Implement simpleMatch that should be use when pattern contains no flags
This commit is contained in:
parent
85e6ab5226
commit
3234322758
11
token.cpp
11
token.cpp
|
@ -135,6 +135,17 @@ int TOKEN::multiCompare( const char *needle, const char *haystack )
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TOKEN::simpleMatch(const TOKEN *tok, const char pattern[])
|
||||||
|
{
|
||||||
|
for ( const char *current = pattern, *next = strchr(pattern, ' '), *tmp; *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) )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool TOKEN::Match(const TOKEN *tok, const char pattern[], const char *varname1[], const char *varname2[], unsigned int varid)
|
bool TOKEN::Match(const TOKEN *tok, const char pattern[], const char *varname1[], const char *varname2[], unsigned int varid)
|
||||||
{
|
{
|
||||||
const char *p = pattern;
|
const char *p = pattern;
|
||||||
|
|
2
token.h
2
token.h
|
@ -54,6 +54,8 @@ public:
|
||||||
|
|
||||||
const char *strAt(int index) const;
|
const char *strAt(int index) const;
|
||||||
|
|
||||||
|
static bool simpleMatch(const TOKEN *tok, const char pattern[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match given token (or list of tokens) to a pattern list.
|
* Match given token (or list of tokens) to a pattern list.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue