Match: Added matching for []
This commit is contained in:
parent
b6868b7f1a
commit
c56cfb5305
|
@ -220,10 +220,7 @@ static void CheckBufferOverrun_CheckScope( const TOKEN *tok, const char *varname
|
||||||
par++;
|
par++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( parlevel == 1 &&
|
if ( parlevel == 1 && Match(tok2, "[(,] %var1% [,)]", varname) )
|
||||||
strchr( "(,", *getstr(tok2,0) ) &&
|
|
||||||
Match( tok2->next, "%var1%", varname ) &&
|
|
||||||
strchr( ",)", *getstr(tok2, 2+varc) ) )
|
|
||||||
{
|
{
|
||||||
par++;
|
par++;
|
||||||
break;
|
break;
|
||||||
|
@ -364,7 +361,7 @@ static void CheckBufferOverrun_StructVariable()
|
||||||
varname[0] = getstr(tok3, 1);
|
varname[0] = getstr(tok3, 1);
|
||||||
|
|
||||||
// Declare pointer: Fred *fred1
|
// Declare pointer: Fred *fred1
|
||||||
else if ( Match(tok3->next, "* %var%") && tok3->next->next->next && strchr(",);=", tok3->next->next->next->str[0]) )
|
else if ( Match(tok3->next, "* %var% [,);=]") )
|
||||||
varname[0] = getstr(tok3, 2);
|
varname[0] = getstr(tok3, 2);
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
|
@ -187,7 +187,7 @@ static void ClassChecking_VarList_Initialize(const TOKEN *ftok, struct VAR *varl
|
||||||
indentlevel--;
|
indentlevel--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strchr("{};", ftok->str[0]) && indentlevel>=1 && IsName(ftok->next->str))
|
if (indentlevel>=1 && Match(ftok, "[{};] %var%"))
|
||||||
{
|
{
|
||||||
ftok = ftok->next;
|
ftok = ftok->next;
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ static void CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const char *varname[]
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Used..
|
// Used..
|
||||||
if ( strchr("=,(", tok->str[0]) && Match( tok->next, "%var1%", varname ) )
|
if ( Match( tok, "[=,(] %var1%", varname ) )
|
||||||
return;
|
return;
|
||||||
if ( Match( tok, "return %var1%", varname ) )
|
if ( Match( tok, "return %var1%", varname ) )
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -308,6 +308,14 @@ bool Match(const TOKEN *tok, const char pattern[], const char *varname1[], const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [.. => search for a one-character token..
|
||||||
|
else if (str[0]=='[' && strchr(str, ']') && tok->str[1] == 0)
|
||||||
|
{
|
||||||
|
*strrchr(str, ']') = 0;
|
||||||
|
if ( strchr( str + 1, tok->str[0] ) == 0 )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
else if (strcmp(str, tok->str) != 0)
|
else if (strcmp(str, tok->str) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue