search just once for basic device types

This commit is contained in:
Henrik Forstén 2013-06-29 20:00:21 +02:00 committed by rlar
parent c659c21e7e
commit e9e3bf2a69
5 changed files with 25 additions and 20 deletions

View File

@ -16,7 +16,7 @@ void INP2C(CKTcircuit *ckt, INPtables * tab, card * current)
/* parse a capacitor card */
/* Cname <node> <node> [<val>] [<mname>] [IC=<val>] */
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);

View File

@ -17,7 +17,7 @@ void INP2I(CKTcircuit *ckt, INPtables * tab, card * current)
/* Iname <node> <node> [ [DC] <val>] [AC [<val> [<val> ] ] ]
* [<tran function>] */
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);

View File

@ -16,7 +16,7 @@ void INP2L(CKTcircuit *ckt, INPtables * tab, card * current)
/* parse an inductor card */
/* Lname <node> <node> [<val>] [<mname>] [IC=<val>] */
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);

View File

@ -22,7 +22,7 @@ void INP2R(CKTcircuit *ckt, INPtables * tab, card * current)
/* parse a resistor card */
/* Rname <node> <node> [<val>][<mname>][w=<val>][l=<val>][ac=<val>] */
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 */

View File

@ -17,7 +17,7 @@ void INP2V(CKTcircuit *ckt, INPtables * tab, card * current)
/* Vname <node> <node> [ [DC] <val>] [AC [<val> [<val> ] ] ]
* [<tran function>] */
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);