diff --git a/src/include/ngspice/wordlist.h b/src/include/ngspice/wordlist.h index 5273973fc..930b6df00 100644 --- a/src/include/ngspice/wordlist.h +++ b/src/include/ngspice/wordlist.h @@ -31,6 +31,8 @@ void wl_append_word(wordlist **first, wordlist **last, char *word); wordlist *wl_chop(wordlist *wlist); wordlist *wl_chop_rest(wordlist *wlist); +wordlist *wl_find(const char *string, wordlist *wlist); + /* For quoting individual characters. '' strings are all quoted, but * `` and "" strings are maintained as single words with the quotes diff --git a/src/misc/wlist.c b/src/misc/wlist.c index 822534e4f..0701eab0e 100644 --- a/src/misc/wlist.c +++ b/src/misc/wlist.c @@ -353,3 +353,17 @@ wl_chop_rest(wordlist *wl) rest->wl_prev = NULL; return rest; } + + +/* + * search for a string in a wordlist + */ + +wordlist * +wl_find(const char *string, wordlist *wl) +{ + for (; wl; wl = wl->wl_next) + if (eq(string, wl->wl_word)) + break; + return wl; +}