Formatting: demux simpleMatch for readability
This commit is contained in:
parent
a303cf278d
commit
14e89fa887
25
token.cpp
25
token.cpp
|
@ -137,13 +137,30 @@ 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, *tmp = strchr(pattern, ' '), *next = tmp ? tmp : (pattern + strlen(pattern));
|
const char *current, *next;
|
||||||
*current; current = next,
|
|
||||||
next = *next ? ((tmp = strchr(++current, ' ')) ? tmp : (current + strlen(current))) : next, tok = tok->next() )
|
current = pattern;
|
||||||
|
next = strchr(pattern, ' ');
|
||||||
|
if ( !next )
|
||||||
|
next = pattern + strlen(pattern);
|
||||||
|
|
||||||
|
while ( *current )
|
||||||
{
|
{
|
||||||
if ( !tok || static_cast<size_t>(next-current) != tok->_str.length() || strncmp( current, tok->_cstr, next-current) )
|
size_t length = static_cast<size_t>(next-current);
|
||||||
|
|
||||||
|
if ( !tok || length != tok->_str.length() || strncmp(current, tok->_cstr, length) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
current = next;
|
||||||
|
if ( *next )
|
||||||
|
{
|
||||||
|
next = strchr(++current, ' ');
|
||||||
|
if ( !next )
|
||||||
|
next = current + strlen(current);
|
||||||
|
}
|
||||||
|
tok = tok->next();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue