From e9e3bf2a698a4ebb6ba68dae24fb525835468454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Forst=C3=A9n?= Date: Sat, 29 Jun 2013 20:00:21 +0200 Subject: [PATCH] search just once for basic device types --- src/spicelib/parser/inp2c.c | 9 +++++---- src/spicelib/parser/inp2i.c | 9 +++++---- src/spicelib/parser/inp2l.c | 9 +++++---- src/spicelib/parser/inp2r.c | 9 +++++---- src/spicelib/parser/inp2v.c | 9 +++++---- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/spicelib/parser/inp2c.c b/src/spicelib/parser/inp2c.c index b8aaac369..b69453d57 100644 --- a/src/spicelib/parser/inp2c.c +++ b/src/spicelib/parser/inp2c.c @@ -16,7 +16,7 @@ void INP2C(CKTcircuit *ckt, INPtables * tab, card * current) /* parse a capacitor card */ /* Cname [] [] [IC=] */ - int mytype; /* the type we determine capacitors are */ + static int mytype = -1; /* the type we determine capacitors are */ int type = 0; /* the type the model says it is */ char *line; /* the part of the current line left to parse */ char *saveline; /* ... just in case we need to go back... */ @@ -41,10 +41,11 @@ void INP2C(CKTcircuit *ckt, INPtables * tab, card * current) printf("In INP2C, Current line: %s\n", current->line); #endif - mytype = INPtypelook("Capacitor"); if (mytype < 0) { - LITERR("Device type Capacitor not supported by this binary\n"); - return; + if ((mytype = INPtypelook("Capacitor")) < 0) { + LITERR("Device type Capacitor not supported by this binary\n"); + return; + } } line = current->line; INPgetTok(&line, &name, 1); diff --git a/src/spicelib/parser/inp2i.c b/src/spicelib/parser/inp2i.c index 8895eb5fe..644e174b5 100644 --- a/src/spicelib/parser/inp2i.c +++ b/src/spicelib/parser/inp2i.c @@ -17,7 +17,7 @@ void INP2I(CKTcircuit *ckt, INPtables * tab, card * current) /* Iname [ [DC] ] [AC [ [ ] ] ] * [] */ - int type; /* the type the model says it is */ + static int type = -1; /* the type the model says it is */ char *line; /* the part of the current line left to parse */ char *name; /* the resistor's name */ char *nname1; /* the first node's name */ @@ -31,10 +31,11 @@ void INP2I(CKTcircuit *ckt, INPtables * tab, card * current) double leadval; /* actual value of unlabeled number */ IFuid uid; /* uid for default model */ - type = INPtypelook("Isource"); if (type < 0) { - LITERR("Device type Isource not supported by this binary\n"); - return; + if ((type = INPtypelook("Isource")) < 0) { + LITERR("Device type Isource not supported by this binary\n"); + return; + } } line = current->line; INPgetTok(&line, &name, 1); diff --git a/src/spicelib/parser/inp2l.c b/src/spicelib/parser/inp2l.c index d72330a6e..971034698 100644 --- a/src/spicelib/parser/inp2l.c +++ b/src/spicelib/parser/inp2l.c @@ -16,7 +16,7 @@ void INP2L(CKTcircuit *ckt, INPtables * tab, card * current) /* parse an inductor card */ /* Lname [] [] [IC=] */ - int mytype; /* the type we determine inductors are */ + int mytype = -1; /* the type we determine inductors are */ int type = 0; /* the type the model says it is */ char *line; /* the part of the current line left to parse */ char *saveline; /* ... just in case we need to go back... */ @@ -41,10 +41,11 @@ void INP2L(CKTcircuit *ckt, INPtables * tab, card * current) printf("In INP2L, Current line: %s\n", current->line); #endif - mytype = INPtypelook("Inductor"); if (mytype < 0) { - LITERR("Device type Inductor not supported by this binary\n"); - return; + if ((mytype = INPtypelook("Inductor")) < 0) { + LITERR("Device type Inductor not supported by this binary\n"); + return; + } } line = current->line; INPgetTok(&line, &name, 1); diff --git a/src/spicelib/parser/inp2r.c b/src/spicelib/parser/inp2r.c index 29c5b6db3..45dce2d83 100644 --- a/src/spicelib/parser/inp2r.c +++ b/src/spicelib/parser/inp2r.c @@ -22,7 +22,7 @@ void INP2R(CKTcircuit *ckt, INPtables * tab, card * current) /* parse a resistor card */ /* Rname [][][w=][l=][ac=] */ - int mytype; /* the type we determine resistors are */ + static int mytype = -1; /* the type we determine resistors are */ int type = 0; /* the type the model says it is */ char *line; /* the part of the current line left to parse */ char *saveline; /* ... just in case we need to go back... */ @@ -49,10 +49,11 @@ void INP2R(CKTcircuit *ckt, INPtables * tab, card * current) printf("In INP2R, Current line: %s\n", current->line); #endif - mytype = INPtypelook("Resistor"); if (mytype < 0) { - LITERR("Device type Resistor not supported by this binary\n"); - return; + if ((mytype = INPtypelook("Resistor")) < 0) { + LITERR("Device type Resistor not supported by this binary\n"); + return; + } } line = current->line; INPgetTok(&line, &name, 1); /* Rname */ diff --git a/src/spicelib/parser/inp2v.c b/src/spicelib/parser/inp2v.c index 01ce5ddf8..0c726ad18 100644 --- a/src/spicelib/parser/inp2v.c +++ b/src/spicelib/parser/inp2v.c @@ -17,7 +17,7 @@ void INP2V(CKTcircuit *ckt, INPtables * tab, card * current) /* Vname [ [DC] ] [AC [ [ ] ] ] * [] */ - int type; /* the type the model says it is */ + static int type = -1; /* the type the model says it is */ char *line; /* the part of the current line left to parse */ char *name; /* the resistor's name */ char *nname1; /* the first node's name */ @@ -31,10 +31,11 @@ void INP2V(CKTcircuit *ckt, INPtables * tab, card * current) double leadval; /* actual value of unlabeled number */ IFuid uid; /* uid for default model */ - type = INPtypelook("Vsource"); if (type < 0) { - LITERR("Device type Vsource not supported by this binary\n"); - return; + if ((type = INPtypelook("Vsource")) < 0) { + LITERR("Device type Vsource not supported by this binary\n"); + return; + } } line = current->line; INPgetTok(&line, &name, 1);