Applied Dan patches for Solaris. Asprintf is masked by HAVE_ASPRINTF. The check
is done by autoconf. getopt path not yet applied.
This commit is contained in:
parent
22acf4b96a
commit
87f6f0673b
|
|
@ -165,9 +165,14 @@ AC_CHECK_HEADERS(float.h limits.h values.h)
|
|||
dnl Check for a few mathematical functions:
|
||||
AC_CHECK_FUNCS(erfc logb scalb scalbn asinh acosh atanh)
|
||||
|
||||
|
||||
AC_MSG_RESULT(Checking for the presence of the Garbage Collector:)
|
||||
dnl Check for the garbage collector:
|
||||
AC_CHECK_LIB(gc,GC_malloc,AC_DEFINE(HAVE_LIBGC) LIBS="$LIBS -lgc")
|
||||
|
||||
AC_MSG_RESULT(Checking for the asprintf function:)
|
||||
dnl Check for the asprintf function:
|
||||
AC_CHECK_FUNCS(asprintf)
|
||||
|
||||
|
||||
# Expand the prefix variable (this is really annoying!)
|
||||
if eval "test x$prefix = xNONE"; then
|
||||
|
|
|
|||
14
src/main.c
14
src/main.c
|
|
@ -8,6 +8,9 @@
|
|||
#include <ngspice.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
|
@ -500,7 +503,18 @@ main(int argc, char **argv)
|
|||
struct passwd *pw;
|
||||
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
#ifdef HAVE_ASPRINTF
|
||||
asprintf(&s, "%s/.spiceinit", pw->pw_dir);
|
||||
#else /* ~ HAVE_ASPRINTF */
|
||||
#define INITSTR "/.spiceinit"
|
||||
if ( (s=(char *) malloc(1 + strlen(pw->pw_dir)+strlen(INITSTR))) == NULL){
|
||||
fprintf(stderr,"malloc failed\n");
|
||||
exit(1);
|
||||
}
|
||||
sprintf(s,"%s%s",pw->pw_dir,INITSTR);
|
||||
#endif /* HAVE_ASPRINTF */
|
||||
|
||||
if (access(s, 0) == 0)
|
||||
inp_source(s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ Copyright 1991 Regents of the University of California. All rights reserved.
|
|||
|
||||
#include "ngspice.h"
|
||||
#include "ivars.h"
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
@ -29,10 +34,31 @@ mkvar(char **p, char *path_prefix, char *var_dir, char *env_var)
|
|||
|
||||
/* Override by environment variables */
|
||||
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){
|
||||
if ( (*p = (char *) malloc(strlen(buffer)+1)) == NULL){
|
||||
fprintf(stderr,"malloc failed\n");
|
||||
exit(1);
|
||||
}
|
||||
sprintf(*p,"%s",buffer);
|
||||
/* asprintf(p, "%s", buffer); */
|
||||
}
|
||||
else{
|
||||
if ( (*p = (char *) malloc(strlen(path_prefix) +
|
||||
strlen(DIR_PATHSEP) + strlen(var_dir) + 1)) == NULL){
|
||||
fprintf(stderr,"malloc failed\n");
|
||||
exit(1);
|
||||
}
|
||||
sprintf(*p, "%s%s%s", path_prefix, DIR_PATHSEP, var_dir);
|
||||
/* asprintf(p, "%s%s%s", path_prefix, DIR_PATHSEP, var_dir); */
|
||||
}
|
||||
#endif /* HAVE_ASPRINTF */
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ Author: 1988 Thomas L. Quarles
|
|||
#include "ngspice.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include <wordlist.h>
|
||||
#include <bool.h>
|
||||
#include <inpdefs.h>
|
||||
|
|
@ -26,9 +30,29 @@ IFnewUid(void *ckt, IFuid * newuid, IFuid olduid, char *suffix, int type,
|
|||
int error;
|
||||
|
||||
if (olduid) {
|
||||
#ifdef HAVE_ASPRINTF
|
||||
asprintf(&newname, "%s#%s", (char *) olduid, suffix);
|
||||
#else /* ~ HAVE_ASPRINTF */
|
||||
if ( (newname = (char *) malloc(strlen((char *) olduid) +
|
||||
strlen(suffix) + strlen("#\0")))
|
||||
== NULL){
|
||||
fprintf(stderr,"malloc failed\n");
|
||||
exit(1);
|
||||
}
|
||||
sprintf(newname, "%s#%s", (char *) olduid, suffix);
|
||||
#endif /* HAVE_ASPRINTF */
|
||||
|
||||
} else {
|
||||
|
||||
#ifdef HAVE_ASPRINTF
|
||||
asprintf(&newname, "%s", suffix);
|
||||
#else /* ~ HAVE_ASPRINTF */
|
||||
if ( (newname = (char *) malloc(strlen(suffix) + 1 )) == NULL){
|
||||
fprintf(stderr,"malloc failed\n");
|
||||
exit(1);
|
||||
}
|
||||
sprintf(newname, "%s", suffix);
|
||||
#endif /* HAVE_ASPRINTF */
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ Author: 1985 Thomas L. Quarles
|
|||
|
||||
#include "ngspice.h"
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "fteext.h"
|
||||
#include "ifsim.h"
|
||||
#include "iferrmsg.h"
|
||||
|
|
@ -25,10 +28,27 @@ char *INPerror(int type)
|
|||
if (!val)
|
||||
return (val);
|
||||
|
||||
#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){
|
||||
if ( (ebuf = (char *) malloc(strlen(val) +
|
||||
strlen(errRtn) + 25)) == NULL){
|
||||
fprintf(stderr,"malloc failed\n");
|
||||
exit(1);
|
||||
}
|
||||
sprintf(ebuf, "%s detected in routine \"%s\"\n", val, errRtn);
|
||||
}
|
||||
else{
|
||||
if ( (ebuf = (char *) malloc(strlen(val) + 2)) == NULL){
|
||||
fprintf(stderr,"malloc failed\n");
|
||||
exit(1);
|
||||
}
|
||||
sprintf(ebuf, "%s\n", val);
|
||||
}
|
||||
#endif /* HAVE_ASPRINTF */
|
||||
return ebuf;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue