Add an additional funtion parameter 'filename' to fcn inp_readall

to transfer not only the folder, but also the file name of the
current input
This commit is contained in:
Holger Vogt 2024-04-26 11:11:36 +02:00
parent da3d51ce9a
commit e151b691fb
5 changed files with 9 additions and 9 deletions

View File

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

View File

@ -532,7 +532,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
/* inp_source() called with fp: load from file, */ /* inp_source() called with fp: load from file, */
/* called with *fp == NULL and intfile: we want to load circuit from circarray */ /* called with *fp == NULL and intfile: we want to load circuit from circarray */
if (fp || intfile) { if (fp || intfile) {
deck = inp_readall(fp, dir_name, comfile, intfile, &expr_w_temper); deck = inp_readall(fp, dir_name, filename, comfile, intfile, &expr_w_temper);
/* files starting with *ng_script are user supplied command files */ /* files starting with *ng_script are user supplied command files */
if (deck && ciprefix("*ng_script", deck->line)) if (deck && ciprefix("*ng_script", deck->line))
@ -580,7 +580,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
fprintf(fdo, "****************** complete mc deck ***************\n\n"); fprintf(fdo, "****************** complete mc deck ***************\n\n");
/* now completely */ /* now completely */
for (tc = deck; tc; tc = tc->nextcard) for (tc = deck; tc; tc = tc->nextcard)
fprintf(fdo, "%6d %6d %s\n", tc->linenum_orig, tc->linenum, tc->line); fprintf(fdo, "%6s %6d %6d %s\n", tc->linesource, tc->linenum_orig, tc->linenum, tc->line);
fclose(fdo); fclose(fdo);
} }
else else
@ -962,17 +962,17 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
struct card *tc = NULL; struct card *tc = NULL;
fprintf(fdo, "**************** uncommented deck **************\n\n"); fprintf(fdo, "**************** uncommented deck **************\n\n");
/* always print first line */ /* always print first line */
fprintf(fdo, "%6d %6d %s\n", deck->linenum_orig, deck->linenum, deck->line); fprintf(fdo, "%6s %6d %6d %s\n", deck->linesource, deck->linenum_orig, deck->linenum, deck->line);
/* here without out-commented lines */ /* here without out-commented lines */
for (tc = deck->nextcard; tc; tc = tc->nextcard) { for (tc = deck->nextcard; tc; tc = tc->nextcard) {
if (*(tc->line) == '*') if (*(tc->line) == '*')
continue; continue;
fprintf(fdo, "%6d %6d %s\n", tc->linenum_orig, tc->linenum, tc->line); fprintf(fdo, "%6s %6d %6d %s\n", tc->linesource, tc->linenum_orig, tc->linenum, tc->line);
} }
fprintf(fdo, "\n****************** complete deck ***************\n\n"); fprintf(fdo, "\n****************** complete deck ***************\n\n");
/* now completely */ /* now completely */
for (tc = deck; tc; tc = tc->nextcard) for (tc = deck; tc; tc = tc->nextcard)
fprintf(fdo, "%6d %6d %s\n", tc->linenum_orig, tc->linenum, tc->line); fprintf(fdo, "%6s %6d %6d %s\n", tc->linesource, tc->linenum_orig, tc->linenum, tc->line);
fclose(fdo); fclose(fdo);
} }
else else

View File

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

View File

@ -217,7 +217,7 @@ extern void inp_source(const char *file);
int inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile); int inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile);
extern void inp_casefix(char *string); extern void inp_casefix(char *string);
extern void inp_list(FILE *file, struct card *deck, struct card *extras, int type); extern void inp_list(FILE *file, struct card *deck, struct card *extras, int type);
struct card *inp_readall(FILE *fp, const char *dir_name, struct card *inp_readall(FILE *fp, const char *dir_name, const char* file_name,
bool comfile, bool intfile, bool *expr_w_temper_p); bool comfile, bool intfile, bool *expr_w_temper_p);
extern FILE *inp_pathopen(const char *name, const char *mode); extern FILE *inp_pathopen(const char *name, const char *mode);
extern char *search_identifier(char *str, const char *identifier, char *str_begin); extern char *search_identifier(char *str, const char *identifier, char *str_begin);

View File

@ -229,7 +229,7 @@ static struct card *expand_deck(struct card *head)
/* The cards are passed to _inp_readall() via a global. */ /* The cards are passed to _inp_readall() via a global. */
circarray = pointers; circarray = pointers;
card = inp_readall(NULL, Infile_Path, FALSE, TRUE, NULL); card = inp_readall(NULL, Infile_Path, "autobridge", FALSE, TRUE, NULL);
card = inp_subcktexpand(card); card = inp_subcktexpand(card);
ft_ngdebug = save_debug; ft_ngdebug = save_debug;