Library: Change range operator in validation pattern to ':'

This commit is contained in:
Daniel Marjamäki 2014-06-08 18:12:11 +02:00
parent 228d67cf05
commit 42c3b3c89d
6 changed files with 96 additions and 78 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<def>
<function name="usleep"> <noreturn>false</noreturn> <arg nr="1"><not-bool/><valid>0-999999</valid></arg> </function>
<function name="usleep"> <noreturn>false</noreturn> <arg nr="1"><not-bool/><valid>0:999999</valid></arg> </function>
<function name="_exit"> <noreturn>true</noreturn> </function>
<function name="closedir"> <noreturn>false</noreturn> <arg nr="1"><not-bool/><not-uninit/><not-null/></arg> </function>

View File

@ -32,7 +32,7 @@
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-uninit/><not-bool/><valid>0-</valid></arg>
<arg nr="2"><not-uninit/><not-bool/><valid>0:</valid></arg>
<arg nr="3"><not-null/><not-uninit/></arg>
</function>
<function name="floor"><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-null/><not-uninit/></arg></function>
@ -42,7 +42,7 @@
<function name="fputc">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-uninit/><not-bool/><valid>0-</valid></arg>
<arg nr="1"><not-uninit/><not-bool/><valid>0:</valid></arg>
<arg nr="2"><not-null/><not-uninit/></arg>
</function>
<function name="fputs">
@ -95,7 +95,7 @@
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-uninit/><not-bool/><valid>0-</valid></arg>
<arg nr="2"><not-uninit/><not-bool/><valid>0:</valid></arg>
<arg nr="3"><not-null/><not-uninit/></arg>
</function>
<function name="ftell">
@ -115,18 +115,18 @@
<function name="getenv"><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-null/><not-uninit/></arg></function>
<function name="gets"><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-null/></arg></function>
<function name="gmtime"><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-null/><not-uninit/></arg></function>
<function name="isalnum"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0-255</valid></arg> </function>
<function name="isalpha"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0-255</valid></arg> </function>
<function name="isblank"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0-255</valid></arg> </function>
<function name="iscntrl"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0-255</valid></arg> </function>
<function name="isdigit"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0-255</valid></arg> </function>
<function name="isgraph"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0-255</valid></arg> </function>
<function name="islower"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0-255</valid></arg> </function>
<function name="isprint"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0-255</valid></arg> </function>
<function name="ispunct"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0-255</valid></arg> </function>
<function name="isspace"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0-255</valid></arg> </function>
<function name="isupper"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0-255</valid></arg> </function>
<function name="isxdigit"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0-255</valid></arg> </function>
<function name="isalnum"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="isalpha"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="isblank"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="iscntrl"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="isdigit"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="isgraph"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="islower"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="isprint"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="ispunct"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="isspace"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="isupper"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="isxdigit"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="labs"><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-null/><not-uninit/></arg></function>
<function name="ldexp">
<noreturn>false</noreturn>
@ -154,36 +154,36 @@
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/><not-uninit/></arg>
<arg nr="2"><not-uninit/><not-bool/><valid>0-</valid></arg>
<arg nr="3"><not-bool/><valid>0-</valid></arg>
<arg nr="2"><not-uninit/><not-bool/><valid>0:</valid></arg>
<arg nr="3"><not-bool/><valid>0:</valid></arg>
</function>
<function name="memcmp">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/><not-uninit/></arg>
<arg nr="2"><not-null/><not-uninit/></arg>
<arg nr="3"><not-bool/><valid>0-</valid></arg>
<arg nr="3"><not-bool/><valid>0:</valid></arg>
</function>
<function name="memcpy">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-null/><not-uninit/></arg>
<arg nr="3"><not-bool/><valid>0-</valid></arg>
<arg nr="3"><not-bool/><valid>0:</valid></arg>
</function>
<function name="memmove">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-null/><not-uninit/></arg>
<arg nr="3"><not-bool/><valid>0-</valid></arg>
<arg nr="3"><not-bool/><valid>0:</valid></arg>
</function>
<function name="memset">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-uninit/></arg>
<arg nr="3"><not-bool/><valid>0-</valid></arg>
<arg nr="3"><not-bool/><valid>0:</valid></arg>
</function>
<function name="mktime"><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-null/><not-uninit/></arg></function>
<function name="modf">
@ -206,18 +206,18 @@
<function name="putc">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/><not-uninit/><not-bool/><valid>0-</valid></arg>
<arg nr="1"><not-null/><not-uninit/><not-bool/><valid>0:</valid></arg>
<arg nr="2"><not-null/><not-uninit/></arg>
</function>
<function name="putchar">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-uninit/><not-bool/><valid>0-</valid></arg>
<arg nr="1"><not-uninit/><not-bool/><valid>0:</valid></arg>
</function>
<function name="puts">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/><not-uninit/><not-bool/><valid>0-</valid></arg>
<arg nr="1"><not-null/><not-uninit/><not-bool/><valid>0:</valid></arg>
</function>
<function name="realloc"><noreturn>false</noreturn><arg nr="2"><not-uninit/></arg></function>
<function name="remove"><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-null/><not-uninit/></arg></function>
@ -260,25 +260,25 @@
<function name="strcpy"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><not-null/></arg> <arg nr="2"><not-null/><not-uninit/></arg> </function>
<function name="strdup"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> </function>
<function name="strlen"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> </function>
<function name="strncpy"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><not-null/></arg> <arg nr="2"><not-null/><not-uninit/></arg> <arg nr="3"><not-bool/><valid>0-</valid></arg> </function>
<function name="strncat"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="2"><not-null/><not-uninit/></arg> <arg nr="3"><not-bool/><valid>0-</valid></arg> </function>
<function name="strncmp"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="2"><not-null/><not-uninit/></arg> <arg nr="3"><not-bool/><valid>0-</valid></arg> </function>
<function name="strncpy"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><not-null/></arg> <arg nr="2"><not-null/><not-uninit/></arg> <arg nr="3"><not-bool/><valid>0:</valid></arg> </function>
<function name="strncat"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="2"><not-null/><not-uninit/></arg> <arg nr="3"><not-bool/><valid>0:</valid></arg> </function>
<function name="strncmp"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="2"><not-null/><not-uninit/></arg> <arg nr="3"><not-bool/><valid>0:</valid></arg> </function>
<function name="strstr"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="2"><not-null/><not-uninit/></arg> </function>
<function name="strspn"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="2"><not-null/><not-uninit/></arg> </function>
<function name="strerror"> <noreturn>false</noreturn> <leak-ignore/></function>
<function name="strcspn"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="2"><not-null/><not-uninit/></arg> </function>
<function name="strcoll"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="2"><not-null/><not-uninit/></arg> </function>
<function name="strtol"> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="3"><valid>0,2-36</valid></arg> </function>
<function name="strtoll"> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="3"><valid>0,2-36</valid></arg> </function>
<function name="strtoul"> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="3"><valid>0,2-36</valid></arg> </function>
<function name="strtoull"> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="3"><valid>0,2-36</valid></arg> </function>
<function name="tolower"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0-255</valid></arg> </function>
<function name="toupper"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0-255</valid></arg> </function>
<function name="wcstol"> <leak-ignore/> <arg nr="3"><valid>0,2-36</valid></arg> </function>
<function name="wcstoll"> <leak-ignore/> <arg nr="3"><valid>0,2-36</valid></arg> </function>
<function name="wcstoul"> <leak-ignore/> <arg nr="3"><valid>0,2-36</valid></arg> </function>
<function name="wcstoull"> <leak-ignore/> <arg nr="3"><valid>0,2-36</valid></arg> </function>
<function name="strtol"> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="3"><valid>0,2:36</valid></arg> </function>
<function name="strtoll"> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="3"><valid>0,2:36</valid></arg> </function>
<function name="strtoul"> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="3"><valid>0,2:36</valid></arg> </function>
<function name="strtoull"> <leak-ignore/> <arg nr="1"><not-null/><not-uninit/></arg> <arg nr="3"><valid>0,2:36</valid></arg> </function>
<function name="tolower"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="toupper"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="wcstol"> <leak-ignore/> <arg nr="3"><valid>0,2:36</valid></arg> </function>
<function name="wcstoll"> <leak-ignore/> <arg nr="3"><valid>0,2:36</valid></arg> </function>
<function name="wcstoul"> <leak-ignore/> <arg nr="3"><valid>0,2:36</valid></arg> </function>
<function name="wcstoull"> <leak-ignore/> <arg nr="3"><valid>0,2:36</valid></arg> </function>
<function name="wprintf"> <noreturn>false</noreturn> <formatstr/> <arg nr="1"><formatstr/></arg> </function>

