diff --git a/src/frontend/device.c b/src/frontend/device.c index 31d6bb796..44a268321 100644 --- a/src/frontend/device.c +++ b/src/frontend/device.c @@ -1464,7 +1464,7 @@ com_alter_mod(wordlist *wl) modfile = inp_pathopen(filename, readmode); { char *dir_name = ngdirname(filename); - inp_readall(modfile, &modeldeck, 0, dir_name, 0); + modeldeck = inp_readall(modfile, 0, dir_name, 0); free(dir_name); } tfree(input); diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 9cb0bbd47..5d82d7a9b 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -302,7 +302,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename) char *dir_name = ngdirname(filename ? filename : "."); startTime = seconds(); - inp_readall(fp, &deck, 0, dir_name, comfile); + deck = inp_readall(fp, 0, dir_name, comfile); endTime = seconds(); tfree(dir_name); diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index a337ff366..b9adc51ad 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -169,10 +169,10 @@ read_a_lib(char *y, int call_depth, char *dir_name) if (dir_name_flag == FALSE) { char *y_dir_name = ngdirname(y); - inp_readall(newfp, &libraries[num_libraries-1], call_depth+1, y_dir_name, FALSE); + libraries[num_libraries-1] = inp_readall(newfp, call_depth+1, y_dir_name, FALSE); tfree(y_dir_name); } else { - inp_readall(newfp, &libraries[num_libraries-1], call_depth+1, dir_name, FALSE); + libraries[num_libraries-1] = inp_readall(newfp, call_depth+1, dir_name, FALSE); } fclose(newfp); @@ -317,10 +317,9 @@ expand_libs(int line_number) ... debug printout to debug-out.txt *-------------------------------------------------------------------------*/ -void -inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool comfile) +struct line * +inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile) /* fp: in, pointer to file to be read, - data: out, linked list of cards call_depth: in, nested call to fcn dir_name: in, name of directory of file to be read comfile: in, TRUE if command file (e.g. spinit, .spiceinit @@ -541,10 +540,10 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c if (dir_name_flag == FALSE) { char *y_dir_name = ngdirname(y); - inp_readall(newfp, &newcard, call_depth+1, y_dir_name, FALSE); /* read stuff in include file into netlist */ + newcard = inp_readall(newfp, call_depth+1, y_dir_name, FALSE); /* read stuff in include file into netlist */ tfree(y_dir_name); } else { - inp_readall(newfp, &newcard, call_depth+1, dir_name, FALSE); /* read stuff in include file into netlist */ + newcard = inp_readall(newfp, call_depth+1, dir_name, FALSE); /* read stuff in include file into netlist */ } (void) fclose(newfp); @@ -640,10 +639,8 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c tfree(buffer); } /* end while ((buffer = readline(fp)) != NULL) */ - if (!end) { /* No stuff here */ - *data = NULL; - return; - } + if (!end) /* No stuff here */ + return NULL; if (call_depth == 0 && found_end == TRUE) { struct line *prev; @@ -772,11 +769,8 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c /* The following processing of an input file is not required for command files like spinit or .spiceinit, so return command files here. */ - if (comfile) { - /* save the return value (via **data) */ - *data = cc; - return; - } + if (comfile) + return cc; working = cc->li_next; @@ -825,9 +819,6 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c inp_add_series_resistor(working); } - /* save the return value (via **data) */ - *data = cc; - /* get max. line length and number of lines in input deck, and renumber the lines, count the number of '{' per line as an upper estimate of the number @@ -862,6 +853,8 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c fprintf(stdout, "max line length %d, max subst. per line %d, number of lines %d\n", (int) max_line_length, no_braces, dynmaxline); } + + return cc; } diff --git a/src/frontend/nutinp.c b/src/frontend/nutinp.c index 77f566f07..631764d0e 100644 --- a/src/frontend/nutinp.c +++ b/src/frontend/nutinp.c @@ -34,7 +34,7 @@ inp_nutsource(FILE *fp, bool comfile, char *filename) wordlist *controls = NULL; FILE *lastin, *lastout, *lasterr; - inp_readall(fp, &deck, 0, NULL, comfile); /* still to check if . or filename instead of NULL */ + deck = inp_readall(fp, 0, NULL, comfile); /* still to check if . or filename instead of NULL */ if (!deck) return; diff --git a/src/include/ngspice/fteext.h b/src/include/ngspice/fteext.h index 0c30ec1d3..e8e081062 100644 --- a/src/include/ngspice/fteext.h +++ b/src/include/ngspice/fteext.h @@ -206,7 +206,7 @@ extern void inp_source(char *file); void inp_spsource(FILE *fp, bool comfile, char *filename); extern void inp_casefix(char *string); extern void inp_list(FILE *file, struct line *deck, struct line *extras, int type); -extern void inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool comfile); +extern struct line *inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile); extern FILE *inp_pathopen(char *name, char *mode); /* nutinp.c */