inp2q.c, #17/23, rewrite, using a 'for' loop

This commit is contained in:
rlar 2017-03-11 18:24:29 +01:00
parent 03d3e2ea12
commit 807115c145
1 changed files with 11 additions and 26 deletions

View File

@ -38,9 +38,11 @@ void INP2Q(CKTcircuit *ckt, INPtables * tab, card * current, CKTnode *gnode)
char *line; /* the part of the current line left to parse */ char *line; /* the part of the current line left to parse */
char *name; /* the resistor's name */ char *name; /* the resistor's name */
#ifdef ADMS #ifdef ADMS
const int max_i = 4;
char *nname[6]; char *nname[6];
CKTnode *node[5]; CKTnode *node[5];
#else #else
const int max_i = 5;
char *nname[5]; char *nname[5];
CKTnode *node[4]; CKTnode *node[4];
#endif #endif
@ -70,36 +72,19 @@ void INP2Q(CKTcircuit *ckt, INPtables * tab, card * current, CKTnode *gnode)
} }
model = NULL; model = NULL;
i = 3;
INPgetTok(&line, &nname[i], 1);
thismodel = NULL; thismodel = NULL;
/* See if 4th token after device specification is a model name */
if (INPlookMod(nname[i])) { for (i = 3; ; i++) {
model = nname[i];
INPinsert(&model, tab);
current->error = INPgetMod(ckt, model, &thismodel, tab);
} else {
INPtermInsert(ckt, &nname[i], tab, &node[i]);
i = 4;
INPgetTok(&line, &nname[i], 1); INPgetTok(&line, &nname[i], 1);
if (INPlookMod(nname[i])) { if (INPlookMod(nname[i])) {
model = nname[i]; model = nname[i];
INPinsert(&model, tab); INPinsert(&model, tab);
current->error = INPgetMod(ckt, model, &thismodel, tab); current->error = INPgetMod(ckt, model, &thismodel, tab);
} else { break;
#ifdef ADMS
INPtermInsert(ckt, &nname[i], tab, &node[i]);
i = 5;
INPgetTok(&line, &nname[i], 1);
if (INPlookMod(nname[i])) {
model = nname[i];
INPinsert(&model, tab);
current->error = INPgetMod(ckt, model, &thismodel, tab);
}
#endif
} }
if (i >= max_i)
break;
INPtermInsert(ckt, &nname[i], tab, &node[i]);
} }
if (!model) { if (!model) {