From 33b11f959816ea76fa9efb14b3383e6c90bb4d70 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sat, 9 Apr 2016 12:25:37 +0200 Subject: [PATCH] comments improved --- src/frontend/inp.c | 5 ++++- src/frontend/inpcom.c | 21 ++++++++++++++++++--- src/frontend/subckt.c | 2 +- src/misc/string.c | 4 ++++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 3dca5e2b6..89abf2c42 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -327,15 +327,18 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile) tfree(dir_name); /* if nothing came back from inp_readall, just close fp and return to caller */ - if (!deck) { /* MW. We must close fp always when returning */ + if (!deck) { if (!intfile) fclose(fp); return; } if (!comfile) { + /* Extract the .option lines from the deck into 'options', + and remove them from the deck. */ options = inp_getopts(deck); + /* copy a deck before subckt substitution. */ realdeck = inp_deckcopy(deck); /* Save the title before INPgetTitle gets it. */ diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 4aed8aaf2..7cb87e97f 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -548,7 +548,7 @@ inp_readall(FILE *fp, char *dir_name, bool comfile, bool intfile) /* 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 - of parameter substitutions in a line*/ + of parameter substitutions in a line */ dynmaxline = 0; max_line_length = 0; no_braces = 0; @@ -1320,6 +1320,15 @@ inp_chk_for_multi_in_vcvs(struct line *c, int *line_number) } +/* If ngspice is started with option -a, then variable 'autorun' + * will be set and the following function scans the deck. + * If 'run' is not found, a .control section will be added: + * .control + * run + * op ; if .op is found + * write rawfile ; if rawfile given + * .endc + */ static void inp_add_control_section(struct line *deck, int *line_number) { @@ -1386,8 +1395,8 @@ inp_add_control_section(struct line *deck, int *line_number) } -// look for shell-style end-of-line continuation '\\' - +/* overwrite shell-style end-of-line continuation '\\' with spaces, + * and return TRUE when found */ static bool chk_for_line_continuation(char *line) { @@ -5760,6 +5769,10 @@ inp_poly_err(struct line *card) #endif +/* Used for debugging. You may add + * tprint(working); + * somewhere in function inp_readall() of this file to have + * a printout of the actual deck written to file "tprint-out.txt" */ void tprint(struct line *t) { @@ -6021,6 +6034,8 @@ inp_fix_temper_in_param(struct line *deck) } +/* append "()" to each 'identifier' in 'curr_line', + * unless already there */ static char * inp_functionalise_identifier(char *curr_line, char *identifier) { diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index 89ea8bbdf..75129c648 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -242,9 +242,9 @@ inp_subcktexpand(struct line *deck) { if (ciprefix(".model", c->li_line)) nupa_scan(c->li_line, c->li_linenum, FALSE); } + /* now copy instances */ for (c = deck; c; c = c->li_next) /* first Numparam pass */ c->li_line = nupa_copy(c->li_line, c->li_linenum); - /* now copy instances */ #ifdef TRACE fprintf(stderr, "Numparams transformed deck:\n"); diff --git a/src/misc/string.c b/src/misc/string.c index f22ca710d..3ea96097b 100644 --- a/src/misc/string.c +++ b/src/misc/string.c @@ -40,6 +40,10 @@ copy(const char *str) return(p); } + +/* copy a substring, from 'str' to 'end' + * including *str, excluding *end + */ char * copy_substring(const char *str, const char *end) {