diff --git a/src/include/ngspice/wordlist.h b/src/include/ngspice/wordlist.h index 49191784b..ade2b43b5 100644 --- a/src/include/ngspice/wordlist.h +++ b/src/include/ngspice/wordlist.h @@ -25,6 +25,11 @@ wordlist * wl_nthelem(int i, wordlist *wl); void wl_sort(wordlist *wl); wordlist * wl_range(wordlist *wl, int low, int up); +wordlist *wl_cons(char *word, wordlist *tail); +void wl_append_word(wordlist **first, wordlist **last, char *word); + +wordlist *wl_chop_rest(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 973cd8d12..b61987e49 100644 --- a/src/misc/wlist.c +++ b/src/misc/wlist.c @@ -294,3 +294,45 @@ wl_range(wordlist *wl, int low, int up) return (wl); } + +wordlist * +wl_cons(char *word, wordlist *tail) +{ + wordlist *w = alloc(struct wordlist); + w->wl_next = tail; + w->wl_prev = NULL; + w->wl_word = word; + + if (tail) + tail->wl_prev = w; + + return w; +} + + +void +wl_append_word(wordlist **first, wordlist **last, char *word) +{ + wordlist *w = alloc(struct wordlist); + w->wl_next = NULL; + w->wl_prev = (*last); + w->wl_word = word; + + if (*last) + (*last)->wl_next = w; + else + (*first) = w; + + (*last) = w; +} + + +wordlist * +wl_chop_rest(wordlist *wl) +{ + wordlist *rest = wl->wl_next; + wl->wl_next = NULL; + if(rest) + rest->wl_prev = NULL; + return rest; +}