diff --git a/src/frontend/com_alias.c b/src/frontend/com_alias.c index 11fe98e44..9835cd898 100644 --- a/src/frontend/com_alias.c +++ b/src/frontend/com_alias.c @@ -66,15 +66,13 @@ cp_doalias(wordlist *wlist) int ntries; wordlist *end, *nextc; - if (eq(comm->wl_word, cp_csep)) { + nextc = wl_find(cp_csep, comm); + + if(nextc == comm) { /* skip leading `;' */ comm = comm->wl_next; continue; } - for (nextc = comm; nextc; nextc = nextc->wl_next) - if (eq(nextc->wl_word, cp_csep)) - break; - /* Temporarily hide the rest of the command... */ end = comm->wl_prev; wl_chop(comm); diff --git a/src/frontend/control.c b/src/frontend/control.c index 9bb8ae901..7dfc9af5a 100644 --- a/src/frontend/control.c +++ b/src/frontend/control.c @@ -163,15 +163,13 @@ docommand(wordlist *wlist) struct comm *command; wordlist *nextc, *ee; - if (eq(wlist->wl_word, cp_csep)) { + nextc = wl_find(cp_csep, wlist); + + if (nextc == wlist) { /* skip leading `;' */ wlist = wlist->wl_next; continue; } - for (nextc = wlist; nextc; nextc = nextc->wl_next) - if (eq(nextc->wl_word, cp_csep)) - break; - /* Temporarily hide the rest of the command... */ ee = wlist->wl_prev; wl_chop(nextc); diff --git a/src/frontend/device.c b/src/frontend/device.c index c09b07ff6..ae4816898 100644 --- a/src/frontend/device.c +++ b/src/frontend/device.c @@ -994,9 +994,7 @@ old_show(wordlist *wl) } devs = tw; - for (tw = parms; tw; tw = tw->wl_next) - if (eq(tw->wl_word, "all")) - break; + tw = wl_find("all", parms); if (tw) parms = NULL; diff --git a/src/frontend/plotting/plotit.c b/src/frontend/plotting/plotit.c index da3e40e19..3d6d2bcd4 100644 --- a/src/frontend/plotting/plotit.c +++ b/src/frontend/plotting/plotit.c @@ -38,9 +38,7 @@ getlims(wordlist *wl, char *name, int number) if(number < 1) return NULL; - for (beg = wl; beg; beg = beg->wl_next) - if (eq(beg->wl_word, name)) - break; + beg = wl_find(name, wl); if(!beg) return NULL; @@ -197,9 +195,7 @@ compress(struct dvec *d, double *xcomp, double *xind) static bool getflag(wordlist *wl, char *name) { - for (; wl; wl = wl->wl_next) - if (eq(wl->wl_word, name)) - break; + wl = wl_find(name, wl); if (!wl) return FALSE; @@ -221,9 +217,7 @@ getword(wordlist *wl, char *name) wordlist *beg; char *s; - for (beg = wl; beg; beg = beg->wl_next) - if (eq(beg->wl_word, name)) - break; + wl = wl_find(name, wl); if (!beg) return NULL; diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index 97a1e4c62..db1d5b39b 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -1601,13 +1601,9 @@ numnodes(char *name, struct subs *subs, wordlist const *modnames) /* Now, is this a model? */ t = gettok(&s); - for (wl = modnames; wl; wl = wl->wl_next) - if (eq(t, wl->wl_word)) { - tfree(t); - return (3); - } + wl = wl_find(t, modnames); tfree(t); - return (4); + return wl ? 3 : 4; } @@ -1788,19 +1784,11 @@ devmodtranslate(struct line *deck, char *subname, wordlist * const submod) } /* while */ - /* Now, is name a subcircuit model? - * Note that we compare against submod = untranslated names of models. + /* + * Note that we compare against submod, + * which is the list of untranslated names of models. */ - for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) { - -#ifdef TRACE - /* SDB debug statement */ - printf("In devmodtranslate, comparing model name against submod list item %s\n", wlsub->wl_word ); -#endif - - if (eq(name, wlsub->wl_word)) - break; - } + wlsub = wl_find(name, submod); if (!wlsub) (void) sprintf(buffer + strlen(buffer), "%s ", name); @@ -1835,10 +1823,7 @@ devmodtranslate(struct line *deck, char *subname, wordlist * const submod) if (*t) { /* if there is a model, process it. . . . */ name = gettok(&t); - /* Now, is this a subcircuit model? */ - for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) - if (eq(name, wlsub->wl_word)) - break; + wlsub = wl_find(name, submod); if (!wlsub) (void) sprintf(buffer + strlen(buffer), "%s ", name); @@ -1849,10 +1834,7 @@ devmodtranslate(struct line *deck, char *subname, wordlist * const submod) if (*t) { name = gettok(&t); - /* Now, is this a subcircuit model? */ - for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) - if (eq(name, wlsub->wl_word)) - break; + wlsub = wl_find(name, submod); if (!wlsub) (void) sprintf(buffer + strlen(buffer), "%s ", name); @@ -1878,10 +1860,7 @@ devmodtranslate(struct line *deck, char *subname, wordlist * const submod) tfree(name); name = gettok(&t); - /* Now, is this a subcircuit model? */ - for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) - if (eq(name, wlsub->wl_word)) - break; + wlsub = wl_find(name, submod); if (!wlsub) (void) sprintf(buffer + strlen(buffer), "%s ", name); @@ -1896,17 +1875,13 @@ devmodtranslate(struct line *deck, char *subname, wordlist * const submod) #if ADMS >= 3 case 'u': /* urc transmissionline */ /* hijacked for adms */ name = gettok_node(&t); /* this can be either a model name or a node name. */ - for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) - if (eq(name, wlsub->wl_word)) /* a three terminal bjt */ - break; + wlsub = wl_find(name, submod); while (!wlsub) { (void) sprintf(buffer + strlen(buffer), "%s ", name); tfree(name); name = gettok_node(&t); /* this can be either a model name or a node name. */ - for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) - if (eq(name, wlsub->wl_word)) /* a three terminal bjt */ - break; + wlsub = wl_find(name, submod); } if (wlsub) @@ -1933,10 +1908,7 @@ devmodtranslate(struct line *deck, char *subname, wordlist * const submod) (void) sprintf(buffer + strlen(buffer), "%s ", name); name = gettok(&t); - /* Now, is this a subcircuit model? */ - for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) - if (eq(name, wlsub->wl_word)) - break; + wlsub = wl_find(name, submod); if (!wlsub) (void) sprintf(buffer + strlen(buffer), "%s ", name); @@ -2022,20 +1994,14 @@ devmodtranslate(struct line *deck, char *subname, wordlist * const submod) tfree(name); name = gettok_node(&t); /* this can be either a model name or a node name. */ - /* Now, is this a subcircuit model? */ - for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) - if (eq(name, wlsub->wl_word)) /* a three terminal bjt */ - break; + wlsub = wl_find(name, submod); if (!wlsub) { if (*t) { /* There is another token - perhaps a model */ (void) sprintf(buffer + strlen(buffer), "%s ", name); tfree(name); name = gettok(&t); - /* Now, is this a subcircuit model? */ - for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) - if (eq(name, wlsub->wl_word)) /* a four terminal bjt */ - break; + wlsub = wl_find(name, submod); } } @@ -2045,10 +2011,7 @@ devmodtranslate(struct line *deck, char *subname, wordlist * const submod) (void) sprintf(buffer + strlen(buffer), "%s ", name); tfree(name); name = gettok(&t); - /* Now, is this a subcircuit model? */ - for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) - if (eq(name, wlsub->wl_word)) /* a five terminal bjt */ - break; + wlsub = wl_find(name, submod); } } #endif @@ -2087,10 +2050,7 @@ devmodtranslate(struct line *deck, char *subname, wordlist * const submod) } } /* while */ - /* Now, is this a subcircuit model? */ - for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) - if (eq(name, wlsub->wl_word)) - break; + wlsub = wl_find(name, submod); if (!wlsub) (void) sprintf(buffer + strlen(buffer), "%s ", name);