diff --git a/src/include/ngspice/inpdefs.h b/src/include/ngspice/inpdefs.h index e8d9c864f..a5a6fb8bc 100644 --- a/src/include/ngspice/inpdefs.h +++ b/src/include/ngspice/inpdefs.h @@ -135,6 +135,7 @@ void INPpas3( CKTcircuit *, struct card *, INPtables *, TSKtask *, IFparm *, int); int INPpName(char *, IFvalue *, CKTcircuit *, int, GENinstance *); int INPtermInsert(CKTcircuit *, char **, INPtables *, CKTnode **); +int INPtermSearch(CKTcircuit*, char**, INPtables*, CKTnode**); int INPmkTerm(CKTcircuit *, char **, INPtables *, CKTnode **); int INPtypelook(char *); int INP2dot(CKTcircuit *, INPtables *, struct card *, TSKtask *, CKTnode *); diff --git a/src/spicelib/parser/inppas3.c b/src/spicelib/parser/inppas3.c index 87e47b0bd..d1eaf6b13 100644 --- a/src/spicelib/parser/inppas3.c +++ b/src/spicelib/parser/inppas3.c @@ -90,9 +90,17 @@ INPpas3(CKTcircuit *ckt, struct card *data, INPtables *tab, TSKtask *task, /* looks like V - must be V(xx) - get xx now*/ char *nodename; INPgetNetTok(&line,&nodename,1); - if (INPtermInsert(ckt,&nodename,tab,&node1)!=E_EXISTS) + /* If node is not found, issue a warning, ignore the defective token */ + if (INPtermSearch(ckt, &nodename, tab, &node1) != E_EXISTS) { fprintf(stderr, - "Warning : Nodeset on non-existant node - %s\n", nodename); + "Warning : Nodeset on non-existent node - %s, ignored\n", nodename); + fprintf(stderr, + " Please check line %s\n\n", current->line); + FREE(name); + /* Gobble the rest of the token */ + line = nexttok(line); + continue; + } ptemp.rValue = INPevaluate(&line,&error,1); IFC(setNodeParm, (ckt, node1, which, &ptemp, NULL)); FREE(name); @@ -131,9 +139,17 @@ INPpas3(CKTcircuit *ckt, struct card *data, INPtables *tab, TSKtask *task, /* looks like V - must be V(xx) - get xx now*/ char *nodename; INPgetNetTok(&line,&nodename,1); - if (INPtermInsert(ckt,&nodename,tab,&node1)!=E_EXISTS) + /* If node is not found, issue a warning, ignore the defective token */ + if (INPtermSearch(ckt, &nodename, tab, &node1) != E_EXISTS) { fprintf(stderr, - "Warning : IC on non-existant node - %s\n", nodename); + "Warning : IC on non-existent node - %s, ignored\n", nodename); + fprintf(stderr, + " Please check line %s\n\n", current->line); + FREE(name); + /* Gobble the rest of the token */ + line = nexttok(line); + continue; + } ptemp.rValue = INPevaluate(&line,&error,1); IFC(setNodeParm, (ckt, node1, which, &ptemp, NULL)); FREE(name); diff --git a/src/spicelib/parser/inpsymt.c b/src/spicelib/parser/inpsymt.c index d77b23265..4cec02c89 100644 --- a/src/spicelib/parser/inpsymt.c +++ b/src/spicelib/parser/inpsymt.c @@ -281,3 +281,25 @@ static int hash(char *name, int tsize) return (int) (hash % (unsigned) tsize); } + +/* Just tests for the existence of a node. If node is found, its + token and node adresses are fed back. + Return value 0 if no node is found, E_EXISTS if its already there */ +int INPtermSearch(CKTcircuit* ckt, char** token, INPtables* tab, CKTnode** node) +{ + int key; + struct INPnTab* t; + NG_IGNORE(ckt); + + key = hash(*token, tab->INPtermsize); + for (t = tab->INPtermsymtab[key]; t; t = t->t_next) { + if (!strcmp(*token, t->t_ent)) { + FREE(*token); + *token = t->t_ent; + if (node) + *node = t->t_node; + return (E_EXISTS); + } + } + return (0); +}