From 2809ccaa139aa0d510ee2c04dc949e0268a0fdc5 Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 26 Mar 2017 18:54:01 +0200 Subject: [PATCH] shrink scope of expr_w_temper --- src/frontend/device.c | 2 +- src/frontend/inp.c | 3 ++- src/frontend/inpcom.c | 10 ++++------ src/frontend/nutinp.c | 2 +- src/include/ngspice/cktdefs.h | 1 - src/include/ngspice/fteext.h | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/frontend/device.c b/src/frontend/device.c index b091b7f24..376528278 100644 --- a/src/frontend/device.c +++ b/src/frontend/device.c @@ -1439,7 +1439,7 @@ com_alter_mod(wordlist *wl) modfile = inp_pathopen(filename, readmode); { char *dir_name = ngdirname(filename); - modeldeck = inp_readall(modfile, dir_name, 0, 0); + modeldeck = inp_readall(modfile, dir_name, 0, 0, NULL); free(dir_name); } tfree(input); diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 369901b99..ba14daa7d 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -352,6 +352,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile) wordlist *controls = NULL, *pre_controls = NULL; FILE *lastin, *lastout, *lasterr; double temperature_value; + bool expr_w_temper = FALSE; double startTime, endTime; @@ -364,7 +365,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile) char *dir_name = ngdirname(filename ? filename : "."); startTime = seconds(); - deck = inp_readall(fp, dir_name, comfile, intfile); + deck = inp_readall(fp, dir_name, comfile, intfile, &expr_w_temper); endTime = seconds(); tfree(dir_name); diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index b65970a94..f0747fc2a 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -100,9 +100,6 @@ int dynMaxckt = 0; /* subckt.c 307 */ /* number of parameter substitutions */ long dynsubst; /* spicenum.c 221 */ -/* Expression handling with 'temper' parameter required */ -bool expr_w_temper = FALSE; - static char *readline(FILE *fd); static int get_number_terminals(char *c); @@ -476,7 +473,7 @@ find_assignment(char *str) *-------------------------------------------------------------------------*/ struct line * -inp_readall(FILE *fp, char *dir_name, bool comfile, bool intfile) +inp_readall(FILE *fp, char *dir_name, bool comfile, bool intfile, bool *expr_w_temper_p) { struct line *cc; struct inp_read_t rv; @@ -535,6 +532,7 @@ inp_readall(FILE *fp, char *dir_name, bool comfile, bool intfile) #ifndef XSPICE inp_poly_err(working); #endif + bool expr_w_temper = FALSE; if (inp_compat_mode != COMPATMODE_SPICE3) { /* Do all the compatibility stuff here */ working = cc->li_next; @@ -545,9 +543,9 @@ inp_readall(FILE *fp, char *dir_name, bool comfile, bool intfile) inp_bsource_compat(working); inp_dot_if(working); expr_w_temper = inp_temper_compat(working); - } else { - expr_w_temper = FALSE; } + if (expr_w_temper_p) + *expr_w_temper_p = expr_w_temper; inp_add_series_resistor(working); diff --git a/src/frontend/nutinp.c b/src/frontend/nutinp.c index 7e37b5384..c8b82ec2d 100644 --- a/src/frontend/nutinp.c +++ b/src/frontend/nutinp.c @@ -35,7 +35,7 @@ inp_nutsource(FILE *fp, bool comfile, char *filename) wordlist *controls = NULL; FILE *lastin, *lastout, *lasterr; - deck = inp_readall(fp, NULL, comfile, FALSE); /* still to check if . or filename instead of NULL */ + deck = inp_readall(fp, NULL, comfile, FALSE, NULL); /* still to check if . or filename instead of NULL */ if (!deck) return; diff --git a/src/include/ngspice/cktdefs.h b/src/include/ngspice/cktdefs.h index 0f151c7ed..48b021db4 100644 --- a/src/include/ngspice/cktdefs.h +++ b/src/include/ngspice/cktdefs.h @@ -447,7 +447,6 @@ extern int NIpred(CKTcircuit *ckt); #endif extern IFfrontEnd *SPfrontEnd; -extern bool expr_w_temper; struct circ; extern void inp_evaluate_temper(struct circ *ckt); diff --git a/src/include/ngspice/fteext.h b/src/include/ngspice/fteext.h index afb992352..8b0c8c625 100644 --- a/src/include/ngspice/fteext.h +++ b/src/include/ngspice/fteext.h @@ -212,7 +212,7 @@ extern void inp_source(char *file); void inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile); extern void inp_casefix(char *string); extern void inp_list(FILE *file, struct line *deck, struct line *extras, int type); -extern struct line *inp_readall(FILE *fp, char *dir_name, bool comfile, bool intfile); +extern struct line *inp_readall(FILE *fp, char *dir_name, bool comfile, bool intfile, bool *expr_w_temper); extern FILE *inp_pathopen(char *name, char *mode); extern char *search_identifier(char *str, const char *identifier, char *str_begin); extern struct line *line_nconc(struct line *head, struct line *rest);