Fix simpleMatch when pattern only contain one word
This commit is contained in:
parent
3234322758
commit
ad73e517a4
|
@ -137,7 +137,8 @@ int TOKEN::multiCompare( const char *needle, const char *haystack )
|
||||||
|
|
||||||
bool TOKEN::simpleMatch(const TOKEN *tok, const char pattern[])
|
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() )
|
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) )
|
if ( !tok || (next-current) != tok->_str.length() || strncmp( current, tok->_cstr, next-current) )
|
||||||
|
|
Loading…
Reference in New Issue