diff --git a/src/frontend/ChangeLog b/src/frontend/ChangeLog index a59b5e15f..8b4291ce0 100644 --- a/src/frontend/ChangeLog +++ b/src/frontend/ChangeLog @@ -1,3 +1,9 @@ +2003.4.10 Stuart Brorson + * modified inp_readall (inpcom.c) to ignore blank + lines terminated by \r\n *and * \n. This fixes problems + associated with importing files from Windozeland. + * Added explanatory comments to many modules. + 2001-11-25 Emmanuel Rouat * circuits.h: transfered definition of sstructire 'circ' to ftedefs.h diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 3cae141c8..8642d4f01 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -533,9 +533,13 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse, ckt = NULL; out_init(); - for (dd = deck; dd; dd = dd->li_next) - if (dd->li_error) { - char *p, *q; + for (dd = deck; dd; dd = dd->li_next) { + + /* debug statement */ + /* printf("In inp_dodeck, examining line %s . . . \n", dd->li_line); */ + + if (dd->li_error) { + char *p, *q; #ifdef XSPICE /* gtri - modify - 12/12/90 - wbk - add setting of ipc syntax error flag */ g_ipc.syntax_error = IPC_TRUE; #endif @@ -556,7 +560,10 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse, *q++ = '\n'; p = q; } while (p && *p); - } + } /* end if (dd->li_error) */ + + } /* for (dd = deck; dd; dd = dd->li_next) */ + /* Add this circuit to the circuit list. If reuse is TRUE then use * the ft_curckt structure. */ diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 36fea0592..c68cd92c3 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -32,13 +32,14 @@ Author: 1985 Wayne A. Christopher /* gtri - end - 12/12/90 */ #endif -/* This routine reads a line (of arbitrary length), up to a '\n' or 'EOF' - * and returns a pointer to the resulting null terminated string. - * The '\n' if found, is included in the returned string. - * From: jason@ucbopal.BERKELEY.EDU (Jason Venner) - * Newsgroups: net.sources - */ +/*-------------------------------------------------------------------------* + * This routine reads a line (of arbitrary length), up to a '\n' or 'EOF' * + * and returns a pointer to the resulting null terminated string. * + * The '\n' if found, is included in the returned string. * + * From: jason@ucbopal.BERKELEY.EDU (Jason Venner) * + * Newsgroups: net.sources * + *-------------------------------------------------------------------------*/ #define STRGROW 256 static char * @@ -79,10 +80,11 @@ readline(FILE *fd) return (strptr); } -/* Look up the variable sourcepath and try everything in the list in order - * if the file isn't in . and it isn't an abs path name. - */ +/*-------------------------------------------------------------------------* + * Look up the variable sourcepath and try everything in the list in order * + * if the file isn't in . and it isn't an abs path name. * + *-------------------------------------------------------------------------*/ FILE * inp_pathopen(char *name, char *mode) { @@ -117,10 +119,12 @@ inp_pathopen(char *name, char *mode) return (NULL); } -/* Read the entire input file and return a pointer to the first line of - * the linked list of 'card' records in data. - */ +/*------------------------------------------------------------------------- + * Read the entire input file and return a pointer to the first line of + * the linked list of 'card' records in data. The pointer is stored in + * *data. + *-------------------------------------------------------------------------*/ void inp_readall(FILE *fp, struct line **data) { @@ -137,6 +141,7 @@ inp_readall(FILE *fp, struct line **data) char ipc_buffer[1025]; /* Had better be big enough */ int ipc_len; + /* First read in all lines & put them in the struct cc */ while (1) { /* If IPC is not enabled, do equivalent of what SPICE did before */ @@ -168,30 +173,49 @@ inp_readall(FILE *fp, struct line **data) #else while ((buffer = readline(fp))) { #endif + + /* debug statement */ + /* printf ("in inp_readall, just read %s . . .\n", buffer); */ + + /* OK -- now we have loaded the next line into 'buffer'. Process it. */ + /* If input line is blank, ignore it & continue looping. */ + if ( (strcmp(buffer,"\n") == 0) + || (strcmp(buffer,"\r\n") == 0) ) { + continue; + } + + if (*buffer == '@') { tfree(buffer); /* was allocated by readline() */ break; } - for (s = buffer; *s && (*s != '\n'); s++) - ; + + + /* loop through 'buffer' until end is reached. Then test for + premature end. If premature end is reached, spew + error and zap the line. */ + for (s = buffer; *s && (*s != '\n'); s++); if (!*s) { fprintf(cp_err, "Warning: premature EOF\n"); } *s = '\0'; /* Zap the newline. */ + if ( s > buffer && s[-1] == '\r') /* Zap the carriage return under windows */ + s[-1] = '\0'; + /* now handle .include statements */ if (ciprefix(".include", buffer)) { - for (s = buffer; *s && !isspace(*s); s++) + for (s = buffer; *s && !isspace(*s); s++) /* advance past non-space chars */ ; - while (isspace(*s)) + while (isspace(*s)) /* now advance past space chars */ s++; - if (!*s) { + if (!*s) { /* if at end of line, error */ fprintf(cp_err, "Error: .include filename missing\n"); tfree(buffer); /* was allocated by readline() */ continue; - } - for (t = s; *t && !isspace(*t); t++) + } /* Now s points to first char after .include */ + for (t = s; *t && !isspace(*t); t++) /* now advance past non-space chars */ ; - *t = '\0'; + *t = '\0'; /* place \0 and end of file name in buffer */ if (*s == '~') { copys = cp_tildexpand(s); /* allocates memory, but can also return NULL */ @@ -199,8 +223,9 @@ inp_readall(FILE *fp, struct line **data) s = copys; /* reuse s, but remember, buffer still points to allocated memory */ } } - - if (!(newfp = inp_pathopen(s, "r"))) { + + /* open file specified by .include statement */ + if (!(newfp = inp_pathopen(s, "r"))) { perror(s); if(copys) { tfree(copys); /* allocated by the cp_tildexpand() above */ @@ -213,17 +238,23 @@ inp_readall(FILE *fp, struct line **data) tfree(copys); /* allocated by the cp_tildexpand() above */ } - inp_readall(newfp, &newcard); + inp_readall(newfp, &newcard); /* read stuff in include file into netlist */ (void) fclose(newfp); /* Make the .include a comment */ *buffer = '*'; - if (end) { - end->li_next = alloc(struct line); - end = end->li_next; + + /* now check if this is the first pass (i.e. end points to null) */ + if (end) { /* end already exists */ + end->li_next = alloc(struct line); /* create next card */ + end = end->li_next; /* make end point to next card */ } else { - end = cc = alloc(struct line); + end = cc = alloc(struct line); /* create the deck & end. cc will + point to beginning of deck, end to + the end */ } + + /* now fill out rest of struct end. */ end->li_next = NULL; end->li_error = NULL; end->li_actual = NULL; @@ -237,50 +268,67 @@ inp_readall(FILE *fp, struct line **data) /* Fix the buffer up a bit. */ (void) strncpy(buffer + 1, "end of:", 7); + } /* end of .include handling */ + + /* now check if this is the first pass (i.e. end points to null) */ + if (end) { /* end already exists */ + end->li_next = alloc(struct line); /* create next card */ + end = end->li_next; /* point to next card */ + } else { /* End doesn't exist. Create it. */ + end = cc = alloc(struct line); /* note that cc points to beginning + of deck, end to the end */ } - if (end) { - end->li_next = alloc(struct line); - end = end->li_next; - } else { - end = cc = alloc(struct line); - } + /* now put buffer into li */ end->li_next = NULL; end->li_error = NULL; end->li_actual = NULL; end->li_line = buffer; end->li_linenum = line++; } + if (!end) { /* No stuff here */ *data = NULL; return; - } + } /* end while ((buffer = readline(fp))) */ - /* Now make logical lines. */ - working = cc->li_next; /* Skip title. */ + /* This should be freed because we are done with it. */ + /* tfree(buffer); */ + + + /* Now clean up li: remove comments & stitch together continuation lines. */ + working = cc->li_next; /* cc points to head of deck. Start with the + next card. */ while (working) { for (s = working->li_line; (c = *s) && c <= ' '; s++) ; + + /* debug statement */ + /* printf("Now processing linked list, at s = %s . . . \n", s); */ + switch (c) { - case '#': + case '#': case '$': case '*': case '\0': - /* - prev = NULL; - */ - working = working->li_next; + /* this used to be commented out. Why? */ + /* prev = NULL; */ + working = working->li_next; /* for these chars, go to next card */ break; - case '+': + + case '+': /* handle continuation */ if (!prev) { working->li_error = copy( "Illegal continuation line: ignored."); working = working->li_next; break; } + + /* create buffer and write last and current line into it. */ buffer = tmalloc(strlen(prev->li_line) + strlen(s) + 2); - (void) sprintf(buffer, "%s %s", prev->li_line, s + 1); + (void) sprintf(buffer, "%s %s", prev->li_line, s + 1); + s = prev->li_line; prev->li_line = buffer; prev->li_next = working->li_next; @@ -302,7 +350,8 @@ inp_readall(FILE *fp, struct line **data) } working = prev->li_next; break; - default: + + default: /* regular one-line card */ prev = working; working = working->li_next; break; @@ -313,7 +362,9 @@ inp_readall(FILE *fp, struct line **data) return; } - +/*-------------------------------------------------------------------------* + * * + *-------------------------------------------------------------------------*/ void inp_casefix(char *string) { diff --git a/src/frontend/spiceif.c b/src/frontend/spiceif.c index 0b445d60e..34d6566c5 100644 --- a/src/frontend/spiceif.c +++ b/src/frontend/spiceif.c @@ -109,7 +109,13 @@ if_inpdeck(struct line *deck, INPtables **tab) } ft_curckt->ci_curTask = ft_curckt->ci_defTask; + + /* Debug statement */ + /* printf("In if_inpdeck, about to call INPpas1. . . \n"); */ INPpas1((void *) ckt, (card *) deck->li_next,(INPtables *)*tab); + + /* Debug statement */ + /* printf("In if_inpdeck, about to call INPpas2. . . \n"); */ INPpas2((void *) ckt, (card *) deck->li_next, (INPtables *) *tab,ft_curckt->ci_defTask); INPkillMods(); diff --git a/src/include/ChangeLog b/src/include/ChangeLog index 7d908a57d..58024470d 100644 --- a/src/include/ChangeLog +++ b/src/include/ChangeLog @@ -1,3 +1,6 @@ +2003.4.10 Stuart Brorson + * Added declaration for INPgetNetTok to inpdefs.h + 2001-11-25 Emmanuel Rouat * ftedefs.h: added definition of structure circ (taken from circuits.h) diff --git a/src/include/inpdefs.h b/src/include/inpdefs.h index 5f815754d..24bb8d153 100644 --- a/src/include/inpdefs.h +++ b/src/include/inpdefs.h @@ -93,6 +93,7 @@ double INPevaluate(char**,int*,int); char * INPfindLev(char*,int*); char * INPgetMod(void*,char*,INPmodel**,INPtables*); int INPgetTok(char**,char**,int); +int INPgetNetTok(char**,char**,int); void INPgetTree(char**,INPparseTree**,void*,INPtables*); IFvalue * INPgetValue(void*,char**,int,INPtables*); int INPgndInsert(void*,char**,INPtables*,void**); diff --git a/src/spicelib/parser/ChangeLog b/src/spicelib/parser/ChangeLog index 2a81fff41..61e2adfce 100644 --- a/src/spicelib/parser/ChangeLog +++ b/src/spicelib/parser/ChangeLog @@ -1,3 +1,8 @@ +2003.4.10 Stuart Brorson + * Cloned INPgetNetTok from INPgetTok in inpgtok.c + * Modified inpg2*.c to use INPgetNetTok for all netnames. + * Added explanatory comments to many files. + 2000-10-12 Arno W. Peters * inpeval.c: Bugfix for subcircuits contributed by Michael diff --git a/src/spicelib/parser/inp2b.c b/src/spicelib/parser/inp2b.c index 8448ebeb7..209ba15e8 100644 --- a/src/spicelib/parser/inp2b.c +++ b/src/spicelib/parser/inp2b.c @@ -40,10 +40,10 @@ void INP2B(void *ckt, INPtables * tab, card * current) INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); error = INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); error = INPtermInsert(ckt, &nname2, tab, &node2); if (!tab->defBmod) { diff --git a/src/spicelib/parser/inp2c.c b/src/spicelib/parser/inp2c.c index c1f2ac855..3ca3b6b2c 100644 --- a/src/spicelib/parser/inp2c.c +++ b/src/spicelib/parser/inp2c.c @@ -44,9 +44,9 @@ void INP2C(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); val = INPevaluate(&line, &error, 1); if (error == 0) { /* Looks like a number */ diff --git a/src/spicelib/parser/inp2d.c b/src/spicelib/parser/inp2d.c index 2d65f4544..393fc375e 100644 --- a/src/spicelib/parser/inp2d.c +++ b/src/spicelib/parser/inp2d.c @@ -42,9 +42,9 @@ void INP2D(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); INPgetTok(&line, &model, 1); INPinsert(&model, tab); diff --git a/src/spicelib/parser/inp2dot.c b/src/spicelib/parser/inp2dot.c index ef7616664..58f88e7bd 100644 --- a/src/spicelib/parser/inp2dot.c +++ b/src/spicelib/parser/inp2dot.c @@ -57,13 +57,13 @@ dot_noise(char *line, void *ckt, INPtables *tab, card *current, length = strlen(name); if (((*name == 'V') || (*name == 'v')) && (length == 1)) { - INPgetTok(&line, &nname1, 0); + INPgetNetTok(&line, &nname1, 0); INPtermInsert(ckt, &nname1, tab, &node1); ptemp.nValue = (IFnode) node1; GCA(INPapName, (ckt, which, foo, "output", &ptemp)) if (*line != ')') { - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); ptemp.nValue = (IFnode) node2; } else { @@ -351,12 +351,12 @@ dot_tf(char *line, void *ckt, INPtables *tab, card *current, if (*line != '(' ) { /* error, bad input format */ } - INPgetTok(&line, &nname1, 0); + INPgetNetTok(&line, &nname1, 0); INPtermInsert(ckt, &nname1, tab, &node1); ptemp.nValue = (IFnode) node1; GCA(INPapName, (ckt, which, foo, "outpos", &ptemp)); if (*line != ')') { - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); ptemp.nValue = (IFnode) node2; GCA(INPapName, (ckt, which, foo, "outneg", &ptemp)); @@ -486,13 +486,13 @@ dot_sens(char *line, void *ckt, INPtables *tab, card *current, LITERR("Syntax error: '(' expected after 'v'\n"); return 0; } - INPgetTok(&line, &nname1, 0); + INPgetNetTok(&line, &nname1, 0); INPtermInsert(ckt, &nname1, tab, &node1); ptemp.nValue = (IFnode) node1; GCA(INPapName, (ckt, which, foo, "outpos", &ptemp)) if (*line != ')') { - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); ptemp.nValue = (IFnode) node2; GCA(INPapName, (ckt, which, foo, "outneg", &ptemp)); diff --git a/src/spicelib/parser/inp2e.c b/src/spicelib/parser/inp2e.c index cd88609be..0c5909df3 100644 --- a/src/spicelib/parser/inp2e.c +++ b/src/spicelib/parser/inp2e.c @@ -42,13 +42,13 @@ void INP2E(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); - INPgetTok(&line, &nname3, 1); + INPgetNetTok(&line, &nname3, 1); INPtermInsert(ckt, &nname3, tab, &node3); - INPgetTok(&line, &nname4, 1); + INPgetNetTok(&line, &nname4, 1); INPtermInsert(ckt, &nname4, tab, &node4); if (!tab->defEmod) { /* create default E model */ diff --git a/src/spicelib/parser/inp2f.c b/src/spicelib/parser/inp2f.c index 32c477863..5e339acca 100644 --- a/src/spicelib/parser/inp2f.c +++ b/src/spicelib/parser/inp2f.c @@ -14,22 +14,23 @@ Author: 1988 Thomas L. Quarles void INP2F(void *ckt, INPtables * tab, card * current) { -/* Fname */ +/* Fname */ + + int type; /* 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 */ + char *nname2; /* the second node's name */ + void *node1; /* the first node's node pointer */ + void *node2; /* the second node's node pointer */ + int error; /* error code temporary */ + void *fast; /* pointer to the actual instance */ + IFvalue ptemp; /* a value structure to package resistance into */ + IFvalue *parm; /* pointer to a value structure for functions which return one */ + int waslead; /* flag to indicate that funny unlabeled number was found */ + double leadval; /* actual value of unlabeled number */ + IFuid uid; /* uid of default model to be created */ - int type; /* 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 */ - char *nname2; /* the second node's name */ - void *node1; /* the first node's node pointer */ - void *node2; /* the second node's node pointer */ - int error; /* error code temporary */ - void *fast; /* pointer to the actual instance */ - IFvalue ptemp; /* a value structure to package resistance into */ - IFvalue *parm; /* a pointer to a value structure to pick things up into */ - int waslead; /* flag to indicate that funny unlabeled number was found */ - double leadval; /* actual value of unlabeled number */ - IFuid uid; /* uid for default model */ type = INPtypelook("CCCS"); if (type < 0) { @@ -39,23 +40,38 @@ void INP2F(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); if (!tab->defFmod) { /* create default F model */ IFnewUid(ckt, &uid, (IFuid) NULL, "F", UID_MODEL, (void **) NULL); IFC(newModel, (ckt, type, &(tab->defFmod), uid)); } + + /* call newInstance with macro IFC */ IFC(newInstance, (ckt, tab->defFmod, &fast, name)); + + /* call bindNode with macro IFC */ IFC(bindNode, (ckt, fast, 1, node1)); + + /* call bindNode with macro IFC */ IFC(bindNode, (ckt, fast, 2, node2)); + parm = INPgetValue(ckt, &line, IF_INSTANCE, tab); + + /* call INPpName with macro GCA */ GCA(INPpName, ("control", parm, ckt, type, fast)); + + /* call INPdevParse with macro PARSECALL */ PARSECALL((&line, ckt, type, fast, &leadval, &waslead, tab)); + if (waslead) { - ptemp.rValue = leadval; - GCA(INPpName, ("gain", &ptemp, ckt, type, fast)); + ptemp.rValue = leadval; + + /* call INPpName with macro GCA */ + GCA(INPpName, ("gain", &ptemp, ckt, type, fast)); } + } diff --git a/src/spicelib/parser/inp2g.c b/src/spicelib/parser/inp2g.c index 60ad74de0..ed77c7f8f 100644 --- a/src/spicelib/parser/inp2g.c +++ b/src/spicelib/parser/inp2g.c @@ -42,13 +42,13 @@ void INP2G(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); - INPgetTok(&line, &nname3, 1); + INPgetNetTok(&line, &nname3, 1); INPtermInsert(ckt, &nname3, tab, &node3); - INPgetTok(&line, &nname4, 1); + INPgetNetTok(&line, &nname4, 1); INPtermInsert(ckt, &nname4, tab, &node4); if (!tab->defGmod) { /* create default G model */ diff --git a/src/spicelib/parser/inp2h.c b/src/spicelib/parser/inp2h.c index 04d386358..e16c77482 100644 --- a/src/spicelib/parser/inp2h.c +++ b/src/spicelib/parser/inp2h.c @@ -39,9 +39,9 @@ void INP2H(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); if (!tab->defHmod) { /* create default H model */ diff --git a/src/spicelib/parser/inp2i.c b/src/spicelib/parser/inp2i.c index 9bb01c5d5..22208bfa1 100644 --- a/src/spicelib/parser/inp2i.c +++ b/src/spicelib/parser/inp2i.c @@ -39,9 +39,9 @@ void INP2I(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); if (!tab->defImod) { /* create default I model */ diff --git a/src/spicelib/parser/inp2j.c b/src/spicelib/parser/inp2j.c index 565fc12a6..0396dded8 100644 --- a/src/spicelib/parser/inp2j.c +++ b/src/spicelib/parser/inp2j.c @@ -38,11 +38,11 @@ void INP2J(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); - INPgetTok(&line, &nname3, 1); + INPgetNetTok(&line, &nname3, 1); INPtermInsert(ckt, &nname3, tab, &node3); INPgetTok(&line, &model, 1); INPinsert(&model, tab); diff --git a/src/spicelib/parser/inp2l.c b/src/spicelib/parser/inp2l.c index 341463dc7..15faeb4ee 100644 --- a/src/spicelib/parser/inp2l.c +++ b/src/spicelib/parser/inp2l.c @@ -38,9 +38,9 @@ void INP2L(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); if (!tab->defLmod) { /* create default L model */ diff --git a/src/spicelib/parser/inp2m.c b/src/spicelib/parser/inp2m.c index 341214160..9a87e860d 100644 --- a/src/spicelib/parser/inp2m.c +++ b/src/spicelib/parser/inp2m.c @@ -54,18 +54,18 @@ INP2M (void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok (&line, &name, 1); INPinsert (&name, tab); - INPgetTok (&line, &nname1, 1); + INPgetNetTok (&line, &nname1, 1); INPtermInsert (ckt, &nname1, tab, &node1); - INPgetTok (&line, &nname2, 1); + INPgetNetTok (&line, &nname2, 1); INPtermInsert (ckt, &nname2, tab, &node2); - INPgetTok (&line, &nname3, 1); + INPgetNetTok (&line, &nname3, 1); INPtermInsert (ckt, &nname3, tab, &node3); - INPgetTok (&line, &nname4, 1); + INPgetNetTok (&line, &nname4, 1); INPtermInsert (ckt, &nname4, tab, &node4); /* See if 5th token after device specification is a model name */ - INPgetTok (&line, &nname5, 1); /* get 5th token */ + INPgetNetTok (&line, &nname5, 1); /* get 5th token */ save = line; /*saj - save the posn for later if the default mosfet model is used */ thismodel = (INPmodel *) NULL; @@ -73,13 +73,13 @@ INP2M (void *ckt, INPtables * tab, card * current) if (thismodel == NULL) { /* 5th token is not a model in the table */ nodeflag = 1; /* now specify a 5 node device */ - INPgetTok (&line, &nname6, 1); /* get next token */ + INPgetNetTok (&line, &nname6, 1); /* get next token */ thismodel = (INPmodel *) NULL; INPgetMod (ckt, nname6, &thismodel, tab); if (thismodel == NULL) { /* 6th token is not a model in the table */ nodeflag = 2; /* now specify a 6 node device */ - INPgetTok (&line, &nname7, 1); /* get next token */ + INPgetNetTok (&line, &nname7, 1); /* get next token */ thismodel = (INPmodel *) NULL; INPgetMod (ckt, nname7, &thismodel, tab); if (thismodel == NULL) diff --git a/src/spicelib/parser/inp2o.c b/src/spicelib/parser/inp2o.c index 33e7cf59c..9e4cc3490 100644 --- a/src/spicelib/parser/inp2o.c +++ b/src/spicelib/parser/inp2o.c @@ -46,13 +46,13 @@ void INP2O(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); - INPgetTok(&line, &nname3, 1); + INPgetNetTok(&line, &nname3, 1); INPtermInsert(ckt, &nname3, tab, &node3); - INPgetTok(&line, &nname4, 1); + INPgetNetTok(&line, &nname4, 1); INPtermInsert(ckt, &nname4, tab, &node4); INPgetTok(&line, &model, 1); if (INPlookMod(model)) { diff --git a/src/spicelib/parser/inp2p.c b/src/spicelib/parser/inp2p.c index e6977c5bd..72e12341b 100644 --- a/src/spicelib/parser/inp2p.c +++ b/src/spicelib/parser/inp2p.c @@ -70,13 +70,13 @@ int num, i; for (i = 0; i < num; i++) { - INPgetTok(&line,&(nname1[i]),1); + INPgetNetTok(&line,&(nname1[i]),1); INPtermInsert(ckt,&(nname1[i]),tab,&(node1[i])); } INPgetTok(&line,&ground,1); INPtermInsert(ckt,&ground,tab,&groundnode); for (i = 0; i < num; i++) { - INPgetTok(&line,&(nname2[i]),1); + INPgetNetTok(&line,&(nname2[i]),1); INPtermInsert(ckt,&(nname2[i]),tab,&(node2[i])); } INPgetTok(&line,&ground,1); diff --git a/src/spicelib/parser/inp2q.c b/src/spicelib/parser/inp2q.c index 0d6423926..192db7696 100644 --- a/src/spicelib/parser/inp2q.c +++ b/src/spicelib/parser/inp2q.c @@ -47,11 +47,11 @@ void INP2Q(void *ckt, INPtables * tab, card * current, void *gnode) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); - INPgetTok(&line, &nname3, 1); + INPgetNetTok(&line, &nname3, 1); INPtermInsert(ckt, &nname3, tab, &node3); INPgetTok(&line, &model, 1); if (INPlookMod(model)) { diff --git a/src/spicelib/parser/inp2r.c b/src/spicelib/parser/inp2r.c index 858392238..3b7c35140 100644 --- a/src/spicelib/parser/inp2r.c +++ b/src/spicelib/parser/inp2r.c @@ -49,9 +49,9 @@ void INP2R(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); val = INPevaluate(&line, &error1, 1); /* either not a number -> model, or diff --git a/src/spicelib/parser/inp2s.c b/src/spicelib/parser/inp2s.c index 9c50f5ef3..7d584fc58 100644 --- a/src/spicelib/parser/inp2s.c +++ b/src/spicelib/parser/inp2s.c @@ -46,13 +46,13 @@ void INP2S(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); - INPgetTok(&line, &nname3, 1); + INPgetNetTok(&line, &nname3, 1); INPtermInsert(ckt, &nname3, tab, &node3); - INPgetTok(&line, &nname4, 1); + INPgetNetTok(&line, &nname4, 1); INPtermInsert(ckt, &nname4, tab, &node4); INPgetTok(&line, &model, 1); INPinsert(&model, tab); diff --git a/src/spicelib/parser/inp2t.c b/src/spicelib/parser/inp2t.c index 1530306dd..ee92b4c69 100644 --- a/src/spicelib/parser/inp2t.c +++ b/src/spicelib/parser/inp2t.c @@ -43,13 +43,13 @@ void INP2T(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); - INPgetTok(&line, &nname3, 1); + INPgetNetTok(&line, &nname3, 1); INPtermInsert(ckt, &nname3, tab, &node3); - INPgetTok(&line, &nname4, 1); + INPgetNetTok(&line, &nname4, 1); INPtermInsert(ckt, &nname4, tab, &node4); if (!tab->defTmod) { /* create deafult T model */ diff --git a/src/spicelib/parser/inp2u.c b/src/spicelib/parser/inp2u.c index 6d03cfadf..092537bd6 100644 --- a/src/spicelib/parser/inp2u.c +++ b/src/spicelib/parser/inp2u.c @@ -43,11 +43,11 @@ void INP2U(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); - INPgetTok(&line, &nname3, 1); + INPgetNetTok(&line, &nname3, 1); INPtermInsert(ckt, &nname3, tab, &node3); INPgetTok(&line, &model, 1); INPinsert(&model, tab); diff --git a/src/spicelib/parser/inp2v.c b/src/spicelib/parser/inp2v.c index c8775cade..fc93000d0 100644 --- a/src/spicelib/parser/inp2v.c +++ b/src/spicelib/parser/inp2v.c @@ -39,9 +39,9 @@ void INP2V(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); if (!tab->defVmod) { /* create default V model */ diff --git a/src/spicelib/parser/inp2w.c b/src/spicelib/parser/inp2w.c index 39f9f9ba1..ec1856702 100644 --- a/src/spicelib/parser/inp2w.c +++ b/src/spicelib/parser/inp2w.c @@ -44,9 +44,9 @@ void INP2W(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); parm = INPgetValue(ckt, &line, IF_INSTANCE, tab); ptemp.uValue = parm->uValue; diff --git a/src/spicelib/parser/inp2y.c b/src/spicelib/parser/inp2y.c index 84a547405..3eb63a176 100644 --- a/src/spicelib/parser/inp2y.c +++ b/src/spicelib/parser/inp2y.c @@ -61,13 +61,13 @@ int lenvalgiven = 0; line = current->line; INPgetTok(&line,&name,1); INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); + INPgetNetTok(&line,&nname1,1); INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&ground1,1); + INPgetNetTok(&line,&ground1,1); INPtermInsert(ckt,&ground1,tab,&gnode1); - INPgetTok(&line,&nname2,1); + INPgetNetTok(&line,&nname2,1); INPtermInsert(ckt,&nname2,tab,&node2); - INPgetTok(&line,&ground2,1); + INPgetNetTok(&line,&ground2,1); INPtermInsert(ckt,&ground2,tab,&gnode2); INPgetTok(&line,&model,1); diff --git a/src/spicelib/parser/inp2z.c b/src/spicelib/parser/inp2z.c index 1656b7374..1c7b9003c 100644 --- a/src/spicelib/parser/inp2z.c +++ b/src/spicelib/parser/inp2z.c @@ -46,11 +46,11 @@ void INP2Z(void *ckt, INPtables * tab, card * current) line = current->line; INPgetTok(&line, &name, 1); INPinsert(&name, tab); - INPgetTok(&line, &nname1, 1); + INPgetNetTok(&line, &nname1, 1); INPtermInsert(ckt, &nname1, tab, &node1); - INPgetTok(&line, &nname2, 1); + INPgetNetTok(&line, &nname2, 1); INPtermInsert(ckt, &nname2, tab, &node2); - INPgetTok(&line, &nname3, 1); + INPgetNetTok(&line, &nname3, 1); INPtermInsert(ckt, &nname3, tab, &node3); INPgetTok(&line, &model, 1); INPinsert(&model, tab); diff --git a/src/spicelib/parser/inpdomod.c b/src/spicelib/parser/inpdomod.c index 319a35713..f826bcb3f 100644 --- a/src/spicelib/parser/inpdomod.c +++ b/src/spicelib/parser/inpdomod.c @@ -9,7 +9,13 @@ Author: 1985 Thomas L. Quarles #include "inpdefs.h" #include "inp.h" - +/*-------------------------------------------------------------- + * This fcn takes the model card & examines it. Depending upon + * model type, it parses the model line, and then calls + * INPmakeMod to stick the model name into the model list. + * Note that multi-line models are handled in the calling fcn + * (INPpas1). + *-------------------------------------------------------------*/ char *INPdomodel(void *ckt, card * image, INPtables * tab) { @@ -21,10 +27,16 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) char *line; line = image->line; + + /* debug statement */ + /* printf("In INPdomodel, examining line %s . . . \n", line); */ + INPgetTok(&line, &modname, 1); /* throw away '.model' */ - INPgetTok(&line, &modname, 1); - INPinsert(&modname, tab); - INPgetTok(&line, &typename, 1); + INPgetTok(&line, &modname, 1); /* get model name */ + INPinsert(&modname, tab); /* stick model name into table */ + INPgetTok(&line, &typename, 1); /* get model type */ + + /* ----- Check if model is a BJT --------- */ if ((strcmp(typename, "npn") == 0) || (strcmp(typename, "pnp") == 0)) { err = INPfindLev(line,&lev); switch(lev) { @@ -38,19 +50,22 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) break; case 2: type = INPtypelook("BJT2"); - if(type < 0) { - err = INPmkTemp( + if(type < 0) { + err = INPmkTemp( "Device type BJT2 not available in this binary\n"); - } - break; + } + break; default: /* placeholder; use level 3 for the next model */ - err = INPmkTemp( - "Only BJT levels 1 and 2 are supported in this binary\n"); - break; + err = INPmkTemp( + "Only BJT levels 1 and 2 are supported in this binary\n"); + break; } INPmakeMod(modname, type, image); - } else if (strcmp(typename, "d") == 0) { + } /* end if ((strcmp(typename, "npn") == 0) || (strcmp(typename, "pnp") == 0)) */ + + /* -------- Check if model is a diode --------- */ + else if (strcmp(typename, "d") == 0) { type = INPtypelook("Diode"); if (type < 0) { err = @@ -58,9 +73,12 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) ("Device type Diode not available in this binary\n"); } INPmakeMod(modname, type, image); - } else if ((strcmp(typename, "njf") == 0) - || (strcmp(typename, "pjf") == 0)) { - err = INPfindLev(line, &lev); + } /* else if (strcmp(typename, "d") == 0) { */ + + /* -------- Check if model is a jfet --------- */ + else if ((strcmp(typename, "njf") == 0) + || (strcmp(typename, "pjf") == 0)) { + err = INPfindLev(line, &lev); switch (lev) { case 0: case 1: @@ -86,7 +104,10 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) break; } INPmakeMod(modname, type, image); - } else if ((strcmp(typename, "nmf") == 0) + } /* end else if ((strcmp(typename, "njf") == 0) */ + + /* -------- Check if model is a ???? --------- */ + else if ((strcmp(typename, "nmf") == 0) || (strcmp(typename, "pmf") == 0) || (strcmp(typename, "nhfet") == 0) || (strcmp(typename, "phfet") == 0)) { @@ -142,7 +163,10 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) break; } INPmakeMod(modname, type, image); - } else if (strcmp(typename, "urc") == 0) { + } + + /* -------- Check if model is a ???? --------- */ + else if (strcmp(typename, "urc") == 0) { type = INPtypelook("URC"); if (type < 0) { err = @@ -150,7 +174,10 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) ("Device type URC not available in this binary\n"); } INPmakeMod(modname, type, image); - } else if ((strcmp(typename, "nmos") == 0) + } + + /* -------- Check if model is a MOSFET --------- */ + else if ((strcmp(typename, "nmos") == 0) || (strcmp(typename, "pmos") == 0) || (strcmp(typename, "nsoi") == 0) || (strcmp(typename, "psoi") == 0)) { @@ -227,8 +254,8 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) if(type < 0) { err = INPmkTemp( "Device type MOS9 not available in this binary\n"); - } - break; + } + break; case 10: type = INPtypelook("B3SOIPD"); if (type < 0) { @@ -332,7 +359,11 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) break; } INPmakeMod(modname, type, image); - } else if (strcmp(typename, "r") == 0) { + } + + + /* -------- Check if model is a resistor --------- */ + else if (strcmp(typename, "r") == 0) { type = INPtypelook("Resistor"); if (type < 0) { err = @@ -340,7 +371,11 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) ("Device type Resistor not available in this binary\n"); } INPmakeMod(modname, type, image); - } else if(strcmp(typename,"txl") == 0) { + } + + + /* -------- Check if model is a transmission line of some sort --------- */ + else if(strcmp(typename,"txl") == 0) { char *val; double rval=0, lval=0; INPgetTok(&line,&val,1); @@ -374,22 +409,34 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) "Device type TransLine not available in this binary\n"); } - } else if(strcmp(typename,"cpl") == 0) { + } + + /* -------- Check if model is a ???? --------- */ + else if(strcmp(typename,"cpl") == 0) { type = INPtypelook("CplLines"); if(type < 0) { err = INPmkTemp( "Device type CplLines not available in this binary\n"); } INPmakeMod(modname,type,image); - } else if (strcmp(typename, "c") == 0) { - type = INPtypelook("Capacitor"); + + } + + + /* -------- Check if model is a cap --------- */ + else if (strcmp(typename, "c") == 0) { + type = INPtypelook("Capacitor"); if (type < 0) { err = INPmkTemp ("Device type Capacitor not available in this binary\n"); } INPmakeMod(modname, type, image); - } else if (strcmp(typename, "sw") == 0) { + } + + + /* -------- Check if model is a switch --------- */ + else if (strcmp(typename, "sw") == 0) { type = INPtypelook("Switch"); if (type < 0) { err = @@ -397,7 +444,11 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) ("Device type Switch not available in this binary\n"); } INPmakeMod(modname, type, image); - } else if (strcmp(typename, "csw") == 0) { + } + + + /* -------- Check if model is a ???? --------- */ + else if (strcmp(typename, "csw") == 0) { type = INPtypelook("CSwitch"); if (type < 0) { err = @@ -405,7 +456,11 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) ("Device type CSwitch not available in this binary\n"); } INPmakeMod(modname, type, image); - } else if (strcmp(typename, "ltra") == 0) { + } + + + /* -------- Check if model is a ???? --------- */ + else if (strcmp(typename, "ltra") == 0) { type = INPtypelook("LTRA"); if (type < 0) { err = @@ -413,7 +468,11 @@ char *INPdomodel(void *ckt, card * image, INPtables * tab) ("Device type LTRA not available in this binary\n"); } INPmakeMod(modname, type, image); - } else { + } + + + /* -------- Default action --------- */ + else { #ifndef XSPICE type = -1; err = (char *) MALLOC(35 + strlen(typename)); diff --git a/src/spicelib/parser/inpgtok.c b/src/spicelib/parser/inpgtok.c index a83be7e33..706a145f0 100644 --- a/src/spicelib/parser/inpgtok.c +++ b/src/spicelib/parser/inpgtok.c @@ -19,18 +19,24 @@ Modified: 2000 AlansFixes #include "inpdefs.h" #include "inp.h" +/*------------------------------------------------------------------- + * INPgetTok -- this fcn extracts a generic input token from + * 'line' and returns a pointer to it in 'token'. + *------------------------------------------------------------------*/ int INPgetTok(char **line, char **token, int gobble) - /* eat non-whitespace trash AFTER token? */ { char *point; int signstate; - /* scan along throwing away garbage characters */ + /* scan along throwing away garbage characters until end of line + or a separation char is found */ for (point = *line; *point != '\0'; point++) { if (*point == ' ') continue; if (*point == '\t') continue; + if (*point == '\r') + continue; if (*point == '=') continue; if (*point == '(') @@ -43,13 +49,17 @@ int INPgetTok(char **line, char **token, int gobble) } /* mark beginning of token */ *line = point; - /* now find all good characters */ + + /* now find all good characters up to next occurance of a + separation character. */ signstate = 0; for (point = *line; *point != '\0'; point++) { if (*point == ' ') break; if (*point == '\t') break; + if (*point == '\r') + break; if (*point == '=') break; if (*point == '(') @@ -58,24 +68,20 @@ int INPgetTok(char **line, char **token, int gobble) break; if (*point == ',') break; - /* This is not complex enough to catch all errors, but it will get the "good" parses */ + /* This is not complex enough to catch all errors, + but it will get the "good" parses */ if ((*point == '+') || (*point == '-')){ /* Treat '+' signs same as '-' signs */ if (signstate == 1 || signstate == 3) break; signstate += 1; continue; } - /* saj */ if (*point == '*') - continue; - /*break;*/ + break; if (*point == '/') - continue; - /*break;*/ + break; if (*point == '^') - continue; - /*break;*/ - /*saj */ + break; if (isdigit(*point) || *point == '.') { if (signstate > 1) signstate = 3; @@ -87,6 +93,7 @@ int INPgetTok(char **line, char **token, int gobble) signstate = 3; } + if (point == *line && *point) /* Weird items, 1 char */ point++; *token = (char *) MALLOC(1 + point - *line); @@ -95,25 +102,114 @@ int INPgetTok(char **line, char **token, int gobble) (void) strncpy(*token, *line, point - *line); *(*token + (point - *line)) = '\0'; *line = point; + /* gobble garbage to next token */ for (; **line != '\0'; (*line)++) { if (**line == ' ') continue; if (**line == '\t') continue; + if (**line == '\r') + continue; if ((**line == '=') && gobble) continue; if ((**line == ',') && gobble) continue; break; } - /*printf("found token (%s) and rest of line (%s)\n",*token,*line); */ + /* debug statement */ + /* printf("found generic token (%s) and rest of line (%s)\n", *token, *line); */ return (OK); } + +/*------------------------------------------------------------------- + * INPgetNetTok -- this fcn extracts an input netname token from + * 'line' and returns a pointer to it in 'token'. + * This fcn cloned from INPgetTok by SDB to enable + * complex netnames (e.g. netnames like '+VCC' and 'IN-'). + * mailto:sdb@cloud9.net -- 4.7.2003 + *------------------------------------------------------------------*/ +int INPgetNetTok(char **line, char **token, int gobble) + /* eat non-whitespace trash AFTER token? */ +{ + char *point; + int signstate; + + /* scan along throwing away garbage characters until end of line + or a separation char is found */ + for (point = *line; *point != '\0'; point++) { + if (*point == ' ') + continue; + if (*point == '\t') + continue; + if (*point == '=') + continue; + if (*point == '(') + continue; + if (*point == ')') + continue; + if (*point == ',') + continue; + break; + } + + /* mark beginning of token */ + *line = point; + + /* now find all good characters up to next occurance of a + separation character. INPgetNetTok is very liberal about + what it accepts. */ + signstate = 0; + for (point = *line; *point != '\0'; point++) { + if (*point == ' ') + break; + if (*point == '\t') + break; + if (*point == '\r') + break; + if (*point == '=') + break; + if (*point == ',') + break; + } + + /* now copy found token into *token */ + if (point == *line && *point) /* Weird items, 1 char */ + point++; + *token = (char *) MALLOC(1 + point - *line); + if (!*token) + return (E_NOMEM); + (void) strncpy(*token, *line, point - *line); + *(*token + (point - *line)) = '\0'; + *line = point; + + /* gobble garbage to next token */ + for (; **line != '\0'; (*line)++) { + if (**line == ' ') + continue; + if (**line == '\t') + continue; + if (**line == '\r') + continue; + if ((**line == '=') && gobble) + continue; + if ((**line == ',') && gobble) + continue; + break; + } + /* debug statement */ + /* printf("found netname token (%s) and rest of line (%s)\n", *token, *line); */ + return (OK); +} + + + +/*------------------------------------------------------------------- + * INPgetUTok -- this fcn extracts an input refdes token from + * 'line' and returns a pointer to it in 'token'. + *------------------------------------------------------------------*/ int INPgetUTok(char **line, char **token, int gobble) - - /* eat non-whitespace trash AFTER token? */ { char *point, separator; @@ -217,6 +313,7 @@ int INPgetUTok(char **line, char **token, int gobble) break; } *line = point; - /* printf("found token (%s) and rest of line (%s)\n",*token,*line); */ + /* debug statement */ + /* printf("found refdes token (%s) and rest of line (%s)\n",*token,*line); */ return (OK); } diff --git a/src/spicelib/parser/inplkmod.c b/src/spicelib/parser/inplkmod.c index d1c534bab..ebd77a542 100644 --- a/src/spicelib/parser/inplkmod.c +++ b/src/spicelib/parser/inplkmod.c @@ -13,7 +13,11 @@ Author: 1985 Thomas L. Quarles extern INPmodel *modtab; - +/*----------------------------------------------------------------- + * This fcn accepts a pointer to the model name, and returns 1 if + * the model exists in the model table, and returns 0 if hte model + * doesn't exist in the model table. + *----------------------------------------------------------------*/ int INPlookMod(char *name) { register INPmodel **i; diff --git a/src/spicelib/parser/inpmkmod.c b/src/spicelib/parser/inpmkmod.c index a9b9705d3..eff8626ca 100644 --- a/src/spicelib/parser/inpmkmod.c +++ b/src/spicelib/parser/inpmkmod.c @@ -11,25 +11,40 @@ Author: 1985 Thomas L. Quarles INPmodel *modtab; - /* create/lookup a 'model' entry */ +/*-------------------------------------------------------------- + * This fcn takes the model name and looks to see if it is already + * in the model table. If it is, then just return. Otherwise, + * stick the model into the model table. + * Note that the model table INPmodel + *--------------------------------------------------------------*/ int INPmakeMod(char *token, int type, card * line) { register INPmodel **i; + /* First cycle through model table and see if model name + already exists in there. If it does, just return. */ for (i = &modtab; *i != (INPmodel *) NULL; i = &((*i)->INPnextModel)) { if (strcmp((*i)->INPmodName, token) == 0) { return (OK); } } + + /* Model name was not already in model table. Therefore stick + it in the model table. Then reutrn. */ *i = (INPmodel *) MALLOC(sizeof(INPmodel)); if (*i == NULL) - return (E_NOMEM); - (*i)->INPmodName = token; - (*i)->INPmodType = type; - (*i)->INPnextModel = (INPmodel *) NULL; - (*i)->INPmodUsed = 0; - (*i)->INPmodLine = line; + return (E_NOMEM); + + (*i)->INPmodName = token; /* model name */ + (*i)->INPmodType = type; /* model type */ + (*i)->INPnextModel = (INPmodel *) NULL; /* pointer to next model (end of list) */ + (*i)->INPmodUsed = 0; /* model is unused */ + (*i)->INPmodLine = line; /* model line */ (*i)->INPmodfast = NULL; return (OK); } + + + + diff --git a/src/spicelib/parser/inppas1.c b/src/spicelib/parser/inppas1.c index 596df381b..9d8f77d28 100644 --- a/src/spicelib/parser/inppas1.c +++ b/src/spicelib/parser/inppas1.c @@ -29,6 +29,13 @@ void INPpas1(void *ckt, card * deck, INPtables * tab) if (*thisline == '.') { if (strncmp(thisline, ".model", 6) == 0) { + /* First check to see if model is multi-line. If so, + read in all lines & stick them into tab. */ + + /* debug statement */ + /* printf("In INPpas1, about to call INPdomodel\n"); */ + + /* Now invoke INPdomodel to stick model into model table. */ temp = INPdomodel(ckt, current, tab); current->error = INPerrCat(current->error, temp); } diff --git a/src/tcl/ChangeLog b/src/tcl/ChangeLog index a7de44579..b79826225 100755 --- a/src/tcl/ChangeLog +++ b/src/tcl/ChangeLog @@ -1,3 +1,8 @@ +14/04/2003: + * loadsnap / savesnap commands added + * Improved spice Tcl GUI + * Net name and CR fix by Stuart Brorson + * stdout now gets redirected to Tcl in the tclmodule 25/07/2002: * Modified configure/Makefiles so use --enable-tcl to make module * Added option --enable-cluster to configure for cluster version