implement wl_find()

This commit is contained in:
rlar 2012-07-28 12:28:15 +02:00
parent 60398d113c
commit e2be942b72
2 changed files with 16 additions and 0 deletions

View File

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

View File

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