implement wl_delete_slice()

This commit is contained in:
rlar 2012-07-29 10:17:09 +02:00
parent d793dd6a61
commit cdef8aa10e
2 changed files with 29 additions and 0 deletions

View File

@ -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

View File

@ -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);
}