inpcom.c, cleanup inp_readall() #1/7, introduce inp_read()

This commit is contained in:
rlar 2013-06-02 17:15:51 +02:00
parent 9b7a5ab54d
commit d598630b72
5 changed files with 26 additions and 11 deletions

View File

@ -1464,7 +1464,7 @@ com_alter_mod(wordlist *wl)
modfile = inp_pathopen(filename, readmode);
{
char *dir_name = ngdirname(filename);
modeldeck = inp_readall(modfile, 0, dir_name, 0, 0);
modeldeck = inp_readall(modfile, dir_name, 0, 0);
free(dir_name);
}
tfree(input);

View File

@ -317,7 +317,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
char *dir_name = ngdirname(filename ? filename : ".");
startTime = seconds();
deck = inp_readall(fp, 0, dir_name, comfile, intfile);
deck = inp_readall(fp, dir_name, comfile, intfile);
endTime = seconds();
tfree(dir_name);

View File

@ -141,6 +141,9 @@ static char *skip_back_ws_(char *d, char *start) { while (d > start && isspa
void tprint(struct line *deck);
static struct line *inp_read(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile);
#ifndef XSPICE
static void inp_poly_err(struct line *deck);
#endif
@ -276,10 +279,10 @@ read_a_lib(char *y, char *dir_name)
if (dir_name_flag == FALSE) {
char *y_dir_name = ngdirname(y);
lib->deck = inp_readall(newfp, 1 /*dummy*/, y_dir_name, FALSE, FALSE);
lib->deck = inp_read(newfp, 1 /*dummy*/, y_dir_name, FALSE, FALSE);
tfree(y_dir_name);
} else {
lib->deck = inp_readall(newfp, 1 /*dummy*/, dir_name, FALSE, FALSE);
lib->deck = inp_read(newfp, 1 /*dummy*/, dir_name, FALSE, FALSE);
}
fclose(newfp);
@ -329,7 +332,7 @@ inp_stitch_continuation_lines(struct line *working)
#ifdef TRACE
/* SDB debug statement */
printf("In inp_readall, processing linked list element line = %d, s = %s . . . \n", working->li_linenum, s);
printf("In inp_read, processing linked list element line = %d, s = %s . . . \n", working->li_linenum, s);
#endif
switch (c) {
@ -456,7 +459,19 @@ find_assignment(char *str)
*-------------------------------------------------------------------------*/
struct line *
inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile)
inp_readall(FILE *fp, char *dir_name, bool comfile, bool intfile)
{
int call_depth = 0;
struct line *cc;
cc = inp_read(fp, call_depth, dir_name, comfile, intfile);
return cc;
}
struct line *
inp_read(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile)
/* fp: in, pointer to file to be read,
call_depth: in, nested call to fcn
dir_name: in, name of directory of file to be read
@ -542,7 +557,7 @@ inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile
#ifdef TRACE
/* SDB debug statement */
printf("in inp_readall, just read %s", buffer);
printf("in inp_read, just read %s", buffer);
#endif
if (!buffer)
@ -644,10 +659,10 @@ inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile
if (dir_name_flag == FALSE) {
char *y_dir_name = ngdirname(y);
newcard = inp_readall(newfp, call_depth+1, y_dir_name, FALSE, FALSE); /* read stuff in include file into netlist */
newcard = inp_read(newfp, call_depth+1, y_dir_name, FALSE, FALSE); /* read stuff in include file into netlist */
tfree(y_dir_name);
} else {
newcard = inp_readall(newfp, call_depth+1, dir_name, FALSE, FALSE); /* read stuff in include file into netlist */
newcard = inp_read(newfp, call_depth+1, dir_name, FALSE, FALSE); /* read stuff in include file into netlist */
}
(void) fclose(newfp);

View File

@ -34,7 +34,7 @@ inp_nutsource(FILE *fp, bool comfile, char *filename)
wordlist *controls = NULL;
FILE *lastin, *lastout, *lasterr;
deck = inp_readall(fp, 0, NULL, comfile, FALSE); /* still to check if . or filename instead of NULL */
deck = inp_readall(fp, NULL, comfile, FALSE); /* still to check if . or filename instead of NULL */
if (!deck)
return;

View File

@ -209,7 +209,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, int call_depth, char *dir_name, bool comfile, bool intfile);
extern struct line *inp_readall(FILE *fp, char *dir_name, bool comfile, bool intfile);
extern FILE *inp_pathopen(char *name, char *mode);
extern char** circarray;