implement wl_delete_slice()
This commit is contained in:
parent
d793dd6a61
commit
cdef8aa10e
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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…
Reference in New Issue