View File

@ -185,41 +185,41 @@
<leak-ignore/>
<arg nr="1"><not-null/><not-uninit/></arg>
<arg nr="2"><not-null/><not-uninit/></arg>
<arg nr="3"><not-bool/><valid>0-</valid></arg>
<arg nr="3"><not-bool/><valid>0:</valid></arg>
</function>
<function name="RtlCopyBytes">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-null/><not-uninit/></arg>
<arg nr="3"><not-bool/><valid>0-</valid></arg>
<arg nr="3"><not-bool/><valid>0:</valid></arg>
</function>
<function name="RtlCopyMemory">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-null/><not-uninit/></arg>
<arg nr="3"><not-bool/><valid>0-</valid></arg>
<arg nr="3"><not-bool/><valid>0:</valid></arg>
</function>
<function name="RtlEqualMemory">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/><not-uninit/></arg>
<arg nr="2"><not-null/><not-uninit/></arg>
<arg nr="3"><not-bool/><valid>0-</valid></arg>
<arg nr="3"><not-bool/><valid>0:</valid></arg>
</function>
<function name="RtlFillBytes">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-bool/><valid>0-</valid></arg>
<arg nr="2"><not-bool/><valid>0:</valid></arg>
<arg nr="3"><not-uninit/></arg>
</function>
<function name="RtlFillMemory">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-bool/><valid>0-</valid></arg>
<arg nr="2"><not-bool/><valid>0:</valid></arg>
<arg nr="3"><not-uninit/></arg>
</function>
<function name="RtlMoveMemory">
@ -227,25 +227,25 @@
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-null/><not-uninit/></arg>
<arg nr="3"><not-bool/><valid>0-</valid></arg>
<arg nr="3"><not-bool/><valid>0:</valid></arg>
</function>
<function name="RtlSecureZeroMemory">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-bool/><valid>0-</valid></arg>
<arg nr="2"><not-bool/><valid>0:</valid></arg>
</function>
<function name="RtlZeroBytes">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-bool/><valid>0-</valid></arg>
<arg nr="2"><not-bool/><valid>0:</valid></arg>
</function>
<function name="RtlZeroMemory">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-bool/><valid>0-</valid></arg>
<arg nr="2"><not-bool/><valid>0:</valid></arg>
</function>
<function name="CopyMemory">
@ -253,13 +253,13 @@
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-null/><not-uninit/></arg>
<arg nr="3"><not-bool/><valid>0-</valid></arg>
<arg nr="3"><not-bool/><valid>0:</valid></arg>
</function>
<function name="FillMemory">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-bool/><valid>0-</valid></arg>
<arg nr="2"><not-bool/><valid>0:</valid></arg>
<arg nr="3"><not-uninit/></arg>
</function>
<function name="MoveMemory">
@ -267,19 +267,19 @@
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-null/><not-uninit/></arg>
<arg nr="3"><not-bool/><valid>0-</valid></arg>
<arg nr="3"><not-bool/><valid>0:</valid></arg>
</function>
<function name="SecureZeroMemory">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-bool/><valid>0-</valid></arg>
<arg nr="2"><not-bool/><valid>0:</valid></arg>
</function>
<function name="ZeroMemory">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/></arg>
<arg nr="2"><not-bool/><valid>0-</valid></arg>
<arg nr="2"><not-bool/><valid>0:</valid></arg>
</function>
<function name="KeBugCheck">

