Browse Source

struct card, #3/6, rename members from struct line to struct card

pre-master-46
rlar 9 years ago
parent
commit
511cdd7188
  1. 8
      src/frontend/device.c
  2. 360
      src/frontend/inp.c
  3. 798
      src/frontend/inpcom.c
  4. 40
      src/frontend/measure.c
  5. 74
      src/frontend/nutinp.c
  6. 36
      src/frontend/options.c
  7. 4
      src/frontend/runcoms2.c
  8. 26
      src/frontend/spiceif.c
  9. 2
      src/frontend/spiceif.h
  10. 286
      src/frontend/subckt.c
  11. 4
      src/frontend/subckt.h
  12. 2
      src/include/ngspice/enh.h
  13. 10
      src/include/ngspice/ftedefs.h
  14. 20
      src/include/ngspice/fteext.h
  15. 6
      src/main.c
  16. 38
      src/xspice/enh/enhtrans.c

8
src/frontend/device.c

@ -1354,7 +1354,7 @@ com_alter_mod(wordlist *wl)
char *filename = NULL, *eqword, *input, *modelline = NULL, *inptoken;
int modno = 0, molineno = 0, i, j;
wordlist *newcommand;
struct line *modeldeck, *tmpdeck;
struct card *modeldeck, *tmpdeck;
char *readmode = "r";
char **arglist;
bool modelfound = FALSE;
@ -1406,13 +1406,13 @@ com_alter_mod(wordlist *wl)
tfree(input);
tfree(filename);
/* get all lines starting with *model */
for (tmpdeck = modeldeck; tmpdeck; tmpdeck = tmpdeck->li_next)
if (ciprefix("*model", tmpdeck->li_line)) {
for (tmpdeck = modeldeck; tmpdeck; tmpdeck = tmpdeck->nextcard)
if (ciprefix("*model", tmpdeck->line)) {
if (molineno == MODLIM) {
fprintf(cp_err, "Error: more than %d models in deck, rest ignored\n", molineno);
break;
}
modellines[molineno] = tmpdeck->li_line;
modellines[molineno] = tmpdeck->line;
molineno++;
}
/* Check if all models named in altermod command are to be found in input deck.

360
src/frontend/inp.c

@ -51,13 +51,13 @@ Author: 1985 Wayne A. Christopher
static char *upper(register char *string);
static bool doedit(char *filename);
static struct line *com_options = NULL;
static void cktislinear(CKTcircuit *ckt, struct line *deck);
static void dotifeval(struct line *deck);
static struct card *com_options = NULL;
static void cktislinear(CKTcircuit *ckt, struct card *deck);
static void dotifeval(struct card *deck);
static wordlist *inp_savecurrents(struct line *deck, struct line *options, wordlist *wl, wordlist *controls);
static wordlist *inp_savecurrents(struct card *deck, struct card *options, wordlist *wl, wordlist *controls);
void line_free_x(struct line *deck, bool recurse);
void line_free_x(struct card *deck, bool recurse);
void create_circbyline(char *line);
extern bool ft_batchmode;
@ -74,7 +74,7 @@ struct pt_temper {
struct pt_temper *next;
};
static int inp_parse_temper(struct line *deck,
static int inp_parse_temper(struct card *deck,
struct pt_temper **motdlist_p,
struct pt_temper **devtlist_p);
static void inp_parse_temper_trees(struct circ *ckt);
@ -179,10 +179,10 @@ upper(char *string)
* deck. The listing should be of either LS_PHYSICAL or LS_LOGICAL or
* LS_DECK lines as specified by the type parameter. */
void
inp_list(FILE *file, struct line *deck, struct line *extras, int type)
inp_list(FILE *file, struct card *deck, struct card *extras, int type)
{
struct line *here;
struct line *there;
struct card *here;
struct card *there;
bool renumber;
bool useout = (file == cp_out);
int i = 1;
@ -203,15 +203,15 @@ inp_list(FILE *file, struct line *deck, struct line *extras, int type)
if (type == LS_LOGICAL) {
top1:
for (here = deck; here; here = here->li_next) {
for (here = deck; here; here = here->nextcard) {
if (renumber)
here->li_linenum = i;
if (ciprefix(".end", here->li_line) && !isalpha_c(here->li_line[4]))
here->linenum = i;
if (ciprefix(".end", here->line) && !isalpha_c(here->line[4]))
continue;
if (*here->li_line != '*') {
Xprintf(file, "%6d : %s\n", here->li_linenum, upper(here->li_line));
if (here->li_error)
Xprintf(file, "%s\n", here->li_error);
if (*here->line != '*') {
Xprintf(file, "%6d : %s\n", here->linenum, upper(here->line));
if (here->error)
Xprintf(file, "%s\n", here->error);
}
i++;
}
@ -227,33 +227,33 @@ inp_list(FILE *file, struct line *deck, struct line *extras, int type)
} else if ((type == LS_PHYSICAL) || (type == LS_DECK)) {
top2:
for (here = deck; here; here = here->li_next) {
if ((here->li_actual == NULL) || (here == deck)) {
for (here = deck; here; here = here->nextcard) {
if ((here->actualLine == NULL) || (here == deck)) {
if (renumber)
here->li_linenum = i;
if (ciprefix(".end", here->li_line) && !isalpha_c(here->li_line[4]))
here->linenum = i;
if (ciprefix(".end", here->line) && !isalpha_c(here->line[4]))
continue;
if (type == LS_PHYSICAL)
Xprintf(file, "%6d : %s\n",
here->li_linenum, upper(here->li_line));
here->linenum, upper(here->line));
else
Xprintf(file, "%s\n", upper(here->li_line));
if (here->li_error && (type == LS_PHYSICAL))
Xprintf(file, "%s\n", here->li_error);
Xprintf(file, "%s\n", upper(here->line));
if (here->error && (type == LS_PHYSICAL))
Xprintf(file, "%s\n", here->error);
} else {
for (there = here->li_actual; there; there = there->li_next) {
there->li_linenum = i++;
if (ciprefix(".end", here->li_line) && isalpha_c(here->li_line[4]))
for (there = here->actualLine; there; there = there->nextcard) {
there->linenum = i++;
if (ciprefix(".end", here->line) && isalpha_c(here->line[4]))
continue;
if (type == LS_PHYSICAL)
Xprintf(file, "%6d : %s\n",
there->li_linenum, upper(there->li_line));
there->linenum, upper(there->line));
else
Xprintf(file, "%s\n", upper(there->li_line));
if (there->li_error && (type == LS_PHYSICAL))
Xprintf(file, "%s\n", there->li_error);
Xprintf(file, "%s\n", upper(there->line));
if (there->error && (type == LS_PHYSICAL))
Xprintf(file, "%s\n", there->error);
}
here->li_linenum = i;
here->linenum = i;
}
i++;
}
@ -274,19 +274,19 @@ inp_list(FILE *file, struct line *deck, struct line *extras, int type)
/*
* Free memory used by a line.
* If recurse is TRUE then recursively free all lines linked via the ->li_next field.
* If recurse is TRUE then recursively free all lines linked via the ->nextcard field.
* If recurse is FALSE free only this line.
* All lines linked via the ->li_actual field are always recursivly freed.
* All lines linked via the ->actualLine field are always recursivly freed.
* SJB - 22nd May 2001
*/
void
line_free_x(struct line *deck, bool recurse)
line_free_x(struct card *deck, bool recurse)
{
while (deck) {
struct line *next_deck = deck->li_next;
line_free_x(deck->li_actual, TRUE);
tfree(deck->li_line);
tfree(deck->li_error);
struct card *next_deck = deck->nextcard;
line_free_x(deck->actualLine, TRUE);
tfree(deck->line);
tfree(deck->error);
tfree(deck);
if (!recurse)
return;
@ -296,31 +296,31 @@ line_free_x(struct line *deck, bool recurse)
/* concatenate two lists, destructively altering the first one */
struct line *
line_nconc(struct line *head, struct line *rest)
struct card *
line_nconc(struct card *head, struct card *rest)
{
struct line *p = head;
struct card *p = head;
if (!rest)
return head;
if (!head)
return rest;
while (p->li_next)
p = p->li_next;
p->li_next = rest;
while (p->nextcard)
p = p->nextcard;
p->nextcard = rest;
return head;
}
/* reverse the linked list struct line */
struct line *
line_reverse(struct line *head)
/* reverse the linked list struct card */
struct card *
line_reverse(struct card *head)
{
struct line *prev = NULL;
struct line *next;
struct card *prev = NULL;
struct card *next;
while (head) {
next = head->li_next;
head->li_next = prev;
next = head->nextcard;
head->nextcard = prev;
prev = head;
head = next;
}
@ -343,8 +343,8 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
* intfile = whether input is from internal array. Values are TRUE/FALSE
*/
{
struct line *deck, *dd, *ld, *prev_param = NULL, *prev_card = NULL;
struct line *realdeck = NULL, *options = NULL, *curr_meas = NULL;
struct card *deck, *dd, *ld, *prev_param = NULL, *prev_card = NULL;
struct card *realdeck = NULL, *options = NULL, *curr_meas = NULL;
char *tt = NULL, name[BSIZE_SP], *s, *t, *temperature = NULL;
double testemp = 0.0;
bool commands = FALSE;
@ -377,7 +377,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
}
/* files starting with *ng_script are user supplied command files */
if (ciprefix("*ng_script", deck->li_line))
if (ciprefix("*ng_script", deck->line))
comfile = TRUE;
if (!comfile) {
@ -389,8 +389,8 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
realdeck = inp_deckcopy(deck);
/* Save the title before INPgetTitle gets it. */
tt = copy(deck->li_line);
if (!deck->li_next)
tt = copy(deck->line);
if (!deck->nextcard)
fprintf(cp_err, "Warning: no lines in input\n");
}
if (!intfile)
@ -419,17 +419,17 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
/* Process each command, except 'option' which is assembled
in a list and ingnored here */
for (dd = deck; dd; dd = ld) {
ld = dd->li_next;
if ((dd->li_line[0] == '*') && (dd->li_line[1] != '#'))
ld = dd->nextcard;
if ((dd->line[0] == '*') && (dd->line[1] != '#'))
continue;
if (!ciprefix(".control", dd->li_line) && !ciprefix(".endc", dd->li_line)) {
if (dd->li_line[0] == '*')
cp_evloop(dd->li_line + 2);
if (!ciprefix(".control", dd->line) && !ciprefix(".endc", dd->line)) {
if (dd->line[0] == '*')
cp_evloop(dd->line + 2);
/* option line stored but not processed */
else if (ciprefix("option", dd->li_line))
com_options = inp_getoptsc(dd->li_line, com_options);
else if (ciprefix("option", dd->line))
com_options = inp_getoptsc(dd->line, com_options);
else
cp_evloop(dd->li_line);
cp_evloop(dd->line);
}
}
/* free the control deck */
@ -442,22 +442,22 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
else { /* must be regular deck . . . . */
/* loop through deck and handle control cards */
for (dd = deck->li_next; dd; dd = ld->li_next) {
for (dd = deck->nextcard; dd; dd = ld->nextcard) {
/* get temp from deck */
if (ciprefix(".temp", dd->li_line)) {
s = skip_ws(dd->li_line + 5);
if (ciprefix(".temp", dd->line)) {
s = skip_ws(dd->line + 5);
if (temperature)
txfree(temperature);
temperature = strdup(s);
}
/* Ignore comment lines, but not lines begining with '*#',
but remove them, if they are in a .control ... .endc section */
s = skip_ws(dd->li_line);
if ((*s == '*') && ((s != dd->li_line) || (s[1] != '#'))) {
s = skip_ws(dd->line);
if ((*s == '*') && ((s != dd->line) || (s[1] != '#'))) {
if (commands) {
/* Remove comment lines in control sections, so they don't
* get considered as circuits. */
ld->li_next = dd->li_next;
ld->nextcard = dd->nextcard;
line_free(dd, FALSE);
continue;
}
@ -466,55 +466,55 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
}
/* Put the first token from line into s */
strncpy(name, dd->li_line, BSIZE_SP);
strncpy(name, dd->line, BSIZE_SP);
s = skip_ws(name);
t = skip_non_ws(s);
*t = '\0';
if (ciprefix(".control", dd->li_line)) {
ld->li_next = dd->li_next;
if (ciprefix(".control", dd->line)) {
ld->nextcard = dd->nextcard;
line_free(dd, FALSE); /* SJB - free this line's memory */
if (commands)
fprintf(cp_err, "Warning: redundant .control card\n");
else
commands = TRUE;
} else if (ciprefix(".endc", dd->li_line)) {
ld->li_next = dd->li_next;
} else if (ciprefix(".endc", dd->line)) {
ld->nextcard = dd->nextcard;
line_free(dd, FALSE); /* SJB - free this line's memory */
if (commands)
commands = FALSE;
else
fprintf(cp_err, "Warning: misplaced .endc card\n");
} else if (commands || prefix("*#", dd->li_line)) {
} else if (commands || prefix("*#", dd->line)) {
/* assemble all commands starting with pre_ after stripping pre_,
to be executed before circuit parsing */
if (ciprefix("pre_", dd->li_line)) {
s = copy(dd->li_line + 4);
if (ciprefix("pre_", dd->line)) {
s = copy(dd->line + 4);
pre_controls = wl_cons(s, pre_controls);
}
/* assemble all other commands to be executed after circuit parsing */
else {
/* special control lines outside of .control section*/
if (prefix("*#", dd->li_line)) {
s = copy(dd->li_line + 2);
if (prefix("*#", dd->line)) {
s = copy(dd->line + 2);
/* all commands from within .control section */
} else {
s = dd->li_line;
dd->li_line = NULL; /* SJB - prevent line_free() freeing the string (now pointed at by wl->wl_word) */
s = dd->line;
dd->line = NULL; /* SJB - prevent line_free() freeing the string (now pointed at by wl->wl_word) */
}
controls = wl_cons(s, controls);
}
ld->li_next = dd->li_next;
ld->nextcard = dd->nextcard;
line_free(dd, FALSE);
} else if (!*dd->li_line) {
} else if (!*dd->line) {
/* So blank lines in com files don't get considered as circuits. */
ld->li_next = dd->li_next;
ld->nextcard = dd->nextcard;
line_free(dd, FALSE);
} else {
/* lines .width, .four, .plot, .print, .save added to wl_first, removed from deck */
/* lines .op, .meas, .tf added to wl_first */
inp_casefix(s); /* s: first token from line */
inp_casefix(dd->li_line);
inp_casefix(dd->line);
if (eq(s, ".width") ||
ciprefix(".four", s) ||
eq(s, ".plot") ||
@ -524,10 +524,10 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
ciprefix(".meas", s) ||
eq(s, ".tf"))
{
wl_append_word(&wl_first, &end, copy(dd->li_line));
wl_append_word(&wl_first, &end, copy(dd->line));
if (!eq(s, ".op") && !eq(s, ".tf") && !ciprefix(".meas", s)) {
ld->li_next = dd->li_next;
ld->nextcard = dd->nextcard;
line_free(dd, FALSE);
} else {
ld = dd;
@ -536,7 +536,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
ld = dd;
}
}
} /* end for (dd = deck->li_next . . . . */
} /* end for (dd = deck->nextcard . . . . */
/* Now that the deck is loaded, do the pre commands, if there are any,
before the circuit structure is set up */
@ -560,16 +560,16 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
/* We are done handling the control stuff. Now process remainder of deck.
Go on if there is something left after the controls.*/
if (deck->li_next) {
if (deck->nextcard) {
fprintf(cp_out, "\nCircuit: %s\n\n", tt);
#ifdef HAS_PROGREP
SetAnalyse("Prepare Deck", 0);
#endif
/* Now expand subcircuit macros and substitute numparams.*/
if (!cp_getvar("nosubckt", CP_BOOL, NULL))
if ((deck->li_next = inp_subcktexpand(deck->li_next)) == NULL) {
if ((deck->nextcard = inp_subcktexpand(deck->nextcard)) == NULL) {
line_free(realdeck, TRUE);
line_free(deck->li_actual, TRUE);
line_free(deck->actualLine, TRUE);
tfree(tt);
return;
}
@ -577,41 +577,41 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
/* Now handle translation of spice2c6 POLYs. */
#ifdef XSPICE
/* Translate all SPICE 2G6 polynomial type sources */
deck->li_next = ENHtranslate_poly(deck->li_next);
deck->nextcard = ENHtranslate_poly(deck->nextcard);
#endif
line_free(deck->li_actual, FALSE);
deck->li_actual = realdeck;
line_free(deck->actualLine, FALSE);
deck->actualLine = realdeck;
/* print out the expanded deck into debug-out2.txt */
if (ft_ngdebug) {
/*debug: print into file*/
FILE *fdo = fopen("debug-out2.txt", "w");
struct line *t = NULL;
struct card *t = NULL;
fprintf(fdo, "**************** uncommented deck **************\n\n");
/* always print first line */
fprintf(fdo, "%6d %6d %s\n", deck->li_linenum_orig, deck->li_linenum, deck->li_line);
fprintf(fdo, "%6d %6d %s\n", deck->linenum_orig, deck->linenum, deck->line);
/* here without out-commented lines */
for (t = deck->li_next; t; t = t->li_next) {
if (*(t->li_line) == '*')
for (t = deck->nextcard; t; t = t->nextcard) {
if (*(t->line) == '*')
continue;
fprintf(fdo, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
fprintf(fdo, "%6d %6d %s\n", t->linenum_orig, t->linenum, t->line);
}
fprintf(fdo, "\n****************** complete deck ***************\n\n");
/* now completely */
for (t = deck; t; t = t->li_next)
fprintf(fdo, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
for (t = deck; t; t = t->nextcard)
fprintf(fdo, "%6d %6d %s\n", t->linenum_orig, t->linenum, t->line);
fclose(fdo);
}
for (dd = deck; dd; dd = dd->li_next) {
for (dd = deck; dd; dd = dd->nextcard) {
/* get csparams and create vectors, being
available in .control section, in plot 'const' */
if (ciprefix(".csparam", dd->li_line)) {
if (ciprefix(".csparam", dd->line)) {
wordlist *wlist = NULL;
char *cstoken[3];
int i;
dd->li_line[0] = '*';
s = skip_ws(dd->li_line + 8);
dd->line[0] = '*';
s = skip_ws(dd->line + 8);
cstoken[0] = gettok_char(&s, '=', FALSE, FALSE);
cstoken[1] = gettok_char(&s, '=', TRUE, FALSE);
cstoken[2] = gettok(&s);
@ -654,7 +654,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
tt = NULL;
options = NULL;
} /* if (deck->li_next) */
} /* if (deck->nextcard) */
/* look for and set temperature; also store param and .meas statements in circuit struct */
if (ft_curckt) {
@ -664,33 +664,33 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
ft_curckt->FTEstats->FTESTATnetLoadTime = endTime - startTime;
}
for (dd = deck; dd; dd = dd->li_next) {
for (dd = deck; dd; dd = dd->nextcard) {
/* all parameter lines should be sequentially ordered and placed at
beginning of deck */
if (ciprefix(".para", dd->li_line)) {
if (ciprefix(".para", dd->line)) {
ft_curckt->ci_param = dd;
/* find end of .param statements */
while (ciprefix(".para", dd->li_line)) {
while (ciprefix(".para", dd->line)) {
prev_param = dd;
dd = dd->li_next;
dd = dd->nextcard;
if (dd == NULL)
break; // no line after .param line
}
prev_card->li_next = dd;
prev_param->li_next = NULL;
prev_card->nextcard = dd;
prev_param->nextcard = NULL;
if (dd == NULL) {
fprintf(cp_err, "Warning: Missing .end card!\n");
break; // no line after .param line
}
}
if (ciprefix(".meas", dd->li_line)) {
if (ciprefix(".meas", dd->line)) {
if (cp_getvar("autostop", CP_BOOL, NULL)) {
if (strstr(dd->li_line, " max ") ||
strstr(dd->li_line, " min ") ||
strstr(dd->li_line, " avg ") ||
strstr(dd->li_line, " rms ") ||
strstr(dd->li_line, " integ "))
if (strstr(dd->line, " max ") ||
strstr(dd->line, " min ") ||
strstr(dd->line, " avg ") ||
strstr(dd->line, " rms ") ||
strstr(dd->line, " integ "))
{
printf("Warning: .OPTION AUTOSTOP will not be effective because one of 'max|min|avg|rms|integ' is used in .meas\n");
printf(" AUTOSTOP being disabled...\n");
@ -701,11 +701,11 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
if (curr_meas == NULL) {
curr_meas = ft_curckt->ci_meas = dd;
} else {
curr_meas->li_next = dd;
curr_meas->nextcard = dd;
curr_meas = dd;
}
prev_card->li_next = dd->li_next;
curr_meas->li_next = NULL;
prev_card->nextcard = dd->nextcard;
curr_meas->nextcard = NULL;
dd = prev_card;
}
prev_card = dd;
@ -729,20 +729,20 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
if (ft_ngdebug) {
/*debug: print into file*/
FILE *fdo = fopen("debug-out3.txt", "w");
struct line *t = NULL;
struct card *t = NULL;
fprintf(fdo, "**************** uncommented deck **************\n\n");
/* always print first line */
fprintf(fdo, "%6d %6d %s\n", deck->li_linenum_orig, deck->li_linenum, deck->li_line);
fprintf(fdo, "%6d %6d %s\n", deck->linenum_orig, deck->linenum, deck->line);
/* here without out-commented lines */
for (t = deck->li_next; t; t = t->li_next) {
if (*(t->li_line) == '*')
for (t = deck->nextcard; t; t = t->nextcard) {
if (*(t->line) == '*')
continue;
fprintf(fdo, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
fprintf(fdo, "%6d %6d %s\n", t->linenum_orig, t->linenum, t->line);
}
fprintf(fdo, "\n****************** complete deck ***************\n\n");
/* now completely */
for (t = deck; t; t = t->li_next)
fprintf(fdo, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
for (t = deck; t; t = t->nextcard)
fprintf(fdo, "%6d %6d %s\n", t->linenum_orig, t->linenum, t->line);
fclose(fdo);
}
@ -789,17 +789,17 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
*-----------------------------------------------------------------*/
void
inp_dodeck(
struct line *deck, /*in: the spice deck */
struct card *deck, /*in: the spice deck */
char *tt, /*in: the title of the deck */
wordlist *end, /*in: all lines with .width, .plot, .print, .save, .op, .meas, .tf */
bool reuse, /*in: TRUE if called from runcoms2.c com_rset,
FALSE if called from inp_spsource() */
struct line *options, /*in: all .option lines from deck */
struct card *options, /*in: all .option lines from deck */
char *filename /*in: input file of deck */
)
{
struct circ *ct;
struct line *dd;
struct card *dd;
CKTcircuit *ckt;
char *s;
INPtables *tab = NULL;
@ -814,10 +814,10 @@ inp_dodeck(
/* First throw away any old error messages there might be and fix
the case of the lines. */
for (dd = deck; dd; dd = dd->li_next)
if (dd->li_error) {
tfree(dd->li_error);
dd->li_error = NULL;
for (dd = deck; dd; dd = dd->nextcard)
if (dd->error) {
tfree(dd->error);
dd->error = NULL;
}
if (reuse) {
@ -841,9 +841,9 @@ inp_dodeck(
is needed because we need the scale info BEFORE building the circuit
and seems there is no other way to do this. */
if (!noparse) {
struct line *opt_beg = options;
for (; options; options = options->li_next) {
s = skip_non_ws(options->li_line);
struct card *opt_beg = options;
for (; options; options = options->nextcard) {
s = skip_non_ws(options->line);
ii = cp_interactive;
cp_interactive = FALSE;
@ -916,42 +916,42 @@ inp_dodeck(
ft_curckt->FTEstats->FTESTATdeckNumLines = 0;
/*----------------------------------------------------
Now run through the deck and look to see if there are
errors on any line (message contained in ->li_error).
errors on any line (message contained in ->error).
Error messages have been generated either by writing
directly to ->li_error from a struct line or to
directly to ->error from a struct card or to
->error from a struct card , or by using one of the
macros as defined in inpmacs.h. Functions INPerror(),
INPerrCat(), and SPerror() are invoked.
*---------------------------------------------------*/
for (dd = deck; dd; dd = dd->li_next) {
for (dd = deck; dd; dd = dd->nextcard) {
ft_curckt->FTEstats->FTESTATdeckNumLines += 1;
#ifdef TRACE
/* SDB debug statement */
printf("In inp_dodeck, looking for errors and examining line %s . . . \n", dd->li_line);
printf("In inp_dodeck, looking for errors and examining line %s . . . \n", dd->line);
#endif
if (dd->li_error) {
if (dd->error) {
char *p, *q;
#ifdef XSPICE
/* add setting of ipc syntax error flag */
g_ipc.syntax_error = IPC_TRUE;
#endif
p = dd->li_error;
p = dd->error;
do {
q = strchr(p, '\n');
if (q)
*q = '\0';
if (p == dd->li_error) {
if (strstr(dd->li_line, ".model"))
if (p == dd->error) {
if (strstr(dd->line, ".model"))
out_printf("Warning: Model issue on line %d :\n %.*s ...\n%s\n",
dd->li_linenum_orig, 72, dd->li_line, dd->li_error);
dd->linenum_orig, 72, dd->line, dd->error);
else {
out_printf("Error on line %d :\n %s\n%s\n",
dd->li_linenum_orig, dd->li_line, dd->li_error);
dd->linenum_orig, dd->line, dd->error);
have_err = TRUE;
}
if (ft_stricterror)
@ -964,9 +964,9 @@ inp_dodeck(
*q++ = '\n';
p = q;
} while (p && *p);
} /* end if (dd->li_error) */
} /* end if (dd->error) */
} /* for (dd = deck; dd; dd = dd->li_next) */
} /* for (dd = deck; dd; dd = dd->nextcard) */
/* Stop here and exit if error occurred in batch mode */
if (have_err && ft_batchmode) {
@ -980,12 +980,12 @@ inp_dodeck(
out_printf("\nProcessed Netlist\n");
out_printf("=================\n");
print_listing = 1;
for (dd = deck; dd; dd = dd->li_next) {
if (ciprefix(".prot", dd->li_line))
for (dd = deck; dd; dd = dd->nextcard) {
if (ciprefix(".prot", dd->line))
print_listing = 0;
if (print_listing == 1)
out_printf("%s\n", dd->li_line);
if (ciprefix(".unprot", dd->li_line))
out_printf("%s\n", dd->line);
if (ciprefix(".unprot", dd->line))
print_listing = 1;
}
out_printf("\n");
@ -1006,8 +1006,8 @@ inp_dodeck(
ct->ci_name = tt;
ct->ci_deck = deck;
ct->ci_options = options;
if (deck->li_actual)
ct->ci_origdeck = deck->li_actual;
if (deck->actualLine)
ct->ci_origdeck = deck->actualLine;
else
ct->ci_origdeck = ct->ci_deck;
ct->ci_ckt = ckt; /* attach the input ckt to the list of circuits */
@ -1021,8 +1021,8 @@ inp_dodeck(
if (!noparse) {
/*
* for (; options; options = options->li_next) {
* s = skip_non_ws(options->li_line);
* for (; options; options = options->nextcard) {
* s = skip_non_ws(options->line);
* ii = cp_interactive;
* cp_interactive = FALSE;
* wl = cp_lexer(s);
@ -1264,14 +1264,14 @@ inp_source(char *file)
ckt->CKTisLinear is set to 1. Return immediately if a first
non-linear element is found. */
static void
cktislinear(CKTcircuit *ckt, struct line *deck)
cktislinear(CKTcircuit *ckt, struct card *deck)
{
struct line *dd;
struct card *dd;
char firstchar;
if (deck->li_next)
for (dd = deck->li_next; dd; dd = dd->li_next) {
firstchar = *dd->li_line;
if (deck->nextcard)
for (dd = deck->nextcard; dd; dd = dd->nextcard) {
firstchar = *dd->line;
switch (firstchar) {
case 'r':
case 'l':
@ -1342,17 +1342,17 @@ com_circbyline(wordlist *wl)
numparam has evaluated .if('boolean expression') to
.if ( 1.000000000e+000 ) or .elseif ( 0.000000000e+000 ) */
static void
dotifeval(struct line *deck)
dotifeval(struct card *deck)
{
int iftrue = 0, elseiftrue = 0, elsetrue = 0, iffound = 0, elseiffound = 0, elsefound = 0;
struct line *dd;
struct card *dd;
char *dottoken;
char *s, *t;
/* skip the first line (title line) */
for (dd = deck->li_next; dd; dd = dd->li_next) {
for (dd = deck->nextcard; dd; dd = dd->nextcard) {
s = t = dd->li_line;
s = t = dd->line;
if (*s == '*')
continue;
@ -1364,7 +1364,7 @@ dotifeval(struct line *deck)
elseiffound = 0;
iffound = 1;
*s = '*';
s = dd->li_line + 3;
s = dd->line + 3;
iftrue = atoi(s);
}
else if (cieq(dottoken, ".elseif")) {
@ -1373,7 +1373,7 @@ dotifeval(struct line *deck)
iffound = 0;
*s = '*';
if (!iftrue) {
s = dd->li_line + 7;
s = dd->line + 7;
elseiftrue = atoi(s);
}
}
@ -1435,7 +1435,7 @@ dotifeval(struct line *deck)
*/
static int
inp_parse_temper(struct line *card, struct pt_temper **modtlist_p, struct pt_temper **devtlist_p)
inp_parse_temper(struct card *card, struct pt_temper **modtlist_p, struct pt_temper **devtlist_p)
{
int error = 0;
@ -1443,10 +1443,10 @@ inp_parse_temper(struct line *card, struct pt_temper **modtlist_p, struct pt_tem
struct pt_temper *devtlist = NULL;
/* skip title line */
card = card->li_next;
for (; card; card = card->li_next) {
card = card->nextcard;
for (; card; card = card->nextcard) {
char *curr_line = card->li_line;
char *curr_line = card->line;
/* exclude some elements */
if (strchr("*vbiegfh", curr_line[0]))
@ -1600,13 +1600,13 @@ inp_evaluate_temper(struct circ *circ)
*/
static wordlist *
inp_savecurrents(struct line *deck, struct line *options, wordlist *wl, wordlist *controls)
inp_savecurrents(struct card *deck, struct card *options, wordlist *wl, wordlist *controls)
{
wordlist *p;
/* check if option 'savecurrents' is set */
for (; options; options = options->li_next)
if (strstr(options->li_line, "savecurrents"))
for (; options; options = options->nextcard)
if (strstr(options->line, "savecurrents"))
break;
if (!options)
@ -1633,8 +1633,8 @@ inp_savecurrents(struct line *deck, struct line *options, wordlist *wl, wordlist
* We currently serve bipolars, resistors, MOS1, capacitors, inductors,
* controlled current sources. Others may follow.
*/
for (deck = deck->li_next; deck; deck = deck->li_next) {
char *newline, *devname, *devline = deck->li_line;
for (deck = deck->nextcard; deck; deck = deck->nextcard) {
char *newline, *devname, *devline = deck->line;
switch (devline[0]) {
case 'm':

798
src/frontend/inpcom.c
File diff suppressed because it is too large
View File

40
src/frontend/measure.c

@ -209,7 +209,7 @@ do_measure(
bool chk_only /*in: TRUE if checking for "autostop", FALSE otherwise*/
)
{
struct line *meas_card, *meas_results = NULL, *end = NULL, *newcard;
struct card *meas_card, *meas_results = NULL, *end = NULL, *newcard;
char *line, *an_name, *an_type, *resname, *meastype, *str_ptr, out_line[1000];
int ok = 0;
int fail;
@ -261,8 +261,8 @@ do_measure(
*/
/* first pass through .meas cards: evaluate everything except param|expr */
for (meas_card = ft_curckt->ci_meas; meas_card != NULL; meas_card = meas_card->li_next) {
line = meas_card->li_line;
for (meas_card = ft_curckt->ci_meas; meas_card != NULL; meas_card = meas_card->nextcard) {
line = meas_card->line;
line = nexttok(line); /* discard .meas */
@ -272,8 +272,8 @@ do_measure(
if (chkAnalysisType(an_type) != TRUE) {
if (!chk_only) {
fprintf(cp_err, "Error: unrecognized analysis type '%s' for the following .meas statement on line %d:\n", an_type, meas_card->li_linenum);
fprintf(cp_err, " %s\n", meas_card->li_line);
fprintf(cp_err, "Error: unrecognized analysis type '%s' for the following .meas statement on line %d:\n", an_type, meas_card->linenum);
fprintf(cp_err, " %s\n", meas_card->line);
}
txfree(an_type);
@ -305,13 +305,13 @@ do_measure(
/* New way of processing measure statements using common code
in fcn get_measure2() (com_measure2.c)*/
out_line[0] = '\0';
measure_word_list = measure_parse_line(meas_card->li_line);
measure_word_list = measure_parse_line(meas_card->line);
if (measure_word_list) {
fail = get_measure2(measure_word_list, &result, out_line, chk_only);
if (fail) {
measures_passed = FALSE;
if (!chk_only)
fprintf(stderr, " %s failed!\n\n", meas_card->li_line);
fprintf(stderr, " %s failed!\n\n", meas_card->line);
num_failed++;
if (chk_only) {
/* added for speed - cleanup last parse and break */
@ -332,14 +332,14 @@ do_measure(
}
if (!chk_only) {
newcard = TMALLOC(struct line, 1);
newcard->li_line = strdup(out_line);
newcard->li_next = NULL;
newcard = TMALLOC(struct card, 1);
newcard->line = strdup(out_line);
newcard->nextcard = NULL;
if (meas_results == NULL) {
meas_results = end = newcard;
} else {
end->li_next = newcard;
end->nextcard = newcard;
end = newcard;
}
}
@ -356,8 +356,8 @@ do_measure(
}
/* second pass through .meas cards: now do param|expr .meas statements */
newcard = meas_results;
for (meas_card = ft_curckt->ci_meas; meas_card != NULL; meas_card = meas_card->li_next) {
line = meas_card->li_line;
for (meas_card = ft_curckt->ci_meas; meas_card != NULL; meas_card = meas_card->nextcard) {
line = meas_card->line;
line = nexttok(line); /* discard .meas */
@ -367,8 +367,8 @@ do_measure(
if (chkAnalysisType(an_type) != TRUE) {
if (!chk_only) {
fprintf(cp_err, "Error: unrecognized analysis type '%s' for the following .meas statement on line %d:\n", an_type, meas_card->li_linenum);
fprintf(cp_err, " %s\n", meas_card->li_line);
fprintf(cp_err, "Error: unrecognized analysis type '%s' for the following .meas statement on line %d:\n", an_type, meas_card->linenum);
fprintf(cp_err, " %s\n", meas_card->line);
}
txfree(an_type);
@ -386,11 +386,11 @@ do_measure(
if (strncmp(meastype, "param", 5) != 0 && strncmp(meastype, "expr", 4) != 0) {
if (!chk_only)
fprintf(stdout, "%s", newcard->li_line);
fprintf(stdout, "%s", newcard->line);
end = newcard;
newcard = newcard->li_next;
newcard = newcard->nextcard;
txfree(end->li_line);
txfree(end->line);
txfree(end);
txfree(an_type);
@ -403,10 +403,10 @@ do_measure(
fprintf(stdout, "%-20s=", resname);
if (!chk_only) {
ok = nupa_eval(meas_card->li_line, meas_card->li_linenum, meas_card->li_linenum_orig);
ok = nupa_eval(meas_card->line, meas_card->linenum, meas_card->linenum_orig);
if (ok) {
str_ptr = strstr(meas_card->li_line, meastype);
str_ptr = strstr(meas_card->line, meastype);
if (!get_double_value(&str_ptr, meastype, &result, chk_only)) {
if (!chk_only)
fprintf(stdout, " failed\n");

74
src/frontend/nutinp.c

@ -27,8 +27,8 @@ Author: 1985 Wayne A. Christopher
void
inp_nutsource(FILE *fp, bool comfile, char *filename)
{
struct line *deck, *dd, *ld;
struct line *realdeck, *options = NULL;
struct card *deck, *dd, *ld;
struct card *realdeck, *options = NULL;
char *tt = NULL, name[BSIZE_SP], *s, *t;
bool commands = FALSE;
wordlist *wl = NULL, *end = NULL;
@ -43,8 +43,8 @@ inp_nutsource(FILE *fp, bool comfile, char *filename)
if (!comfile) {
/* Save the title before INPgetTitle gets it. */
tt = copy(deck->li_line);
if (!deck->li_next)
tt = copy(deck->line);
if (!deck->nextcard)
fprintf(cp_err, "Warning: no lines in deck...\n");
}
(void) fclose(fp);
@ -74,80 +74,80 @@ inp_nutsource(FILE *fp, bool comfile, char *filename)
if (comfile) {
/* This is easy. */
for (dd = deck; dd; dd = ld) {
ld = dd->li_next;
if ((dd->li_line[0] == '*') && (dd->li_line[1] != '#'))
ld = dd->nextcard;
if ((dd->line[0] == '*') && (dd->line[1] != '#'))
continue;
if (!ciprefix(".control", dd->li_line) &&
!ciprefix(".endc", dd->li_line)) {
if (dd->li_line[0] == '*')
(void) cp_evloop(dd->li_line + 2);
if (!ciprefix(".control", dd->line) &&
!ciprefix(".endc", dd->line)) {
if (dd->line[0] == '*')
(void) cp_evloop(dd->line + 2);
else
(void) cp_evloop(dd->li_line);
(void) cp_evloop(dd->line);
}
tfree(dd->li_line);
tfree(dd->line);
tfree(dd);
}
} else {
for (dd = deck->li_next; dd; dd = ld->li_next) {
if ((dd->li_line[0] == '*') && (dd->li_line[1] != '#')) {
for (dd = deck->nextcard; dd; dd = ld->nextcard) {
if ((dd->line[0] == '*') && (dd->line[1] != '#')) {
ld = dd;
continue;
}
(void) strncpy(name, dd->li_line, BSIZE_SP);
(void) strncpy(name, dd->line, BSIZE_SP);
s = skip_ws(name);
t = skip_non_ws(s);
*t = '\0';
if (ciprefix(".control", dd->li_line)) {
ld->li_next = dd->li_next;
tfree(dd->li_line);
if (ciprefix(".control", dd->line)) {
ld->nextcard = dd->nextcard;
tfree(dd->line);
tfree(dd);
if (commands)
fprintf(cp_err, "Warning: redundant .control line\n");
else
commands = TRUE;
} else if (ciprefix(".endc", dd->li_line)) {
ld->li_next = dd->li_next;
tfree(dd->li_line);
} else if (ciprefix(".endc", dd->line)) {
ld->nextcard = dd->nextcard;
tfree(dd->line);
tfree(dd);
if (commands)
commands = FALSE;
else
fprintf(cp_err, "Warning: misplaced .endc line\n");
} else if (commands || prefix("*#", dd->li_line)) {
} else if (commands || prefix("*#", dd->line)) {
controls = wl_cons(NULL, controls);
wl = controls;
if (prefix("*#", dd->li_line))
wl->wl_word = copy(dd->li_line + 2);
if (prefix("*#", dd->line))
wl->wl_word = copy(dd->line + 2);
else
wl->wl_word = dd->li_line;
ld->li_next = dd->li_next;
wl->wl_word = dd->line;
ld->nextcard = dd->nextcard;
tfree(dd);
} else if (!*dd->li_line) {
} else if (!*dd->line) {
/* So blank lines in com files don't get
* considered as circuits.
*/
ld->li_next = dd->li_next;
tfree(dd->li_line);
ld->nextcard = dd->nextcard;
tfree(dd->line);
tfree(dd);
} else {
inp_casefix(s);
inp_casefix(dd->li_line);
inp_casefix(dd->line);
if (eq(s, ".width") || ciprefix(".four", s) ||
eq(s, ".plot") ||
eq(s, ".print") ||
eq(s, ".save"))
{
wl_append_word(&wl, &end, copy(dd->li_line));
ld->li_next = dd->li_next;
tfree(dd->li_line);
wl_append_word(&wl, &end, copy(dd->line));
ld->nextcard = dd->nextcard;
tfree(dd->line);
tfree(dd);
} else {
ld = dd;
}
}
}
if (deck->li_next) {
if (deck->nextcard) {
/* There is something left after the controls. */
fprintf(cp_out, "\nCircuit: %s\n\n", tt);
fprintf(stderr, "\nCircuit: %s\n\n", tt);
@ -157,8 +157,8 @@ inp_nutsource(FILE *fp, bool comfile, char *filename)
* deal with the commands.
*/
if (!cp_getvar("nosubckt", CP_BOOL, NULL))
deck->li_next = inp_subcktexpand(deck->li_next);
deck->li_actual = realdeck;
deck->nextcard = inp_subcktexpand(deck->nextcard);
deck->actualLine = realdeck;
nutinp_dodeck(deck, tt, wl, FALSE, options, filename);
}
@ -259,7 +259,7 @@ nutinp_source(char *file)
*/
void
nutinp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse, struct line *options, char *filename)
nutinp_dodeck(struct card *deck, char *tt, wordlist *end, bool reuse, struct card *options, char *filename)
{
NG_IGNORE(filename);
NG_IGNORE(options);

36
src/frontend/options.c

@ -136,20 +136,20 @@ cp_usrvars(void)
/* Extract the .option lines from the deck */
struct line *
inp_getopts(struct line *deck)
struct card *
inp_getopts(struct card *deck)
{
struct line *last = NULL, *opts = NULL, *dd, *next = NULL;
struct card *last = NULL, *opts = NULL, *dd, *next = NULL;
for (dd = deck->li_next; dd; dd = next) {
next = dd->li_next;
if (ciprefix(".opt", dd->li_line)) {
inp_casefix(dd->li_line);
for (dd = deck->nextcard; dd; dd = next) {
next = dd->nextcard;
if (ciprefix(".opt", dd->line)) {
inp_casefix(dd->line);
if (last)
last->li_next = dd->li_next;
last->nextcard = dd->nextcard;
else
deck->li_next = dd->li_next;
dd->li_next = opts;
deck->nextcard = dd->nextcard;
dd->nextcard = opts;
opts = dd;
} else {
last = dd;
@ -165,20 +165,20 @@ inp_getopts(struct line *deck)
* substitute '.options' for 'option'
* then put it in front of the given 'options' list */
struct line *
inp_getoptsc(char *line, struct line *options)
struct card *
inp_getoptsc(char *line, struct card *options)
{
line = nexttok(line); /* skip option */
struct line *next = TMALLOC(struct line, 1);
struct card *next = TMALLOC(struct card, 1);
next->li_line = tprintf(".options %s", line);
next->li_linenum = 0;
next->li_error = NULL;
next->li_actual = NULL;
next->line = tprintf(".options %s", line);
next->linenum = 0;
next->error = NULL;
next->actualLine = NULL;
/* put new line in front */
next->li_next = options;
next->nextcard = options;
return next;
}

4
src/frontend/runcoms2.c

@ -29,7 +29,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#define RAWBUF_SIZE 32768
extern char rawfileBuf[RAWBUF_SIZE];
extern void line_free_x(struct line * deck, bool recurse);
extern void line_free_x(struct card * deck, bool recurse);
extern INPmodel *modtab;
#define line_free(line, flag) \
@ -198,7 +198,7 @@ void
com_remcirc(wordlist *wl)
{
struct variable *v, *next;
struct line *dd; /*in: the spice deck */
struct card *dd; /*in: the spice deck */
struct circ *p, *prev = NULL;
#ifdef SHARED_MODULE
TRANan *job;

26
src/frontend/spiceif.c

@ -92,16 +92,16 @@ static int finddev_special(CKTcircuit *ckt, char *name, GENinstance **devptr, GE
/* Input a single deck, and return a pointer to the circuit. */
CKTcircuit *
if_inpdeck(struct line *deck, INPtables **tab)
if_inpdeck(struct card *deck, INPtables **tab)
{
CKTcircuit *ckt;
int err, i;
struct line *ll;
struct card *ll;
IFuid taskUid;
IFuid optUid;
int which = -1;
for (i = 0, ll = deck; ll; ll = ll->li_next)
for (i = 0, ll = deck; ll; ll = ll->nextcard)
i++;
*tab = INPtabInit(i);
ft_curckt->ci_symtab = *tab;
@ -160,16 +160,16 @@ if_inpdeck(struct line *deck, INPtables **tab)
/* reset the model table, will be filled in anew in INPpas1() */
modtab = NULL;
INPpas1(ckt, (card *) deck->li_next, *tab);
INPpas1(ckt, (card *) deck->nextcard, *tab);
/* store the new model table in the current circuit */
ft_curckt->ci_modtab = modtab;
INPpas2(ckt, (card *) deck->li_next, *tab, ft_curckt->ci_defTask);
INPpas2(ckt, (card *) deck->nextcard, *tab, ft_curckt->ci_defTask);
/* INPpas2 has been modified to ignore .NODESET and .IC
* cards. These are left till INPpas3 so that we can check for
* nodeset/ic of non-existant nodes. */
INPpas3(ckt, (card *) deck->li_next,
INPpas3(ckt, (card *) deck->nextcard,
*tab, ft_curckt->ci_defTask, ft_sim->nodeParms,
ft_sim->numNodeParms);
@ -197,7 +197,7 @@ int
if_run(CKTcircuit *ckt, char *what, wordlist *args, INPtables *tab)
{
int err;
struct line deck;
struct card deck;
char buf[BSIZE_SP];
int which = -1;
IFuid specUid, optUid;
@ -226,10 +226,10 @@ if_run(CKTcircuit *ckt, char *what, wordlist *args, INPtables *tab)
s = wl_flatten(args); /* va: tfree char's tmalloc'ed in wl_flatten */
(void) sprintf(buf, ".%s", s);
tfree(s);
deck.li_next = deck.li_actual = NULL;
deck.li_error = NULL;
deck.li_linenum = 0;
deck.li_line = buf;
deck.nextcard = deck.actualLine = NULL;
deck.error = NULL;
deck.linenum = 0;
deck.line = buf;
/*CDHW Delete any previous special task CDHW*/
@ -302,8 +302,8 @@ if_run(CKTcircuit *ckt, char *what, wordlist *args, INPtables *tab)
INPpas2(ckt, (card *) &deck, tab, ft_curckt->ci_specTask);
if (deck.li_error) {
fprintf(cp_err, "Warning: %s\n", deck.li_error);
if (deck.error) {
fprintf(cp_err, "Warning: %s\n", deck.error);
return 2;
}
}

2
src/frontend/spiceif.h

@ -6,7 +6,7 @@
#ifndef ngspice_SPICEIF_H
#define ngspice_SPICEIF_H
CKTcircuit * if_inpdeck(struct line *deck, INPtables **tab);
CKTcircuit * if_inpdeck(struct card *deck, INPtables **tab);
int if_run(CKTcircuit *t, char *what, wordlist *args, INPtables *tab);
int if_option(CKTcircuit *ckt, char *name, enum cp_types type, void *value);
void if_dump(CKTcircuit *ckt, FILE *file);

286
src/frontend/subckt.c

@ -74,7 +74,7 @@ Modified: 2000 AlansFixes
#include "numparam/numpaif.h"
extern void line_free_x(struct line * deck, bool recurse);
extern void line_free_x(struct card * deck, bool recurse);
#define line_free(line, flag) \
do { \
@ -85,8 +85,8 @@ extern void line_free_x(struct line * deck, bool recurse);
struct subs;
static struct line *doit(struct line *deck, wordlist *modnames);
static int translate(struct line *deck, char *formal, char *actual, char *scname,
static struct card *doit(struct card *deck, wordlist *modnames);
static int translate(struct card *deck, char *formal, char *actual, char *scname,
const char *subname, struct subs *subs, wordlist const *modnames);
struct bxx_buffer;
static void finishLine(struct bxx_buffer *dst, char *src, char *scname);
@ -94,8 +94,8 @@ static int settrans(char *formal, char *actual, const char *subname);
static char *gettrans(const char *name, const char *name_end);
static int numnodes(const char *line, struct subs *subs, wordlist const *modnames);
static int numdevs(char *s);
static wordlist *modtranslate(struct line *deck, char *subname, wordlist *new_modnames);
static void devmodtranslate(struct line *deck, char *subname, wordlist * const orig_modnames);
static wordlist *modtranslate(struct card *deck, char *subname, wordlist *new_modnames);
static void devmodtranslate(struct card *deck, char *subname, wordlist * const orig_modnames);
static int inp_numnodes(char c);
/*---------------------------------------------------------------------
@ -117,7 +117,7 @@ struct subs {
char *su_name; /* The .subckt name. */
char *su_args; /* The .subckt arguments, space separated. */
int su_numargs;
struct line *su_def; /* Pointer to the .subckt definition. */
struct card *su_def; /* Pointer to the .subckt definition. */
struct subs *su_next;
};
@ -136,7 +136,7 @@ static int num_global_nodes;
static void
collect_global_nodes(struct line *c)
collect_global_nodes(struct card *c)
{
num_global_nodes = 0;
@ -146,16 +146,16 @@ collect_global_nodes(struct line *c)
global_nodes[num_global_nodes++] = copy("null");
#endif
for (; c; c = c->li_next)
if (ciprefix(".global", c->li_line)) {
char *s = c->li_line;
for (; c; c = c->nextcard)
if (ciprefix(".global", c->line)) {
char *s = c->line;
s = nexttok(s);
while (*s) {
char *t = skip_non_ws(s);
global_nodes[num_global_nodes++] = copy_substring(s, t);
s = skip_ws(t);
}
c->li_line[0] = '*'; /* comment it out */
c->line[0] = '*'; /* comment it out */
}
#ifdef TRACE
@ -202,9 +202,9 @@ free_global_nodes(void)
it returns a pointer to the same deck after the new subcircuits
are spliced in.
-------------------------------------------------------------------*/
struct line *
inp_subcktexpand(struct line *deck) {
struct line *c;
struct card *
inp_subcktexpand(struct card *deck) {
struct card *c;
int ok = 0;
wordlist *modnames = NULL;
@ -228,26 +228,26 @@ inp_subcktexpand(struct line *deck) {
#ifdef TRACE
fprintf(stderr, "Numparams is processing this deck:\n");
for (c = deck; c; c = c->li_next)
fprintf(stderr, "%3d:%s\n", c->li_linenum, c->li_line);
for (c = deck; c; c = c->nextcard)
fprintf(stderr, "%3d:%s\n", c->linenum, c->line);
#endif
ok = nupa_signal(NUPADECKCOPY, NULL);
/* get the subckt/model names from the deck */
for (c = deck; c; c = c->li_next) { /* first Numparam pass */
if (ciprefix(".subckt", c->li_line))
nupa_scan(c->li_line, c->li_linenum, TRUE);
if (ciprefix(".model", c->li_line))
nupa_scan(c->li_line, c->li_linenum, FALSE);
for (c = deck; c; c = c->nextcard) { /* first Numparam pass */
if (ciprefix(".subckt", c->line))
nupa_scan(c->line, c->linenum, TRUE);
if (ciprefix(".model", c->line))
nupa_scan(c->line, c->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);
for (c = deck; c; c = c->nextcard) /* first Numparam pass */
c->line = nupa_copy(c->line, c->linenum);
#ifdef TRACE
fprintf(stderr, "Numparams transformed deck:\n");
for (c = deck; c; c = c->li_next)
fprintf(stderr, "%3d:%s\n", c->li_linenum, c->li_line);
for (c = deck; c; c = c->nextcard)
fprintf(stderr, "%3d:%s\n", c->linenum, c->line);
#endif
}
@ -257,17 +257,17 @@ inp_subcktexpand(struct line *deck) {
*/
{
int nest = 0;
for (c = deck; c; c = c->li_next) {
for (c = deck; c; c = c->nextcard) {
if (ciprefix(".subckt", c->li_line))
if (ciprefix(".subckt", c->line))
nest++;
else if (ciprefix(".ends", c->li_line))
else if (ciprefix(".ends", c->line))
nest--;
else if (nest > 0)
continue;
if (ciprefix(model, c->li_line)) {
char *s = nexttok(c->li_line);
if (ciprefix(model, c->line)) {
char *s = nexttok(c->line);
modnames = wl_cons(gettok(&s), modnames);
}
}
@ -286,9 +286,9 @@ inp_subcktexpand(struct line *deck) {
collect_global_nodes(deck);
/* Let's do a few cleanup things... Get rid of ( ) around node lists... */
for (c = deck; c; c = c->li_next) { /* iterate on lines in deck */
for (c = deck; c; c = c->nextcard) { /* iterate on lines in deck */
char *s = c->li_line;
char *s = c->line;
if (*s == '*') /* skip comment */
continue;
@ -350,14 +350,14 @@ inp_subcktexpand(struct line *deck) {
/* Count numbers of line in deck after expansion */
if (deck) {
dynMaxckt = 0; /* number of lines in deck after expansion */
for (c = deck; c; c = c->li_next)
for (c = deck; c; c = c->nextcard)
dynMaxckt++;
}
/* Now check to see if there are still subckt instances undefined... */
for (c = deck; c; c = c->li_next)
if (ciprefix(invoke, c->li_line)) {
fprintf(cp_err, "Error: unknown subckt: %s\n", c->li_line);
for (c = deck; c; c = c->nextcard)
if (ciprefix(invoke, c->line)) {
fprintf(cp_err, "Error: unknown subckt: %s\n", c->line);
if (use_numparams)
ok = ok && nupa_signal(NUPAEVALDONE, NULL);
return NULL;
@ -366,19 +366,19 @@ inp_subcktexpand(struct line *deck) {
if (use_numparams) {
/* the NUMPARAM final line translation pass */
ok = ok && nupa_signal(NUPASUBDONE, NULL);
for (c = deck; c; c = c->li_next)
for (c = deck; c; c = c->nextcard)
/* 'param' .meas statements can have dependencies on measurement values */
/* need to skip evaluating here and evaluate after other .meas statements */
if (ciprefix(".meas", c->li_line) && strstr(c->li_line, "param")) {
if (ciprefix(".meas", c->line) && strstr(c->line, "param")) {
;
} else {
nupa_eval(c->li_line, c->li_linenum, c->li_linenum_orig);
nupa_eval(c->line, c->linenum, c->linenum_orig);
}
#ifdef TRACE
fprintf(stderr, "Numparams converted deck:\n");
for (c = deck; c; c = c->li_next)
fprintf(stderr, "%3d:%s\n", c->li_linenum, c->li_line);
for (c = deck; c; c = c->nextcard)
fprintf(stderr, "%3d:%s\n", c->linenum, c->line);
#endif
/*nupa_list_params(stdout);*/
@ -390,22 +390,22 @@ inp_subcktexpand(struct line *deck) {
}
static struct line *
find_ends(struct line *l)
static struct card *
find_ends(struct card *l)
{
int nest = 1;
while (l->li_next) {
while (l->nextcard) {
if (ciprefix(sbend, l->li_next->li_line)) /* found a .ends */
if (ciprefix(sbend, l->nextcard->line)) /* found a .ends */
nest--;
else if (ciprefix(start, l->li_next->li_line)) /* found a .subckt */
else if (ciprefix(start, l->nextcard->line)) /* found a .subckt */
nest++;
if (!nest)
break;
l = l->li_next;
l = l->nextcard;
}
return l;
@ -423,8 +423,8 @@ find_ends(struct line *l)
/* It takes as argument a pointer to the deck, and returns a */
/* pointer to the deck after the subcircuit has been spliced in. */
/*-------------------------------------------------------------------*/
static struct line *
doit(struct line *deck, wordlist *modnames) {
static struct card *
doit(struct card *deck, wordlist *modnames) {
struct subs *sss = NULL; /* *sss temporarily hold decks to substitute */
int numpasses = MAXNEST;
bool gotone;
@ -437,31 +437,31 @@ doit(struct line *deck, wordlist *modnames) {
#ifdef TRACE
/* SDB debug statement */
{
struct line *c;
struct card *c;
printf("In doit, about to start first pass through deck.\n");
for (c = deck; c; c = c->li_next)
printf(" %s\n", c->li_line);
for (c = deck; c; c = c->nextcard)
printf(" %s\n", c->line);
}
#endif
{
/* First pass: xtract all the .subckts and stick pointers to them into sss. */
struct line *c = deck;
struct line *prev_of_c = NULL;
struct card *c = deck;
struct card *prev_of_c = NULL;
while (c) {
if (ciprefix(sbend, c->li_line)) { /* if line == .ends */
if (ciprefix(sbend, c->line)) { /* if line == .ends */
fprintf(cp_err, "Error: misplaced %s line: %s\n", sbend,
c->li_line);
c->line);
return (NULL);
}
if (ciprefix(start, c->li_line)) { /* if line == .subckt */
if (ciprefix(start, c->line)) { /* if line == .subckt */
struct line *prev_of_ends = find_ends(c);
struct line *ends = prev_of_ends->li_next;
struct card *prev_of_ends = find_ends(c);
struct card *ends = prev_of_ends->nextcard;
if (!ends) {
fprintf(cp_err, "Error: no %s line.\n", sbend);
@ -475,7 +475,7 @@ doit(struct line *deck, wordlist *modnames) {
/* Now put the .subckt definition found into sss */
{
char *s = c->li_line;
char *s = c->line;
sss = TMALLOC(struct subs, 1);
@ -483,7 +483,7 @@ doit(struct line *deck, wordlist *modnames) {
sss->su_name = gettok(&s);
sss->su_args = copy(s);
sss->su_def = c->li_next;
sss->su_def = c->nextcard;
/* count the number of args in the .subckt line */
sss->su_numargs = 0;
@ -503,25 +503,25 @@ doit(struct line *deck, wordlist *modnames) {
/* cut the whole .subckt ... .ends sequence from the deck chain */
line_free_x(c, FALSE); /* drop the .subckt card */
c = ends->li_next;
c = ends->nextcard;
if (prev_of_c)
prev_of_c->li_next = c;
prev_of_c->nextcard = c;
else
deck = c;
if (use_numparams == FALSE) {
line_free_x(ends, FALSE); /* drop the .ends card */
prev_of_ends->li_next = NULL;
prev_of_ends->nextcard = NULL;
} else {
ends->li_line[0] = '*'; /* comment the .ends card */
ends->li_next = NULL;
ends->line[0] = '*'; /* comment the .ends card */
ends->nextcard = NULL;
}
} else {
prev_of_c = c;
c = c->li_next;
c = c->nextcard;
}
}
}
@ -542,27 +542,27 @@ doit(struct line *deck, wordlist *modnames) {
#ifdef TRACE
/* SDB debug statement */
{
struct line *c;
struct card *c;
printf("In doit, about to start second pass through deck.\n");
for (c = deck; c; c = c->li_next)
printf(" %s\n", c->li_line);
for (c = deck; c; c = c->nextcard)
printf(" %s\n", c->line);
}
#endif
error = 0;
/* Second pass: do the replacements. */
do { /* while (!error && numpasses-- && gotone) */
struct line *c = deck;
struct line *prev_of_c = NULL;
struct card *c = deck;
struct card *prev_of_c = NULL;
gotone = FALSE;
for (; c; prev_of_c = c, c = c->li_next) {
if (ciprefix(invoke, c->li_line)) { /* found reference to .subckt (i.e. component with refdes X) */
for (; c; prev_of_c = c, c = c->nextcard) {
if (ciprefix(invoke, c->line)) { /* found reference to .subckt (i.e. component with refdes X) */
char *tofree, *tofree2, *s, *t;
char *scname;
gotone = TRUE;
t = tofree = s = copy(c->li_line); /* s & t hold copy of component line */
t = tofree = s = copy(c->line); /* s & t hold copy of component line */
/* make scname point to first non-whitepace chars after refdes invocation
* e.g. if invocation is Xreference, *scname = reference
@ -601,8 +601,8 @@ doit(struct line *deck, wordlist *modnames) {
*/
if (sss) {
struct line *su_deck = inp_deckcopy(sss->su_def);
struct line *rest_of_c = c->li_next;
struct card *su_deck = inp_deckcopy(sss->su_def);
struct card *rest_of_c = c->nextcard;
/* Now we have to replace this line with the
* macro definition.
@ -625,19 +625,19 @@ doit(struct line *deck, wordlist *modnames) {
if (use_numparams == FALSE) {
line_free_x(c, FALSE); /* drop the invocation */
if (prev_of_c)
prev_of_c->li_next = su_deck;
prev_of_c->nextcard = su_deck;
else
deck = su_deck;
} else {
c->li_line[0] = '*'; /* comment the invocation */
c->li_next = su_deck;
c->line[0] = '*'; /* comment the invocation */
c->nextcard = su_deck;
}
c = su_deck;
while (c->li_next)
c = c->li_next;
while (c->nextcard)
c = c->nextcard;
c->li_next = rest_of_c;
c->nextcard = rest_of_c;
}
tfree(tofree);
@ -655,10 +655,10 @@ doit(struct line *deck, wordlist *modnames) {
#ifdef TRACE
/* Added by H.Tanaka to display converted deck */
{
struct line *c = deck;
struct card *c = deck;
printf("Converted deck\n");
for (; c; c = c->li_next)
printf("%s\n", c->li_line);
for (; c; c = c->nextcard)
printf("%s\n", c->line);
}
{
wordlist *w = modnames;
@ -692,23 +692,23 @@ doit(struct line *deck, wordlist *modnames) {
/*-------------------------------------------------------------------*/
/* Copy a deck, including the actual lines. */
/*-------------------------------------------------------------------*/
struct line *
inp_deckcopy(struct line *deck) {
struct line *d = NULL, *nd = NULL;
struct card *
inp_deckcopy(struct card *deck) {
struct card *d = NULL, *nd = NULL;
while (deck) {
if (nd) {
d->li_next = TMALLOC(struct line, 1);
d = d->li_next;
d->nextcard = TMALLOC(struct card, 1);
d = d->nextcard;
} else {
nd = d = TMALLOC(struct line, 1);
nd = d = TMALLOC(struct card, 1);
}
d->li_linenum = deck->li_linenum;
d->li_line = copy(deck->li_line);
if (deck->li_error)
d->li_error = copy(deck->li_error);
d->li_actual = inp_deckcopy(deck->li_actual);
deck = deck->li_next;
d->linenum = deck->linenum;
d->line = copy(deck->line);
if (deck->error)
d->error = copy(deck->error);
d->actualLine = inp_deckcopy(deck->actualLine);
deck = deck->nextcard;
}
return (nd);
}
@ -866,7 +866,7 @@ bxx_buffer(struct bxx_buffer *t)
* touch it.
*
* Variable name meanings:
* *deck = pointer to subcircuit definition (lcc) (struct line)
* *deck = pointer to subcircuit definition (lcc) (struct card)
* formal = copy of the .subckt definition line (e.g. ".subckt subcircuitname 1 2 3") (string)
* actual = copy of the .subcircuit invocation line (e.g. "Xexample 4 5 6 subcircuitname") (string)
* scname = refdes (- first letter) used at invocation (e.g. "example") (string)
@ -909,9 +909,9 @@ translate_inst_name(struct bxx_buffer *buffer, const char *scname, const char *n
static int
translate(struct line *deck, char *formal, char *actual, char *scname, const char *subname, struct subs *subs, wordlist const *modnames)
translate(struct card *deck, char *formal, char *actual, char *scname, const char *subname, struct subs *subs, wordlist const *modnames)
{
struct line *c;
struct card *c;
struct bxx_buffer buffer;
char *next_name, *name, *t, *nametofree, *paren_ptr;
int nnodes, i, dim;
@ -933,8 +933,8 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
goto quit;
}
for (c = deck; c; c = c->li_next) {
char *s = c->li_line;
for (c = deck; c; c = c->nextcard) {
char *s = c->line;
char dev_type = tolower_c(s[0]);
bxx_rewind(&buffer);
@ -951,7 +951,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
name = paren_ptr + 1;
if ((paren_ptr = strchr(name, ')')) == NULL) {
fprintf(cp_err, "Error: missing closing ')' for .ic|.nodeset statement %s\n", c->li_line);
fprintf(cp_err, "Error: missing closing ')' for .ic|.nodeset statement %s\n", c->line);
goto quit;
}
@ -1067,13 +1067,13 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
bxx_putc(&buffer, ' ');
/* Next iterate over all nodes (netnames) found and translate them. */
nnodes = numnodes(c->li_line, subs, modnames);
nnodes = numnodes(c->line, subs, modnames);
while (--nnodes >= 0) {
name = gettok_node(&s);
if (name == NULL) {
fprintf(cp_err, "Error: too few nodes: %s\n",
c->li_line);
c->line);
goto quit;
}
@ -1096,7 +1096,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
/* move pointer ahead of '(' */
if (get_l_paren(&s) == 1) {
fprintf(cp_err, "Error: no left paren after POLY %s\n",
c->li_line);
c->line);
tfree(next_name);
goto quit;
}
@ -1108,7 +1108,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
/* move pointer ahead of ')' */
if (get_r_paren(&s) == 1) {
fprintf(cp_err, "Error: no right paren after POLY %s\n",
c->li_line);
c->line);
tfree(next_name);
goto quit;
}
@ -1121,11 +1121,11 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
tfree(next_name);
/* Now translate the controlling source/nodes */
nnodes = dim * numdevs(c->li_line);
nnodes = dim * numdevs(c->line);
while (--nnodes >= 0) {
name = gettok_node(&s); /* name points to the returned token */
if (name == NULL) {
fprintf(cp_err, "Error: too few devs: %s\n", c->li_line);
fprintf(cp_err, "Error: too few devs: %s\n", c->line);
goto quit;
}
@ -1154,11 +1154,11 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
tfree(name);
bxx_putc(&buffer, ' ');
nnodes = numnodes(c->li_line, subs, modnames);
nnodes = numnodes(c->line, subs, modnames);
while (--nnodes >= 0) {
name = gettok_node(&s);
if (name == NULL) {
fprintf(cp_err, "Error: too few nodes: %s\n", c->li_line);
fprintf(cp_err, "Error: too few nodes: %s\n", c->line);
goto quit;
}
@ -1171,11 +1171,11 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
* This may be superfluous because we handle dependent
* source devices above . . . .
*/
nnodes = numdevs(c->li_line);
nnodes = numdevs(c->line);
while (--nnodes >= 0) {
name = gettok_node(&s);
if (name == NULL) {
fprintf(cp_err, "Error: too few devs: %s\n", c->li_line);
fprintf(cp_err, "Error: too few devs: %s\n", c->line);
goto quit;
}
@ -1193,11 +1193,11 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
break;
}
tfree(c->li_line);
c->li_line = copy(bxx_buffer(&buffer));
tfree(c->line);
c->line = copy(bxx_buffer(&buffer));
#ifdef TRACE
printf("In translate, translated line = %s \n", c->li_line);
printf("In translate, translated line = %s \n", c->line);
#endif
}
rtn = 1;
@ -1480,15 +1480,15 @@ numdevs(char *s)
* modtranslate returns the list of model names which have been translated
*----------------------------------------------------------------------*/
static wordlist *
modtranslate(struct line *c, char *subname, wordlist *new_modnames)
modtranslate(struct card *c, char *subname, wordlist *new_modnames)
{
wordlist *orig_modnames = NULL;
struct line *lcc = c;
struct card *lcc = c;
for (; c; c = c->li_next)
if (ciprefix(".model", c->li_line)) {
for (; c; c = c->nextcard)
if (ciprefix(".model", c->line)) {
char *model_name, *new_model_name;
char *t = c->li_line;
char *t = c->line;
#ifdef TRACE
printf("modtranslate(), translating:\n"
@ -1508,8 +1508,8 @@ modtranslate(struct line *c, char *subname, wordlist *new_modnames)
/* perform the actual translation of this .model line */
t = tprintf(".model %s %s", new_model_name, t);
tfree(c->li_line);
c->li_line = t;
tfree(c->line);
c->line = t;
#ifdef TRACE
printf(" \"%s\"\n", t);
@ -1553,7 +1553,7 @@ translate_mod_name(struct bxx_buffer *buffer, char *modname, char *subname, stru
static void
devmodtranslate(struct line *s, char *subname, wordlist * const orig_modnames)
devmodtranslate(struct card *s, char *subname, wordlist * const orig_modnames)
{
int found;
@ -1561,14 +1561,14 @@ devmodtranslate(struct line *s, char *subname, wordlist * const orig_modnames)
bxx_init(&buffer);
for (; s; s = s->li_next) {
for (; s; s = s->nextcard) {
char *t, c, *name, *next_name;
wordlist *wlsub;
bxx_rewind(&buffer);
t = s->li_line;
t = s->line;
#ifdef TRACE
/* SDB debug stuff */
@ -1629,8 +1629,8 @@ devmodtranslate(struct line *s, char *subname, wordlist * const orig_modnames)
#endif
bxx_put_cstring(&buffer, t);
tfree(s->li_line);
s->li_line = copy(bxx_buffer(&buffer));
tfree(s->line);
s->line = copy(bxx_buffer(&buffer));
break;
#endif /* XSPICE */
@ -1663,8 +1663,8 @@ devmodtranslate(struct line *s, char *subname, wordlist * const orig_modnames)
}
bxx_put_cstring(&buffer, t);
tfree(s->li_line);
s->li_line = copy(bxx_buffer(&buffer));
tfree(s->line);
s->line = copy(bxx_buffer(&buffer));
break;
case 'd':
@ -1684,8 +1684,8 @@ devmodtranslate(struct line *s, char *subname, wordlist * const orig_modnames)
tfree(name);
bxx_putc(&buffer, ' ');
bxx_put_cstring(&buffer, t);
tfree(s->li_line);
s->li_line = copy(bxx_buffer(&buffer));
tfree(s->line);
s->line = copy(bxx_buffer(&buffer));
break;
case 'u': /* urc transmissionline */
@ -1711,8 +1711,8 @@ devmodtranslate(struct line *s, char *subname, wordlist * const orig_modnames)
tfree(name);
bxx_putc(&buffer, ' ');
bxx_put_cstring(&buffer, t);
tfree(s->li_line);
s->li_line = copy(bxx_buffer(&buffer));
tfree(s->line);
s->line = copy(bxx_buffer(&buffer));
break;
/* 4 terminal devices */
@ -1743,8 +1743,8 @@ devmodtranslate(struct line *s, char *subname, wordlist * const orig_modnames)
translate_mod_name(&buffer, name, subname, orig_modnames);
bxx_putc(&buffer, ' ');
bxx_put_cstring(&buffer, t);
tfree(s->li_line);
s->li_line = copy(bxx_buffer(&buffer));
tfree(s->line);
s->line = copy(bxx_buffer(&buffer));
tfree(name);
break;
@ -1793,8 +1793,8 @@ devmodtranslate(struct line *s, char *subname, wordlist * const orig_modnames)
bxx_putc(&buffer, ' ');
bxx_put_cstring(&buffer, t);
tfree(s->li_line);
s->li_line = copy(bxx_buffer(&buffer));
tfree(s->line);
s->line = copy(bxx_buffer(&buffer));
tfree(name);
break;
@ -1838,8 +1838,8 @@ devmodtranslate(struct line *s, char *subname, wordlist * const orig_modnames)
bxx_putc(&buffer, ' ');
bxx_put_cstring(&buffer, t);
tfree(s->li_line);
s->li_line = copy(bxx_buffer(&buffer));
tfree(s->line);
s->line = copy(bxx_buffer(&buffer));
break;
/* 4-18 terminal devices */
@ -1869,8 +1869,8 @@ devmodtranslate(struct line *s, char *subname, wordlist * const orig_modnames)
bxx_putc(&buffer, ' ');
bxx_put_cstring(&buffer, t);
tfree(s->li_line);
s->li_line = copy(bxx_buffer(&buffer));
tfree(s->line);
s->line = copy(bxx_buffer(&buffer));
break;
default:

4
src/frontend/subckt.h

@ -6,7 +6,7 @@
#ifndef ngspice_SUBCKT_H
#define ngspice_SUBCKT_H
struct line * inp_subcktexpand(struct line *deck);
struct line * inp_deckcopy(struct line *deck);
struct card * inp_subcktexpand(struct card *deck);
struct card * inp_deckcopy(struct card *deck);
#endif

2
src/include/ngspice/enh.h

@ -94,7 +94,7 @@ struct Enh_Ckt_Data {
void ENHreport_conv_prob(Enh_Conv_Source_t type, char *name, char *msg);
struct line *ENHtranslate_poly(struct line *deck);
struct card *ENHtranslate_poly(struct card *deck);
#endif

10
src/include/ngspice/ftedefs.h

@ -35,11 +35,11 @@ struct circ {
INPtables *ci_symtab; /* The INP symbol table. */
INPmodel *ci_modtab; /* The INP model table. */
struct dbcomm *ci_dbs; /* The database storing save, iplot, stop data */
struct line *ci_deck; /* The input deck. */
struct line *ci_origdeck; /* The input deck, before subckt expansion. */
struct line *ci_options; /* The .option cards from the deck... */
struct line *ci_meas; /* .measure commands to run after simulation */
struct line *ci_param; /* .param statements found in deck */
struct card *ci_deck; /* The input deck. */
struct card *ci_origdeck; /* The input deck, before subckt expansion. */
struct card *ci_options; /* The .option cards from the deck... */
struct card *ci_meas; /* .measure commands to run after simulation */
struct card *ci_param; /* .param statements found in deck */
struct variable *ci_vars; /* ... and the parsed versions. */
bool ci_inprogress; /* We are in a break now. */
bool ci_runonce; /* So com_run can to a reset if necessary... */

20
src/include/ngspice/fteext.h

@ -206,20 +206,20 @@ extern bool gr_circular;
/* inp.c */
void inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse,
struct line *options, char *filename);
void inp_dodeck(struct card *deck, char *tt, wordlist *end, bool reuse,
struct card *options, char *filename);
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, char *dir_name, bool comfile, bool intfile, bool *expr_w_temper);
extern void inp_list(FILE *file, struct card *deck, struct card *extras, int type);
extern struct card *inp_readall(FILE *fp, char *dir_name, bool comfile, bool intfile, bool *expr_w_temper);
extern FILE *inp_pathopen(char *name, char *mode);
extern char *search_identifier(char *str, const char *identifier, char *str_begin);
extern char *find_assignment(const char *s);
extern char *find_back_assignment(const char *s, const char *start);
extern struct line *line_nconc(struct line *head, struct line *rest);
extern struct line *line_reverse(struct line *head);
extern struct card *line_nconc(struct card *head, struct card *rest);
extern struct card *line_reverse(struct card *head);
extern char **circarray;
extern void rem_tlist(struct pt_temper *p);
@ -227,8 +227,8 @@ extern void rem_tlist(struct pt_temper *p);
/* nutinp.c */
void inp_nutsource(FILE *fp, bool comfile, char *filename);
void nutinp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse,
struct line *options, char *filename);
void nutinp_dodeck(struct card *deck, char *tt, wordlist *end, bool reuse,
struct card *options, char *filename);
extern void nutcom_source(wordlist *wl);
/* interpolate.c */
@ -254,8 +254,8 @@ extern bool ft_gidb;
extern bool ft_controldb;
extern bool ft_asyncdb;
extern char *ft_setkwords[];
extern struct line *inp_getopts(struct line *deck);
extern struct line *inp_getoptsc(char *line, struct line *options);
extern struct card *inp_getopts(struct card *deck);
extern struct card *inp_getoptsc(char *line, struct card *options);
extern bool ft_ngdebug;
extern bool ft_stricterror;

6
src/main.c

@ -265,7 +265,7 @@ if_dump(CKTcircuit *ckt, FILE *fp)
/* -------------------------------------------------------------------------- */
CKTcircuit *
if_inpdeck(struct line *deck, INPtables **tab)
if_inpdeck(struct card *deck, INPtables **tab)
{
NG_IGNORE(tab);
NG_IGNORE(deck);
@ -410,8 +410,8 @@ ipc_get_line(char *str, int *len, Ipc_Wait_t wait)
return x;
}
struct line *
ENHtranslate_poly(struct line *deck)
struct card *
ENHtranslate_poly(struct card *deck)
{
NG_IGNORE(deck);
return NULL;

38
src/xspice/enh/enhtrans.c

@ -79,25 +79,25 @@ to new polynomial controlled source code model syntax.
/* out the old dependent source. */
/* It returns (a pointer to) the processed deck. */
/*---------------------------------------------------------------------*/
struct line *
struct card *
ENHtranslate_poly(
struct line *deck) { /* Linked list of lines in input deck */
struct line *d;
struct line *l1;
struct line *l2;
struct card *deck) { /* Linked list of lines in input deck */
struct card *d;
struct card *l1;
struct card *l2;
char *card;
/* Iterate through each card in the deck and translate as needed */
for(d = deck; d; d = d->li_next) {
for(d = deck; d; d = d->nextcard) {
#ifdef TRACE
/* SDB debug statement */
printf("In ENHtranslate_poly, now examining card %s . . . \n", d->li_line);
printf("In ENHtranslate_poly, now examining card %s . . . \n", d->line);
#endif
/* If doesn't need to be translated, continue to next card */
if(! needs_translating(d->li_line)) {
if(! needs_translating(d->line)) {
#ifdef TRACE
/* SDB debug statement */
@ -112,27 +112,27 @@ ENHtranslate_poly(
#endif
/* Create two new line structs and splice into deck */
l1 = TMALLOC(struct line, 1);
l2 = TMALLOC(struct line, 1);
l2->li_next = d->li_next;
l1->li_next = l2;
d->li_next = l1;
l1 = TMALLOC(struct card, 1);
l2 = TMALLOC(struct card, 1);
l2->nextcard = d->nextcard;
l1->nextcard = l2;
d->nextcard = l1;
/* PN 2004: Add original linenumber to ease the debug process
* for malfromned netlist
*/
l1->li_linenum = d->li_linenum;
l2->li_linenum = d->li_linenum;
l1->linenum = d->linenum;
l2->linenum = d->linenum;
/* Create the translated cards */
d->li_error = two2three_translate(d->li_line, &(l1->li_line), &(l2->li_line));
d->error = two2three_translate(d->line, &(l1->line), &(l2->line));
/* Comment out the original line */
card = TMALLOC(char, strlen(d->li_line) + 2);
card = TMALLOC(char, strlen(d->line) + 2);
strcpy(card,"*");
strcat(card, d->li_line);
d->li_line = card;
strcat(card, d->line);
d->line = card;
#ifdef TRACE
/* SDB debug statement */

Loading…
Cancel
Save