Browse Source

main.c, whitespace

rlar 15 years ago
parent
commit
2c5c5e2c49
  1. 66
      src/main.c

66
src/main.c

@ -201,13 +201,13 @@ bool ft_nutmeg = FALSE;
extern struct comm spcp_coms[ ]; extern struct comm spcp_coms[ ];
struct comm *cp_coms = spcp_coms; struct comm *cp_coms = spcp_coms;
extern int OUTpBeginPlot(CKTcircuit *,JOB *,IFuid,IFuid,int,int,IFuid *,int,void **);
extern int OUTpData(void *,IFvalue *,IFvalue *);
extern int OUTwBeginPlot(CKTcircuit *,JOB *,IFuid,IFuid,int,int,IFuid *,int,void **);
extern int OUTpBeginPlot(CKTcircuit *,JOB *,IFuid,IFuid,int,int,IFuid *,int,void **);
extern int OUTpData(void *,IFvalue *,IFvalue *);
extern int OUTwBeginPlot(CKTcircuit *,JOB *,IFuid,IFuid,int,int,IFuid *,int,void **);
extern int OUTwReference(void *,IFvalue *,void **); extern int OUTwReference(void *,IFvalue *,void **);
extern int OUTwData(void *,int,IFvalue *,void *), OUTwEnd(void *), OUTendPlot(void *);
extern int OUTwData(void *,int,IFvalue *,void *), OUTwEnd(void *), OUTendPlot(void *);
extern int OUTbeginDomain(void *,IFuid,int,IFvalue *); extern int OUTbeginDomain(void *,IFuid,int,IFvalue *);
extern int OUTendDomain(void *), OUTstopnow(void), OUTerror(int,char *,IFuid *);
extern int OUTendDomain(void *), OUTstopnow(void), OUTerror(int,char *,IFuid *);
extern int OUTattributes(void *,IFuid,int,IFvalue *); extern int OUTattributes(void *,IFuid,int,IFvalue *);
extern void initw(void); extern void initw(void);
@ -432,12 +432,12 @@ COMPATMODE_T ngspice_compat_mode(void)
char behaviour[80] ; char behaviour[80] ;
if( cp_getvar("ngbehavior", CP_STRING, behaviour)){ if( cp_getvar("ngbehavior", CP_STRING, behaviour)){
if (strcasecmp(behaviour,"all")==0)
if (strcasecmp(behaviour, "all")==0)
return( COMPATMODE_ALL ) ; return( COMPATMODE_ALL ) ;
if (strcasecmp(behaviour,"hs")==0)
if (strcasecmp(behaviour, "hs")==0)
return( COMPATMODE_HS ) ; return( COMPATMODE_HS ) ;
if (strcasecmp(behaviour,"spice3")==0)
return( COMPATMODE_SPICE3 ) ;
if (strcasecmp(behaviour, "spice3")==0)
return( COMPATMODE_SPICE3 ) ;
} }
return(COMPATMODE_NATIVE) ; return(COMPATMODE_NATIVE) ;
} /* end ngspice_compat_mode() */ } /* end ngspice_compat_mode() */
@ -719,12 +719,12 @@ read_initialisation_file(char *dir, char *name)
path = name; path = name;
} else { } else {
#ifdef HAVE_ASPRINTF #ifdef HAVE_ASPRINTF
asprintf(&path, "%s" DIR_PATHSEP "%s", dir,name);
asprintf(&path, "%s" DIR_PATHSEP "%s", dir, name);
if(path==NULL) return FALSE; /* memory allocation error */ if(path==NULL) return FALSE; /* memory allocation error */
#else /* ~ HAVE_ASPRINTF */ #else /* ~ HAVE_ASPRINTF */
path = TMALLOC(char, 2 + strlen(dir) + strlen(name)); path = TMALLOC(char, 2 + strlen(dir) + strlen(name));
if(path==NULL) return FALSE; /* memory allocation error */ if(path==NULL) return FALSE; /* memory allocation error */
sprintf(path,"%s" DIR_PATHSEP "%s",dir,name);
sprintf(path, "%s" DIR_PATHSEP "%s", dir, name);
#endif /* HAVE_ASPRINTF */ #endif /* HAVE_ASPRINTF */
} }
@ -737,7 +737,7 @@ read_initialisation_file(char *dir, char *name)
#endif /* HAVE_UNISTD_H */ #endif /* HAVE_UNISTD_H */
inp_source(path); inp_source(path);
#ifdef TRACE #ifdef TRACE
printf("Init file: '%s'\n",path);
printf("Init file: '%s'\n", path);
#endif /* TRACE */ #endif /* TRACE */
result = TRUE; /* loaded okay */ result = TRUE; /* loaded okay */
} }
@ -779,10 +779,10 @@ print_news(void)
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
int err;
int err;
#ifdef SIMULATOR #ifdef SIMULATOR
bool gotone = FALSE;
bool gotone = FALSE;
#else #else
bool gdata = TRUE; bool gdata = TRUE;
#endif #endif
@ -799,13 +799,13 @@ main(int argc, char **argv)
#ifdef TRACE #ifdef TRACE
/* this is used to detect memory leaks during debugging */ /* this is used to detect memory leaks during debugging */
/* added by SDB during debug . . . . */ /* added by SDB during debug . . . . */
/* mtrace(); */
/* mtrace(); */
#endif #endif
#ifdef TRACE #ifdef TRACE
/* this is also used for memory leak plugging . . . */ /* this is also used for memory leak plugging . . . */
/* added by SDB during debug . . . . */ /* added by SDB during debug . . . . */
/* mwDoFlush(1); */
/* mwDoFlush(1); */
#endif #endif
/* MFB tends to jump to 0 on errors. This tends to catch it. */ /* MFB tends to jump to 0 on errors. This tends to catch it. */
@ -840,7 +840,7 @@ main(int argc, char **argv)
ivars(argv[0]); ivars(argv[0]);
cp_in = stdin;
cp_in = stdin;
cp_out = stdout; cp_out = stdout;
cp_err = stderr; cp_err = stderr;
@ -849,6 +849,7 @@ main(int argc, char **argv)
#ifdef MALLOCTRACE #ifdef MALLOCTRACE
mallocTraceInit("malloc.out"); mallocTraceInit("malloc.out");
#endif #endif
#if defined(HAVE_ISATTY) && !defined(HAS_WINDOWS) #if defined(HAVE_ISATTY) && !defined(HAS_WINDOWS)
istty = (bool) isatty(fileno(stdin)); istty = (bool) isatty(fileno(stdin));
#endif #endif
@ -916,7 +917,7 @@ main(int argc, char **argv)
} }
break; break;
case 'a': /* Add control section for autorun */
case 'a': /* Add control section for autorun */
if (!ft_batchmode) { if (!ft_batchmode) {
bool x_true = TRUE; bool x_true = TRUE;
cp_vset("addcontrol", CP_BOOL, &x_true); cp_vset("addcontrol", CP_BOOL, &x_true);
@ -946,11 +947,11 @@ main(int argc, char **argv)
/* turn off buffering for stdout */ /* turn off buffering for stdout */
setbuf(stdout, NULL); setbuf(stdout, NULL);
#ifdef PARALLEL_ARCH #ifdef PARALLEL_ARCH
sprintf (buf, "%s%03d", optarg, ARCHme);
sprintf (buf, "%s%03d", optarg, ARCHme);
#else #else
sprintf (buf, "%s", optarg);
sprintf (buf, "%s", optarg);
#endif #endif
orflag = TRUE;
orflag = TRUE;
} }
break; break;
@ -1128,6 +1129,7 @@ bot:
err = 0; err = 0;
#ifdef SIMULATOR #ifdef SIMULATOR
#ifdef FastRand #ifdef FastRand
// initialization and seed for FastNorm Gaussian random generator // initialization and seed for FastNorm Gaussian random generator
{ {
@ -1151,7 +1153,9 @@ bot:
initw(); initw();
} }
#endif #endif
if (!ft_servermode && !ft_nutmeg) { if (!ft_servermode && !ft_nutmeg) {
/* Concatenate all non-option arguments into a temporary file /* Concatenate all non-option arguments into a temporary file
and load that file into the spice core. and load that file into the spice core.
@ -1160,12 +1164,16 @@ bot:
the temporary file but used the original file instead. The the temporary file but used the original file instead. The
current algorithm is uniform at the expense of a little current algorithm is uniform at the expense of a little
startup time. */ startup time. */
FILE *tempfile = tmpfile(); FILE *tempfile = tmpfile();
#if defined(HAS_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__) #if defined(HAS_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__)
char *tpf = NULL; /* temporary file */
char *dname = NULL; /* input file*/
/* tmpfile() returns NULL, if in MS Windows as non admin user
then we add a tempfile in the local directory */
char *tpf = NULL; /* temporary file */
char *dname = NULL; /* input file*/
/* tmpfile() returns NULL, if in MS Windows as non admin user
then we add a tempfile in the local directory */
if (tempfile == NULL) { if (tempfile == NULL) {
tpf = smktemp("sp"); tpf = smktemp("sp");
tempfile = fopen(tpf, "w+b"); tempfile = fopen(tpf, "w+b");
@ -1206,6 +1214,7 @@ bot:
break; break;
} }
} }
#if defined(HAS_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__) #if defined(HAS_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__)
/* Copy the input file name which otherwise will be lost due to the /* Copy the input file name which otherwise will be lost due to the
temporary file */ temporary file */
@ -1217,6 +1226,7 @@ bot:
/* write source file name into a variable */ /* write source file name into a variable */
cp_vset("sourcefile", CP_STRING, dname); cp_vset("sourcefile", CP_STRING, dname);
#endif #endif
append_to_stream(tempfile, tp); append_to_stream(tempfile, tp);
fclose(tp); fclose(tp);
} }
@ -1233,18 +1243,22 @@ bot:
#endif #endif
gotone = TRUE; gotone = TRUE;
} }
#if defined(HAS_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__) #if defined(HAS_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__)
if (tempfile && tpf && remove(tpf)) if (tempfile && tpf && remove(tpf))
perror("Could not delete temp file"); perror("Could not delete temp file");
#endif #endif
if (ft_batchmode && err) { if (ft_batchmode && err) {
sp_shutdown(EXIT_BAD); sp_shutdown(EXIT_BAD);
} }
} /* --- if (!ft_servermode && !ft_nutmeg) --- */ } /* --- if (!ft_servermode && !ft_nutmeg) --- */
if (!gotone && ft_batchmode && !ft_nutmeg) if (!gotone && ft_batchmode && !ft_nutmeg)
inp_spsource(circuit_file, FALSE, NULL); inp_spsource(circuit_file, FALSE, NULL);
evl: evl:
if (ft_batchmode) { if (ft_batchmode) {
@ -1257,7 +1271,9 @@ evl:
if (st == TRUE) { if (st == TRUE) {
sp_shutdown(EXIT_BAD); sp_shutdown(EXIT_BAD);
} }
st = TRUE; st = TRUE;
if (ft_servermode) { if (ft_servermode) {
if (ft_curckt == NULL) { if (ft_curckt == NULL) {
fprintf(cp_err, "Error: no circuit loaded!\n"); fprintf(cp_err, "Error: no circuit loaded!\n");

Loading…
Cancel
Save