inp_readall() change function signature for readability

This commit is contained in:
rlar 2013-02-12 17:41:33 +01:00
parent aeb850021b
commit aa573f79e8
5 changed files with 16 additions and 23 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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 */