View File

@ -181,19 +181,24 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
else if (strcmp(argnode->Name(), "valid") == 0) {
// Validate the validation expression
const char *p = argnode->GetText();
if (*p == '-')
++p;
if (!std::isdigit(*p))
return Error(BAD_ATTRIBUTE_VALUE, argnode->GetText());
bool error = false;
bool range = false;
for (; *p; p++) {
if (std::isdigit(*p))
continue;
if (*p == '-' && std::isdigit(*(p-1)))
continue;
if (*p == ',' && *(p+1) != ',')
continue;
return Error(BAD_ATTRIBUTE_VALUE, argnode->GetText());
error |= (*(p+1) == '-');
else if (*p == ':')
error |= range;
else if (*p == '-')
error |= (!std::isdigit(*(p+1)));
else if (*p == ',')
range = false;
else
error = true;
range |= (*p == ':');
}
if (error)
return Error(BAD_ATTRIBUTE_VALUE, argnode->GetText());
// Set validation expression
valid = argnode->GetText();
@ -337,18 +342,20 @@ bool Library::isargvalid(const std::string &functionName, int argnr, const MathL
TokenList tokenList(0);
std::istringstream istr(ac->valid + ',');
tokenList.createTokens(istr,"");
if (Token::Match(tokenList.front(), "- %num% -")) {
tokenList.front()->str("-" + tokenList.front()->strAt(1));
tokenList.front()->deleteNext();
for (Token *tok = tokenList.front(); tok; tok = tok->next()) {
if (Token::Match(tok,"- %num%")) {
tok->str("-" + tok->strAt(1));
tok->deleteNext();
}
}
for (const Token *tok = tokenList.front(); tok; tok = tok->next()) {
if (tok->isNumber() && argvalue == MathLib::toLongNumber(tok->str()))
return true;
if (Token::Match(tok, "%num% - %num%") && argvalue >= MathLib::toLongNumber(tok->str()) && argvalue <= MathLib::toLongNumber(tok->strAt(2)))
if (Token::Match(tok, "%num% : %num%") && argvalue >= MathLib::toLongNumber(tok->str()) && argvalue <= MathLib::toLongNumber(tok->strAt(2)))
return true;
if (Token::Match(tok, "%num% - ,") && argvalue >= MathLib::toLongNumber(tok->str()))
if (Token::Match(tok, "%num% : ,") && argvalue >= MathLib::toLongNumber(tok->str()))
return true;
if ((!tok->previous() || tok->previous()->str() == ",") && Token::Match(tok,"- %num%") && argvalue <= MathLib::toLongNumber(tok->strAt(1)))
if ((!tok->previous() || tok->previous()->str() == ",") && Token::Match(tok,": %num%") && argvalue <= MathLib::toLongNumber(tok->strAt(1)))
return true;
}
return false;

View File

@ -112,9 +112,11 @@ private:
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"foo\">\n"
" <arg nr=\"1\"><valid>1-</valid></arg>\n"
" <arg nr=\"2\"><valid>-7-0</valid></arg>\n"
" <arg nr=\"3\"><valid>1-5,8</valid></arg>\n"
" <arg nr=\"1\"><valid>1:</valid></arg>\n"
" <arg nr=\"2\"><valid>-7:0</valid></arg>\n"
" <arg nr=\"3\"><valid>1:5,8</valid></arg>\n"
" <arg nr=\"4\"><valid>-1,5</valid></arg>\n"
" <arg nr=\"5\"><valid>:1,5</valid></arg>\n"
" </function>\n"
"</def>";
tinyxml2::XMLDocument doc;
@ -145,6 +147,15 @@ private:
ASSERT_EQUALS(false, library.isargvalid("foo", 3, 7));
ASSERT_EQUALS(true, library.isargvalid("foo", 3, 8));
ASSERT_EQUALS(false, library.isargvalid("foo", 3, 9));
// -1,5
ASSERT_EQUALS(false, library.isargvalid("foo", 4, -10));
ASSERT_EQUALS(true, library.isargvalid("foo", 4, -1));
// :1,5
ASSERT_EQUALS(true, library.isargvalid("foo", 5, -10));
ASSERT_EQUALS(true, library.isargvalid("foo", 5, 1));
ASSERT_EQUALS(false, library.isargvalid("foo", 5, 2));
}
void memory() const {

View File

@ -219,7 +219,7 @@ private:
if (posix) {
const char cfg[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"usleep\"> <arg nr=\"1\"><valid>0-999999</valid></arg> </function>\n"
" <function name=\"usleep\"> <arg nr=\"1\"><valid>0:999999</valid></arg> </function>\n"
"</def>";
tinyxml2::XMLDocument xmldoc;
xmldoc.Parse(cfg, sizeof(cfg));
@ -768,7 +768,7 @@ private:
const char cfg[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"memset\"> <arg nr=\"3\"><not-bool/></arg> </function>\n"
" <function name=\"strtol\"> <arg nr=\"3\"><valid>0,2-36</valid></arg> </function>\n"
" <function name=\"strtol\"> <arg nr=\"3\"><valid>0,2:36</valid></arg> </function>\n"
"</def>";
tinyxml2::XMLDocument xmldoc;
xmldoc.Parse(cfg, sizeof(cfg));
@ -794,10 +794,10 @@ private:
TODO_ASSERT_EQUALS("error", "", errout.str());
invalidFunctionUsage("int f() { strtol(a,b,sizeof(a)!=12); }");
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid strtol() argument nr 3. The value is 0 or 1 (comparison result) but the valid values are '0,2-36'.\n", errout.str());
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid strtol() argument nr 3. The value is 0 or 1 (comparison result) but the valid values are '0,2:36'.\n", errout.str());
invalidFunctionUsage("int f() { strtol(a,b,1); }");
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid strtol() argument nr 3. The value is 1 but the valid values are '0,2-36'.\n", errout.str());
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid strtol() argument nr 3. The value is 1 but the valid values are '0,2:36'.\n", errout.str());
invalidFunctionUsage("int f() { strtol(a,b,10); }");
ASSERT_EQUALS("", errout.str());
@ -7156,12 +7156,12 @@ private:
check("void f(){\n"
"usleep(1000000);\n"
"}",nullptr,false,false,true);
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid usleep() argument nr 1. The value is 1000000 but the valid values are '0-999999'.\n", errout.str());
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid usleep() argument nr 1. The value is 1000000 but the valid values are '0:999999'.\n", errout.str());
check("void f(){\n"
"usleep(1000001);\n"
"}",nullptr,false,false,true);
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid usleep() argument nr 1. The value is 1000001 but the valid values are '0-999999'.\n", errout.str());
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid usleep() argument nr 1. The value is 1000001 but the valid values are '0:999999'.\n", errout.str());
}
void checkCommaSeparatedReturn() {