diff --git a/configure.ac b/configure.ac index 28c0d6cfc..822b8b5a6 100644 --- a/configure.ac +++ b/configure.ac @@ -751,31 +751,9 @@ AC_TRY_LINK([#include ],[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], [], diff --git a/src/frontend/terminal.c b/src/frontend/terminal.c index ec9dbf880..7a1a8ffec 100644 --- a/src/frontend/terminal.c +++ b/src/frontend/terminal.c @@ -13,17 +13,6 @@ Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group #include -#ifdef HAVE_ASPRINTF -#ifdef HAVE_LIBIBERTY_H /* asprintf */ -#include -#elif defined(__MINGW32__) || defined(__SUNPRO_C) -/* we have asprintf, but not libiberty.h */ -#include -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 #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 } diff --git a/src/main.c b/src/main.c index 0e1cbb455..aa7e6388d 100644 --- a/src/main.c +++ b/src/main.c @@ -9,16 +9,6 @@ #include "ngspice/ngspice.h" -#ifdef HAVE_ASPRINTF -# ifdef HAVE_LIBIBERTY_H /* asprintf */ -# include -# elif defined(__MINGW32__) || defined(__SUNPRO_C) /* we have asprintf, but not libiberty.h */ -# include - extern int asprintf(char **out, const char *fmt, ...); - extern int vasprintf(char **out, const char *fmt, va_list ap); -# endif -#endif - #include #include @@ -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; } diff --git a/src/misc/ivars.c b/src/misc/ivars.c index ae6ac6239..9a504bcf6 100644 --- a/src/misc/ivars.c +++ b/src/misc/ivars.c @@ -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 -#elif defined(__MINGW32__) || defined(__SUNPRO_C) /* we have asprintf, but not libiberty.h */ -#include -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 diff --git a/src/sharedspice.c b/src/sharedspice.c index 4649db8a8..f21dee18a 100644 --- a/src/sharedspice.c +++ b/src/sharedspice.c @@ -163,16 +163,6 @@ typedef void (*sighandler)(int); #define S_IRWXU _S_IWRITE #endif -#ifdef HAVE_ASPRINTF -#ifdef HAVE_LIBIBERTY_H /* asprintf */ -#include -#elif defined(__MINGW32__) || defined(__SUNPRO_C) /* we have asprintf, but not libiberty.h */ -#include -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[ ]; diff --git a/src/spicelib/parser/ifnewuid.c b/src/spicelib/parser/ifnewuid.c index 5b874e136..8afc74d78 100644 --- a/src/spicelib/parser/ifnewuid.c +++ b/src/spicelib/parser/ifnewuid.c @@ -5,16 +5,6 @@ Author: 1988 Thomas L. Quarles #include "ngspice/ngspice.h" -#ifdef HAVE_ASPRINTF -#ifdef HAVE_LIBIBERTY_H /* asprintf */ -#include -#elif defined(__MINGW32__) || defined(__SUNPRO_C) /* we have asprintf, but not libiberty.h */ -#include -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: diff --git a/src/spicelib/parser/inperror.c b/src/spicelib/parser/inperror.c index d6da34f40..9113421b8 100644 --- a/src/spicelib/parser/inperror.c +++ b/src/spicelib/parser/inperror.c @@ -9,16 +9,6 @@ Author: 1985 Thomas L. Quarles #include "ngspice/ngspice.h" -#ifdef HAVE_ASPRINTF -#ifdef HAVE_LIBIBERTY_H /* asprintf */ -#include -#elif defined(__MINGW32__) || defined(__SUNPRO_C) /* we have asprintf, but not libiberty.h */ -#include -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; } diff --git a/src/tclspice.c b/src/tclspice.c index 2dbbaae62..f0efe02ca 100644 --- a/src/tclspice.c +++ b/src/tclspice.c @@ -136,16 +136,6 @@ typedef void (*sighandler)(int); #define S_IRWXU _S_IWRITE #endif -#ifdef HAVE_ASPRINTF -#ifdef HAVE_LIBIBERTY_H /* asprintf */ -#include -#elif defined(__MINGW32__) || defined(__SUNPRO_C) /* we have asprintf, but not libiberty.h */ -#include -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); } diff --git a/visualc-shared/include/ngspice/config.h b/visualc-shared/include/ngspice/config.h index 8a9ed1b17..c92038494 100644 --- a/visualc-shared/include/ngspice/config.h +++ b/visualc-shared/include/ngspice/config.h @@ -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 header file. */ -/* #undef HAVE_LIBGEN_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LIBIBERTY_H */ - /* Define to 1 if you have the header file. */ /* #undef HAVE_LIBINTL_H */ diff --git a/visualc/include/ngspice/config.h b/visualc/include/ngspice/config.h index 554dd739e..b2ebef3aa 100644 --- a/visualc/include/ngspice/config.h +++ b/visualc/include/ngspice/config.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 header file. */ -/* #undef HAVE_LIBGEN_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LIBIBERTY_H */ - /* Define to 1 if you have the header file. */ /* #undef HAVE_LIBINTL_H */