Browse Source

implement wl_delete_slice()

rlar 14 years ago
parent
commit
cdef8aa10e
  1. 1
      src/include/ngspice/wordlist.h
  2. 28
      src/misc/wlist.c

1
src/include/ngspice/wordlist.h

@ -32,6 +32,7 @@ wordlist *wl_chop(wordlist *wlist);
wordlist *wl_chop_rest(wordlist *wlist);
wordlist *wl_find(const char *string, wordlist *wlist);
void wl_delete_slice(wordlist *from, wordlist *to);
/* For quoting individual characters. '' strings are all quoted, but

28
src/misc/wlist.c

@ -367,3 +367,31 @@ wl_find(const char *string, wordlist *wl)
break;
return wl;
}
/*
* delete elements from a wordlist
* from inclusive `from'
* up to exclusive `to'
*/
void
wl_delete_slice(wordlist *from, wordlist *to)
{
wordlist *prev;
if (from == to)
return;
prev = from->wl_prev;
if(prev)
prev->wl_next = to;
if (to) {
to->wl_prev->wl_next = NULL;
to->wl_prev = prev;
}
wl_free(from);
}
Loading…
Cancel
Save