src/main.c, whitespace cleanup

This commit is contained in:
rlar 2015-01-03 21:16:22 +01:00
parent 8369732e7b
commit f8df1a7b2f
1 changed files with 237 additions and 219 deletions

View File

@ -22,8 +22,8 @@
/* SJB added editline support 2005-05-05 */ /* SJB added editline support 2005-05-05 */
#ifdef HAVE_BSDEDITLINE #ifdef HAVE_BSDEDITLINE
# include <editline/readline.h> # include <editline/readline.h>
extern VFunction *rl_event_hook; /* missing from editline/readline.h */ extern VFunction *rl_event_hook; /* missing from editline/readline.h */
extern int rl_catch_signals; /* missing from editline/readline.h */ extern int rl_catch_signals; /* missing from editline/readline.h */
#endif #endif
#include "ngspice/iferrmsg.h" #include "ngspice/iferrmsg.h"
@ -68,8 +68,8 @@
#endif #endif
#if defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE) #if defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE)
char history_file[512] = {'\0'}; char history_file[512] = {'\0'};
static char *application_name; static char *application_name;
#endif #endif
/* Undefine this next line for debug tracing */ /* Undefine this next line for debug tracing */
@ -87,12 +87,12 @@ bool ft_setflag = FALSE; /* TRUE = Don't abort simulation after an interrupt.
char *ft_rawfile = "rawspice.raw"; char *ft_rawfile = "rawspice.raw";
#ifdef HAS_WINGUI #ifdef HAS_WINGUI
extern void winmessage(char *new_msg); /* display a message box (defined in winmain.c)*/ extern void winmessage(char *new_msg); /* display a message box (defined in winmain.c)*/
extern void SetSource( char *Name); /* display the source file name in the source window */ extern void SetSource(char *Name); /* display the source file name in the source window */
extern int xmain(int argc, char **argv); extern int xmain(int argc, char **argv);
FILE *flogp = NULL; /* log file ('-o logfile' command line option) */ FILE *flogp = NULL; /* log file ('-o logfile' command line option) */
#else #else
bool orflag = FALSE; /* global for -o option */ bool orflag = FALSE; /* global for -o option */
#endif #endif
FILE *slogp = NULL; /* soa log file ('--soa-log file' command line option) */ FILE *slogp = NULL; /* soa log file ('--soa-log file' command line option) */
@ -147,7 +147,7 @@ double Temp, RelTemp, Vt;
double RefPsi;/* potential at Infinity */ double RefPsi;/* potential at Infinity */
double EpsNorm, VNorm, NNorm, LNorm, TNorm, JNorm, GNorm, ENorm; double EpsNorm, VNorm, NNorm, LNorm, TNorm, JNorm, GNorm, ENorm;
/* end cider globals */ /* end cider globals */
#endif /* CIDER */ #endif /* CIDER */
struct variable *(*if_getparam)(CKTcircuit *ckt, char **name, char *param, int ind, int do_model); struct variable *(*if_getparam)(CKTcircuit *ckt, char **name, char *param, int ind, int do_model);
@ -158,16 +158,16 @@ static void sp_shutdown(int exitval);
static void app_rl_readlines(void); static void app_rl_readlines(void);
#if defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE) #if defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE)
static char *prompt(void); static char *prompt(void);
#endif #endif
#ifndef X_DISPLAY_MISSING #ifndef X_DISPLAY_MISSING
# include "frontend/plotting/x11.h" # include "frontend/plotting/x11.h"
# ifdef HAVE_GNUREADLINE # ifdef HAVE_GNUREADLINE
static int app_event_func(void); static int app_event_func(void);
# endif # endif
# ifdef HAVE_BSDEDITLINE # ifdef HAVE_BSDEDITLINE
static void app_event_func(void); static void app_event_func(void);
# endif # endif
#endif #endif
@ -185,17 +185,17 @@ extern IFsimulator SIMinfo;
#ifdef SIMULATOR #ifdef SIMULATOR
const bool ft_nutmeg = FALSE; const 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,runDesc **); extern int OUTpBeginPlot(CKTcircuit *, JOB *, IFuid, IFuid, int, int, IFuid *, int, runDesc **);
extern int OUTpData(runDesc *,IFvalue *,IFvalue *); extern int OUTpData(runDesc *, IFvalue *, IFvalue *);
extern int OUTwBeginPlot(CKTcircuit *,JOB *,IFuid,IFuid,int,int,IFuid *,int,runDesc **); extern int OUTwBeginPlot(CKTcircuit *, JOB *, IFuid, IFuid, int, int, IFuid *, int, runDesc **);
extern int OUTwReference(runDesc *,IFvalue *,void **); extern int OUTwReference(runDesc *, IFvalue *, void **);
extern int OUTwData(runDesc *,int,IFvalue *,void *), OUTwEnd(runDesc *), OUTendPlot(runDesc *); extern int OUTwData(runDesc *, int, IFvalue *, void *), OUTwEnd(runDesc *), OUTendPlot(runDesc *);
extern int OUTbeginDomain(runDesc *,IFuid,int,IFvalue *); extern int OUTbeginDomain(runDesc *, IFuid, int, IFvalue *);
extern int OUTendDomain(runDesc *), OUTstopnow(void); extern int OUTendDomain(runDesc *), OUTstopnow(void);
extern void OUTerror(int,char *,IFuid *); extern void OUTerror(int, char *, IFuid *);
#ifdef __GNUC__ #ifdef __GNUC__
extern void OUTerrorf(int, const char *fmt, ...) __attribute__ ((format (__printf__, 2, 3))); extern void OUTerrorf(int, const char *fmt, ...) __attribute__ ((format (__printf__, 2, 3)));
@ -203,7 +203,7 @@ extern void OUTerrorf(int, const char *fmt, ...) __attribute__ ((format (__prin
extern void OUTerrorf(int, const char *fmt, ...); extern void OUTerrorf(int, const char *fmt, ...);
#endif #endif
extern int OUTattributes(runDesc *,IFuid,int,IFvalue *); extern int OUTattributes(runDesc *, IFuid, int, IFvalue *);
extern void initw(void); extern void initw(void);
@ -224,12 +224,12 @@ IFfrontEnd nutmeginfo = {
OUTbeginDomain, OUTbeginDomain,
OUTendDomain, OUTendDomain,
OUTattributes OUTattributes
}; };
#else /* SIMULATOR */ #else /* SIMULATOR */
const bool ft_nutmeg = TRUE; const bool ft_nutmeg = TRUE;
extern struct comm nutcp_coms[ ]; extern struct comm nutcp_coms[];
struct comm *cp_coms = nutcp_coms; struct comm *cp_coms = nutcp_coms;
IFfrontEnd nutmeginfo; IFfrontEnd nutmeginfo;
@ -270,6 +270,7 @@ if_inpdeck(struct line *deck, INPtables **tab)
{ {
NG_IGNORE(tab); NG_IGNORE(tab);
NG_IGNORE(deck); NG_IGNORE(deck);
return NULL; return NULL;
} }
@ -305,6 +306,7 @@ char *
if_errstring(int code) if_errstring(int code)
{ {
NG_IGNORE(code); NG_IGNORE(code);
return "spice error"; return "spice error";
} }
@ -354,6 +356,7 @@ com_snload(wordlist *wl)
{ {
NG_IGNORE(wl); NG_IGNORE(wl);
} }
void void
com_snsave(wordlist *wl) com_snsave(wordlist *wl)
{ {
@ -388,50 +391,59 @@ spice_destroy_devices(void)
#ifdef XSPICE #ifdef XSPICE
/* saj to get nutmeg to compile, not nice but necessary */ /* saj to get nutmeg to compile, not nice but necessary */
Ipc_Tiein_t g_ipc; Ipc_Tiein_t g_ipc;
Ipc_Status_t Ipc_Status_t
ipc_send_errchk(void) ipc_send_errchk(void)
{ {
Ipc_Status_t x = IPC_STATUS_OK; Ipc_Status_t x = IPC_STATUS_OK;
return x; return x;
} }
Ipc_Status_t Ipc_Status_t
ipc_get_line(char *str, int *len, Ipc_Wait_t wait) ipc_get_line(char *str, int *len, Ipc_Wait_t wait)
{ {
Ipc_Status_t x = IPC_STATUS_OK; Ipc_Status_t x = IPC_STATUS_OK;
NG_IGNORE(str); NG_IGNORE(str);
NG_IGNORE(len); NG_IGNORE(len);
NG_IGNORE(wait); NG_IGNORE(wait);
return x; return x;
} }
struct line * struct line *
ENHtranslate_poly(struct line *deck) ENHtranslate_poly(struct line *deck)
{ {
NG_IGNORE(deck); NG_IGNORE(deck);
return NULL; return NULL;
} }
int int
load_opus(char *name) load_opus(char *name)
{ {
NG_IGNORE(name); NG_IGNORE(name);
return 1; return 1;
} }
char * char *
MIFgettok(char **s) MIFgettok(char **s)
{ {
NG_IGNORE(s); NG_IGNORE(s);
return NULL; return NULL;
} }
void void
EVTprint(wordlist *wl) EVTprint(wordlist *wl)
{ {
NG_IGNORE(wl); NG_IGNORE(wl);
} }
struct dvec * struct dvec *
EVTfindvec(char *node) { EVTfindvec(char *node) {
NG_IGNORE(node); NG_IGNORE(node);
return NULL; return NULL;
} }
#endif /* XSPICE */ #endif /* XSPICE */
#endif /* SIMULATOR */ #endif /* SIMULATOR */
@ -456,21 +468,23 @@ int DEVmaxnum = 0;
- Spice3 - Spice3
- all compatibility stuff - all compatibility stuff
*/ */
COMPATMODE_T COMPATMODE_T
ngspice_compat_mode(void) 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, "ps")==0) if (strcasecmp(behaviour, "ps") == 0)
return COMPATMODE_PS; return COMPATMODE_PS;
if (strcasecmp(behaviour, "spice3")==0) if (strcasecmp(behaviour, "spice3") == 0)
return COMPATMODE_SPICE3; return COMPATMODE_SPICE3;
} }
return COMPATMODE_ALL; return COMPATMODE_ALL;
} }
@ -497,7 +511,7 @@ SIMinit(IFfrontEnd *frontEnd, IFsimulator **simulator)
SPfrontEnd = frontEnd; SPfrontEnd = frontEnd;
*simulator = &SIMinfo; *simulator = &SIMinfo;
CONSTroot2 = sqrt(2.); CONSTroot2 = sqrt(2.);
CONSTvt0 = CONSTboltz * (27 /* deg c */ + CONSTCtoK ) / CHARGE; CONSTvt0 = CONSTboltz * (27 /* deg c */ + CONSTCtoK) / CHARGE;
CONSTKoverQ = CONSTboltz / CHARGE; CONSTKoverQ = CONSTboltz / CHARGE;
CONSTe = exp(1.0); CONSTe = exp(1.0);
return OK; return OK;
@ -518,7 +532,7 @@ sp_shutdown(int exitval)
#endif #endif
if (exitval == EXIT_INFO) if (exitval == EXIT_INFO)
exitval = EXIT_NORMAL; exitval = EXIT_NORMAL;
exit (exitval); exit(exitval);
} }
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
@ -535,8 +549,10 @@ prompt(void)
return NULL; /* NULL means no prompt */ return NULL; /* NULL means no prompt */
s = get_alt_prompt(); s = get_alt_prompt();
if (!s) if (!s)
s = cp_promptstring; s = cp_promptstring;
if (!s) if (!s)
s = "->"; s = "->";
@ -554,7 +570,9 @@ prompt(void)
break; break;
} }
} }
*p = '\0'; *p = '\0';
return pbuf; return pbuf;
} }
#endif /* HAVE_GNUREADLINE || HAVE_BSDEDITLINE */ #endif /* HAVE_GNUREADLINE || HAVE_BSDEDITLINE */
@ -615,7 +633,7 @@ app_rl_readlines(void)
rl_instream = cp_in; rl_instream = cp_in;
rl_outstream = cp_out; rl_outstream = cp_out;
#ifndef X_DISPLAY_MISSING #ifndef X_DISPLAY_MISSING
if(dispdev->Input == X11_Input) if (dispdev->Input == X11_Input)
rl_event_hook = app_event_func; rl_event_hook = app_event_func;
#endif #endif
rl_catch_signals = 0; /* disable signal handling */ rl_catch_signals = 0; /* disable signal handling */
@ -846,11 +864,11 @@ main(int argc, char **argv)
istty = (bool) isatty(fileno(stdin)); istty = (bool) isatty(fileno(stdin));
#endif #endif
init_time( ); init_time();
{ {
int rv = SIMinit(&nutmeginfo, &ft_sim); int rv = SIMinit(&nutmeginfo, &ft_sim);
if(rv != OK) { if (rv != OK) {
ft_sperror(rv, "SIMinit"); ft_sperror(rv, "SIMinit");
sp_shutdown(EXIT_BAD); sp_shutdown(EXIT_BAD);
} }
@ -862,7 +880,7 @@ main(int argc, char **argv)
TausSeed(); TausSeed();
/* --- Process command line options --- */ /* --- Process command line options --- */
for(;;) { for (;;) {
enum { soa_log = 1001, }; enum { soa_log = 1001, };
static struct option long_options[] = { static struct option long_options[] = {
@ -885,7 +903,7 @@ main(int argc, char **argv)
int option_index = 0; int option_index = 0;
int c = getopt_long (argc, argv, "hvbac:ino:pqr:st:", int c = getopt_long(argc, argv, "hvbac:ino:pqr:st:",
long_options, &option_index); long_options, &option_index);
if (c == -1) if (c == -1)
@ -894,12 +912,12 @@ main(int argc, char **argv)
switch (c) { switch (c) {
case 'h': /* Help */ case 'h': /* Help */
show_help(); show_help();
sp_shutdown (EXIT_INFO); sp_shutdown(EXIT_INFO);
break; break;
case 'v': /* Version info */ case 'v': /* Version info */
show_version(); show_version();
sp_shutdown (EXIT_INFO); sp_shutdown(EXIT_INFO);
break; break;
case 'b': /* Batch mode */ case 'b': /* Batch mode */
@ -940,7 +958,7 @@ main(int argc, char **argv)
if (optarg) { if (optarg) {
/* switch to line buffering for stdout */ /* switch to line buffering for stdout */
setvbuf(stdout, NULL, _IOLBF, BUFSIZ); setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
sprintf (log_file, "%s", optarg); sprintf(log_file, "%s", optarg);
oflag = TRUE; oflag = TRUE;
} }
break; break;
@ -974,7 +992,7 @@ main(int argc, char **argv)
case soa_log: case soa_log:
if (optarg) { if (optarg) {
sprintf (soa_log_file, "%s", optarg); sprintf(soa_log_file, "%s", optarg);
srflag = TRUE; srflag = TRUE;
} }
break; break;
@ -1009,15 +1027,15 @@ main(int argc, char **argv)
/* flogp used by winmain's putc which writes to file 'log_file' */ /* flogp used by winmain's putc which writes to file 'log_file' */
flogp = fopen(log_file, "w"); flogp = fopen(log_file, "w");
if (!flogp) { if (!flogp) {
perror (log_file); perror(log_file);
sp_shutdown (EXIT_BAD); sp_shutdown(EXIT_BAD);
} }
#else #else
orflag = TRUE; orflag = TRUE;
/* Connect stdout and stderr to file log_file and log stdout */ /* Connect stdout and stderr to file log_file and log stdout */
if (!freopen (log_file, "w", stdout)) { if (!freopen(log_file, "w", stdout)) {
perror (log_file); perror(log_file);
sp_shutdown (EXIT_BAD); sp_shutdown(EXIT_BAD);
} }
dup2(fileno(stdout), fileno(stderr)); dup2(fileno(stdout), fileno(stderr));
setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* enable line buffering */ setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* enable line buffering */
@ -1031,8 +1049,8 @@ main(int argc, char **argv)
/* Open the soa log file */ /* Open the soa log file */
slogp = fopen(soa_log_file, "w"); slogp = fopen(soa_log_file, "w");
if (!slogp) { if (!slogp) {
perror (soa_log_file); perror(soa_log_file);
sp_shutdown (EXIT_BAD); sp_shutdown(EXIT_BAD);
} }
} /* srflag */ } /* srflag */
@ -1059,7 +1077,7 @@ main(int argc, char **argv)
/* Get information on memory status upon startup. /* Get information on memory status upon startup.
Would like to do this later, but cpinit evals commands. Would like to do this later, but cpinit evals commands.
fcn is in resource.c */ fcn is in resource.c */
init_rlimits( ); init_rlimits();
/* Have to initialize cp now. /* Have to initialize cp now.
fcn is in cpitf.c*/ fcn is in cpitf.c*/
@ -1106,13 +1124,13 @@ main(int argc, char **argv)
/* load user's initialisation file /* load user's initialisation file
try accessing the initialisation file in the current directory try accessing the initialisation file in the current directory
if that fails try the alternate name */ if that fails try the alternate name */
if(FALSE == read_initialisation_file("", INITSTR) && if (FALSE == read_initialisation_file("", INITSTR) &&
FALSE == read_initialisation_file("", ALT_INITSTR)) { FALSE == read_initialisation_file("", ALT_INITSTR)) {
/* if that failed try in the user's home directory /* if that failed try in the user's home directory
if their HOME environment variable is set */ if their HOME environment variable is set */
char *homedir = getenv("HOME"); char *homedir = getenv("HOME");
if (homedir) if (homedir)
if(FALSE == read_initialisation_file(homedir, INITSTR) && if (FALSE == read_initialisation_file(homedir, INITSTR) &&
FALSE == read_initialisation_file(homedir, ALT_INITSTR)) { FALSE == read_initialisation_file(homedir, ALT_INITSTR)) {
; ;
} }
@ -1121,7 +1139,7 @@ main(int argc, char **argv)
if (!ft_batchmode) { if (!ft_batchmode) {
com_version(NULL); com_version(NULL);
DevInit( ); DevInit();
print_news(); print_news();
} }
@ -1149,15 +1167,15 @@ main(int argc, char **argv)
// initialization and seed for FastNorm Gaussian random generator // initialization and seed for FastNorm Gaussian random generator
{ {
unsigned int rseed = 66; unsigned int rseed = 66;
initnorm (0, 0); initnorm(0, 0);
if (!cp_getvar("rndseed", CP_NUM, &rseed)) { if (!cp_getvar("rndseed", CP_NUM, &rseed)) {
time_t acttime = time(NULL); time_t acttime = time(NULL);
rseed = (unsigned int) acttime; rseed = (unsigned int) acttime;
} }
initnorm (rseed, 2); initnorm(rseed, 2);
fprintf (cp_out, "SoS %f, seed value: %ld\n", renormalize(), rseed); fprintf(cp_out, "SoS %f, seed value: %ld\n", renormalize(), rseed);
} }
#elif defined (WaGauss) #elif defined(WaGauss)
{ {
unsigned int rseed = 66; unsigned int rseed = 66;
if (!cp_getvar("rndseed", CP_NUM, &rseed)) { if (!cp_getvar("rndseed", CP_NUM, &rseed)) {
@ -1203,7 +1221,7 @@ main(int argc, char **argv)
} }
#endif #endif
if(!tempfile) { if (!tempfile) {
perror("tmpfile()"); perror("tmpfile()");
sp_shutdown(EXIT_BAD); sp_shutdown(EXIT_BAD);
} }
@ -1339,8 +1357,8 @@ main(int argc, char **argv)
#endif /* ~ SIMULATOR */ #endif /* ~ SIMULATOR */
for(;;) for (;;)
if(!SETJMP(jbuf, 1)) { if (!SETJMP(jbuf, 1)) {
/* enter the command processing loop */ /* enter the command processing loop */
cp_interactive = TRUE; cp_interactive = TRUE;
app_rl_readlines(); app_rl_readlines();