Fix simpleMatch when pattern only contain one word

This commit is contained in:
Nicolas Le Cam 2008-12-22 08:20:25 +00:00
parent 3234322758
commit ad73e517a4
1 changed files with 2 additions and 1 deletions

View File

@ -137,7 +137,8 @@ int TOKEN::multiCompare( const char *needle, const char *haystack )
bool TOKEN::simpleMatch(const TOKEN *tok, const char pattern[])
{
for ( const char *current = pattern, *next = strchr(pattern, ' '), *tmp; *current; current = next,
for ( const char *current = pattern, *tmp = strchr(pattern, ' '), *next = tmp ? tmp : (pattern + strlen(pattern));
*current; current = next,
next = *next ? ((tmp = strchr(++current, ' ')) ? tmp : (current + strlen(current))) : next, tok = tok->next() )
{
if ( !tok || (next-current) != tok->_str.length() || strncmp( current, tok->_cstr, next-current) )