Fixed bug in Token::Match (#3720)
This commit is contained in:
parent
0d26a79f2c
commit
ff7373f46f
|
@ -341,7 +341,7 @@ static int multiComparePercent(const char * * haystack_p,
|
|||
{
|
||||
const char *haystack = *haystack_p;
|
||||
|
||||
if (haystack[0] == '%' && haystack[1] != '|') {
|
||||
if (haystack[0] == '%' && haystack[1] != '|' && haystack[1] != '\0' && haystack[1] != ' ') {
|
||||
if (haystack[1] == 'o' && // "%op%"
|
||||
haystack[2] == 'p' &&
|
||||
haystack[3] == '%') {
|
||||
|
@ -564,7 +564,7 @@ bool Token::Match(const Token *tok, const char pattern[], unsigned int varid)
|
|||
|
||||
// Compare the first character of the string for optimization reasons
|
||||
// before doing more detailed checks.
|
||||
if (p[0] == '%') {
|
||||
if (p[0] == '%' && p[1]!='|') {
|
||||
bool patternUnderstood = false;
|
||||
switch (p[1]) {
|
||||
case 'v':
|
||||
|
|
|
@ -166,6 +166,11 @@ private:
|
|||
|
||||
ASSERT_EQUALS(true, Token::Match(toks3.tokens(), "return %var% xyz|%oror% %var% ;"));
|
||||
ASSERT_EQUALS(true, Token::Match(toks3.tokens(), "return %var% %oror%|xyz %var% ;"));
|
||||
|
||||
givenACodeSampleToTokenize toks4("a % b ;", true);
|
||||
ASSERT_EQUALS(true, Token::Match(toks4.tokens(), "%var% >>|<<|&|%or%|^|% %var% ;"));
|
||||
ASSERT_EQUALS(true, Token::Match(toks4.tokens(), "%var% %|>>|<<|&|%or%|^ %var% ;"));
|
||||
ASSERT_EQUALS(true, Token::Match(toks4.tokens(), "%var% >>|<<|&|%or%|%|^ %var% ;"));
|
||||
}
|
||||
|
||||
void getStrLength() {
|
||||
|
|
Loading…
Reference in New Issue