drop asprintf()
This commit is contained in:
parent
80dd41451f
commit
cc56c90b9d
24
configure.ac
24
configure.ac
|
|
@ -751,31 +751,9 @@ AC_TRY_LINK([#include <setjmp.h>],[jmp_buf env; sigsetjmp(env, 1);],
|
|||
AC_DEFINE([HAVE_SIGSETJMP], [], [Define if we have sigsetjmp().])],
|
||||
[AC_MSG_RESULT([no])])
|
||||
|
||||
# A mingw ngspice dll with linking against libiberty.a seems not to be possible.
|
||||
# Because there is a internal replacement for asprintf, and dirmane is not been used anywhere,
|
||||
# just skip it.
|
||||
case $host_os in
|
||||
*mingw* )
|
||||
AC_MSG_RESULT([Cannot make dll from libiberty.a, no check for headers])
|
||||
;;
|
||||
* )
|
||||
|
||||
# Check for some headers (asprintf, dirname, etc.)
|
||||
AC_CHECK_HEADERS([libiberty.h libgen.h])
|
||||
|
||||
# Check for the asprintf function:
|
||||
AC_CHECK_FUNCS([asprintf], [],
|
||||
[AC_CHECK_LIB([iberty], [asprintf],
|
||||
[AC_DEFINE([HAVE_ASPRINTF], [1], [Have asprintf in libiberty])
|
||||
LIBS="$LIBS -liberty"])])
|
||||
|
||||
;;
|
||||
esac
|
||||
|
||||
# Check for the snprintf function:
|
||||
if test "x$ac_cv_func_asprintf" = xno ; then
|
||||
AC_CHECK_FUNCS([snprintf])
|
||||
fi
|
||||
AC_CHECK_FUNCS([snprintf])
|
||||
|
||||
# Check for the dirname function:
|
||||
AC_CHECK_FUNCS([dirname], [],
|
||||
|
|
|
|||
|
|
@ -13,17 +13,6 @@ Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
|
|||
#include <stdarg.h>
|
||||
|
||||
|
||||
#ifdef HAVE_ASPRINTF
|
||||
#ifdef HAVE_LIBIBERTY_H /* asprintf */
|
||||
#include <libiberty.h>
|
||||
#elif defined(__MINGW32__) || defined(__SUNPRO_C)
|
||||
/* we have asprintf, but not libiberty.h */
|
||||
#include <stdarg.h>
|
||||
extern int asprintf(char **out, const char *fmt, ...);
|
||||
extern int vasprintf(char **out, const char *fmt, va_list ap);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SGTTY_H
|
||||
#include <sgtty.h>
|
||||
#endif
|
||||
|
|
@ -262,20 +251,9 @@ out_send(char *string)
|
|||
void
|
||||
out_vprintf(const char *fmt, va_list ap)
|
||||
{
|
||||
#if defined(HAVE_ASPRINTF) /* seems the best solution */
|
||||
char * tbuf;
|
||||
vasprintf(&tbuf, fmt, ap);
|
||||
char *tbuf = tvprintf(fmt, ap);
|
||||
out_send(tbuf);
|
||||
FREE(tbuf);
|
||||
#elif defined(HAVE_SNPRINTF) /* the second best */
|
||||
static char out_pbuf[8*BSIZE_SP];
|
||||
vsnprintf(out_pbuf, sizeof(out_pbuf), fmt, ap);
|
||||
out_send(out_pbuf);
|
||||
#else /* guaranteed a bug for long messages */
|
||||
static char out_pbuf[8*BSIZE_SP];
|
||||
vsprintf(out_pbuf, fmt, ap);
|
||||
out_send(out_pbuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
24
src/main.c
24
src/main.c
|
|
@ -9,16 +9,6 @@
|
|||
|
||||
#include "ngspice/ngspice.h"
|
||||
|
||||
#ifdef HAVE_ASPRINTF
|
||||
# ifdef HAVE_LIBIBERTY_H /* asprintf */
|
||||
# include <libiberty.h>
|
||||
# elif defined(__MINGW32__) || defined(__SUNPRO_C) /* we have asprintf, but not libiberty.h */
|
||||
# include <stdarg.h>
|
||||
extern int asprintf(char **out, const char *fmt, ...);
|
||||
extern int vasprintf(char **out, const char *fmt, va_list ap);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
|
@ -742,13 +732,8 @@ read_initialisation_file(char *dir, char *name)
|
|||
if(dir == NULL || dir[0]=='\0') {
|
||||
path = name;
|
||||
} else {
|
||||
#ifdef HAVE_ASPRINTF
|
||||
asprintf(&path, "%s" DIR_PATHSEP "%s", dir, name);
|
||||
if(path==NULL) return FALSE; /* memory allocation error */
|
||||
#else /* ~ HAVE_ASPRINTF */
|
||||
path = tprintf("%s" DIR_PATHSEP "%s", dir, name);
|
||||
if(path==NULL) return FALSE; /* memory allocation error */
|
||||
#endif /* HAVE_ASPRINTF */
|
||||
}
|
||||
|
||||
/* now access the file */
|
||||
|
|
@ -765,13 +750,8 @@ read_initialisation_file(char *dir, char *name)
|
|||
result = TRUE; /* loaded okay */
|
||||
}
|
||||
|
||||
/* if dir was not NULL and not empty then we allocated memory above */
|
||||
if(dir!=NULL && dir[0] !='\0')
|
||||
#ifdef HAVE_ASPRINTF
|
||||
free(path);
|
||||
#else
|
||||
tfree(path);
|
||||
#endif /* HAVE_ASPRINTF */
|
||||
if (path != name)
|
||||
tfree(path);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,16 +6,6 @@ Copyright 1991 Regents of the University of California. All rights reserved.
|
|||
#include "ivars.h"
|
||||
#include "../misc/util.h" /* ngdirname() */
|
||||
|
||||
#ifdef HAVE_ASPRINTF
|
||||
#ifdef HAVE_LIBIBERTY_H /* asprintf */
|
||||
#include <libiberty.h>
|
||||
#elif defined(__MINGW32__) || defined(__SUNPRO_C) /* we have asprintf, but not libiberty.h */
|
||||
#include <stdarg.h>
|
||||
extern int asprintf(char **out, const char *fmt, ...);
|
||||
extern int vasprintf(char **out, const char *fmt, va_list ap);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
char *Spice_Path;
|
||||
char *News_File;
|
||||
char *Help_Path;
|
||||
|
|
@ -34,26 +24,13 @@ env_overr(char **v, char *e)
|
|||
static void
|
||||
mkvar(char **p, char *path_prefix, char *var_dir, char *env_var)
|
||||
{
|
||||
char *buffer;
|
||||
|
||||
/* Override by environment variables */
|
||||
buffer = getenv(env_var);
|
||||
char *buffer = getenv(env_var);
|
||||
|
||||
#ifdef HAVE_ASPRINTF
|
||||
if (buffer)
|
||||
asprintf(p, "%s", buffer);
|
||||
else
|
||||
asprintf(p, "%s%s%s", path_prefix, DIR_PATHSEP, var_dir);
|
||||
#else /* ~ HAVE_ASPRINTF */
|
||||
if (buffer){
|
||||
*p = tprintf("%s",buffer);
|
||||
/* asprintf(p, "%s", buffer); */
|
||||
}
|
||||
else{
|
||||
else
|
||||
*p = tprintf("%s%s%s", path_prefix, DIR_PATHSEP, var_dir);
|
||||
/* asprintf(p, "%s%s%s", path_prefix, DIR_PATHSEP, var_dir); */
|
||||
}
|
||||
#endif /* HAVE_ASPRINTF */
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -163,16 +163,6 @@ typedef void (*sighandler)(int);
|
|||
#define S_IRWXU _S_IWRITE
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ASPRINTF
|
||||
#ifdef HAVE_LIBIBERTY_H /* asprintf */
|
||||
#include <libiberty.h>
|
||||
#elif defined(__MINGW32__) || defined(__SUNPRO_C) /* we have asprintf, but not libiberty.h */
|
||||
#include <stdarg.h>
|
||||
extern int asprintf(char **out, const char *fmt, ...);
|
||||
extern int vasprintf(char **out, const char *fmt, va_list ap);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern IFfrontEnd nutmeginfo;
|
||||
|
||||
extern struct comm spcp_coms[ ];
|
||||
|
|
|
|||
|
|
@ -5,16 +5,6 @@ Author: 1988 Thomas L. Quarles
|
|||
|
||||
#include "ngspice/ngspice.h"
|
||||
|
||||
#ifdef HAVE_ASPRINTF
|
||||
#ifdef HAVE_LIBIBERTY_H /* asprintf */
|
||||
#include <libiberty.h>
|
||||
#elif defined(__MINGW32__) || defined(__SUNPRO_C) /* we have asprintf, but not libiberty.h */
|
||||
#include <stdarg.h>
|
||||
extern int asprintf(char **out, const char *fmt, ...);
|
||||
extern int vasprintf(char **out, const char *fmt, va_list ap);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "ngspice/wordlist.h"
|
||||
#include "ngspice/bool.h"
|
||||
#include "ngspice/inpdefs.h"
|
||||
|
|
@ -35,21 +25,10 @@ IFnewUid(CKTcircuit *ckt, IFuid * newuid, IFuid olduid, char *suffix, int type,
|
|||
char *newname;
|
||||
int error;
|
||||
|
||||
if (olduid) {
|
||||
#ifdef HAVE_ASPRINTF
|
||||
asprintf(&newname, "%s#%s", olduid, suffix);
|
||||
#else /* ~ HAVE_ASPRINTF */
|
||||
newname = tprintf("%s#%s", olduid, suffix);
|
||||
#endif /* HAVE_ASPRINTF */
|
||||
|
||||
} else {
|
||||
|
||||
#ifdef HAVE_ASPRINTF
|
||||
asprintf(&newname, "%s", suffix);
|
||||
#else /* ~ HAVE_ASPRINTF */
|
||||
newname = tprintf("%s", suffix);
|
||||
#endif /* HAVE_ASPRINTF */
|
||||
}
|
||||
if (olduid)
|
||||
newname = tprintf("%s#%s", olduid, suffix);
|
||||
else
|
||||
newname = tprintf("%s", suffix);
|
||||
|
||||
switch (type) {
|
||||
case UID_ANALYSIS:
|
||||
|
|
|
|||
|
|
@ -9,16 +9,6 @@ Author: 1985 Thomas L. Quarles
|
|||
|
||||
#include "ngspice/ngspice.h"
|
||||
|
||||
#ifdef HAVE_ASPRINTF
|
||||
#ifdef HAVE_LIBIBERTY_H /* asprintf */
|
||||
#include <libiberty.h>
|
||||
#elif defined(__MINGW32__) || defined(__SUNPRO_C) /* we have asprintf, but not libiberty.h */
|
||||
#include <stdarg.h>
|
||||
extern int asprintf(char **out, const char *fmt, ...);
|
||||
extern int vasprintf(char **out, const char *fmt, va_list ap);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "ngspice/fteext.h"
|
||||
#include "ngspice/ifsim.h"
|
||||
#include "ngspice/iferrmsg.h"
|
||||
|
|
@ -41,18 +31,11 @@ char *INPerror(int type)
|
|||
if (!val)
|
||||
return NULL;
|
||||
|
||||
#ifdef HAVE_ASPRINTF
|
||||
if (errRtn)
|
||||
asprintf(&ebuf, "%s detected in routine \"%s\"\n", val, errRtn);
|
||||
else
|
||||
asprintf(&ebuf, "%s\n", val);
|
||||
#else /* ~ HAVE_ASPRINTF */
|
||||
if (errRtn) {
|
||||
ebuf = tprintf("%s detected in routine \"%s\"\n", val, errRtn);
|
||||
} else {
|
||||
else
|
||||
ebuf = tprintf("%s\n", val);
|
||||
}
|
||||
#endif /* HAVE_ASPRINTF */
|
||||
|
||||
tfree(val);
|
||||
return ebuf;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,16 +136,6 @@ typedef void (*sighandler)(int);
|
|||
#define S_IRWXU _S_IWRITE
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ASPRINTF
|
||||
#ifdef HAVE_LIBIBERTY_H /* asprintf */
|
||||
#include <libiberty.h>
|
||||
#elif defined(__MINGW32__) || defined(__SUNPRO_C) /* we have asprintf, but not libiberty.h */
|
||||
#include <stdarg.h>
|
||||
extern int asprintf(char **out, const char *fmt, ...);
|
||||
extern int vasprintf(char **out, const char *fmt, va_list ap);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern IFfrontEnd nutmeginfo;
|
||||
|
||||
extern struct comm spcp_coms[ ];
|
||||
|
|
@ -2532,11 +2522,8 @@ Spice_Init(Tcl_Interp *interp)
|
|||
struct passwd *pw;
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
#ifdef HAVE_ASPRINTF
|
||||
asprintf(&s, "%s%s", pw->pw_dir, INITSTR);
|
||||
#else
|
||||
s = tprintf("%s%s", pw->pw_dir, INITSTR);
|
||||
#endif
|
||||
|
||||
if (access(s, 0) == 0)
|
||||
inp_source(s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,9 +76,6 @@
|
|||
/* Define to 1 if you have the `asinh' function. */
|
||||
/* #undef HAVE_ASINH */
|
||||
|
||||
/* Define to 1 if you have the `asprintf' function. */
|
||||
/* #undef HAVE_ASPRINTF */
|
||||
|
||||
/* Define to 1 if you have the `atanh' function. */
|
||||
/* #undef HAVE_ATANH */
|
||||
|
||||
|
|
@ -166,12 +163,6 @@
|
|||
/* Define if we want garbage collection enabled */
|
||||
/* #undef HAVE_LIBGC */
|
||||
|
||||
/* Define to 1 if you have the <libgen.h> header file. */
|
||||
/* #undef HAVE_LIBGEN_H */
|
||||
|
||||
/* Define to 1 if you have the <libiberty.h> header file. */
|
||||
/* #undef HAVE_LIBIBERTY_H */
|
||||
|
||||
/* Define to 1 if you have the <libintl.h> header file. */
|
||||
/* #undef HAVE_LIBINTL_H */
|
||||
|
||||
|
|
|
|||
|
|
@ -71,9 +71,6 @@
|
|||
/* Define to 1 if you have the `asinh' function. */
|
||||
/* #undef HAVE_ASINH */
|
||||
|
||||
/* Define to 1 if you have the `asprintf' function. */
|
||||
/* #undef HAVE_ASPRINTF */
|
||||
|
||||
/* Define to 1 if you have the `atanh' function. */
|
||||
/* #undef HAVE_ATANH */
|
||||
|
||||
|
|
@ -171,12 +168,6 @@
|
|||
/* Define if we want garbage collection enabled */
|
||||
/* #undef HAVE_LIBGC */
|
||||
|
||||
/* Define to 1 if you have the <libgen.h> header file. */
|
||||
/* #undef HAVE_LIBGEN_H */
|
||||
|
||||
/* Define to 1 if you have the <libiberty.h> header file. */
|
||||
/* #undef HAVE_LIBIBERTY_H */
|
||||
|
||||
/* Define to 1 if you have the <libintl.h> header file. */
|
||||
/* #undef HAVE_LIBINTL_H */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue