Added version attribute to .cfg files (#5928)
This commit is contained in:
parent
68b26f8faa
commit
cbb8360b30
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!-- Based on http://www.nongnu.org/avr-libc/user-manual/group__avr__stdint.html -->
|
<!-- Based on http://www.nongnu.org/avr-libc/user-manual/group__avr__stdint.html -->
|
||||||
<def>
|
<def format="1">
|
||||||
<!-- stdint.h -->
|
<!-- stdint.h -->
|
||||||
<define name="__USING_MINT8" value="0"/>
|
<define name="__USING_MINT8" value="0"/>
|
||||||
<define name="__CONCATenate(left, right)" value="left ## right"/>
|
<define name="__CONCATenate(left, right)" value="left ## right"/>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!-- THIS FILE IS GENERATED AUTOMATICALLY. See https://github.com/scriptum/cppcheck-libs -->
|
<!-- THIS FILE IS GENERATED AUTOMATICALLY. See https://github.com/scriptum/cppcheck-libs -->
|
||||||
<def>
|
<def format="1">
|
||||||
<define name="g_return_if_fail(expr)" value="do{if(!(expr)){return;}}while(0)"/>
|
<define name="g_return_if_fail(expr)" value="do{if(!(expr)){return;}}while(0)"/>
|
||||||
<define name="g_return_val_if_fail(expr, val)" value="do{if(!(expr)){return val;}}while(0)"/>
|
<define name="g_return_val_if_fail(expr, val)" value="do{if(!(expr)){return val;}}while(0)"/>
|
||||||
<define name="g_return_if_reached()" value="do{return;}while(0)"/>
|
<define name="g_return_if_reached()" value="do{return;}while(0)"/>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<def>
|
<def format="1">
|
||||||
<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="_exit"> <noreturn>true</noreturn> </function>
|
||||||
<function name="closedir"> <noreturn>false</noreturn> <arg nr="1"><not-bool/><not-uninit/><not-null/></arg> </function>
|
<function name="closedir"> <noreturn>false</noreturn> <arg nr="1"><not-bool/><not-uninit/><not-null/></arg> </function>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<def>
|
<def format="1">
|
||||||
|
|
||||||
<markup ext=".qml" reporterrors="false" aftercode="true">
|
<markup ext=".qml" reporterrors="false" aftercode="true">
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<def>
|
<def format="1">
|
||||||
<function name="SDL_mutexP"> <noreturn>false</noreturn> <arg nr="1"><not-bool/><not-null/></arg> </function>
|
<function name="SDL_mutexP"> <noreturn>false</noreturn> <arg nr="1"><not-bool/><not-null/></arg> </function>
|
||||||
<function name="SDL_mutexV"> <noreturn>false</noreturn> <arg nr="1"><not-bool/><not-null/></arg> </function>
|
<function name="SDL_mutexV"> <noreturn>false</noreturn> <arg nr="1"><not-bool/><not-null/></arg> </function>
|
||||||
<function name="SDL_RWsize"> <noreturn>false</noreturn> <arg nr="1"><not-bool/><not-null/></arg> </function>
|
<function name="SDL_RWsize"> <noreturn>false</noreturn> <arg nr="1"><not-bool/><not-null/></arg> </function>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<def>
|
<def format="1">
|
||||||
<function name="abort"><noreturn>true</noreturn></function>
|
<function name="abort"><noreturn>true</noreturn></function>
|
||||||
<function name="abs"><use-retval/><pure/><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-uninit/><not-bool/></arg></function>
|
<function name="abs"><use-retval/><pure/><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-uninit/><not-bool/></arg></function>
|
||||||
<function name="acos"><use-retval/><pure/><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-uninit/></arg></function>
|
<function name="acos"><use-retval/><pure/><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-uninit/></arg></function>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<def>
|
<def format="1">
|
||||||
<resource>
|
<resource>
|
||||||
<alloc init="true">CreatePen</alloc>
|
<alloc init="true">CreatePen</alloc>
|
||||||
<alloc init="true">CreateBrushIndirect</alloc>
|
<alloc init="true">CreateBrushIndirect</alloc>
|
||||||
|
|
|
@ -531,6 +531,9 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
||||||
case Library::BAD_ATTRIBUTE_VALUE:
|
case Library::BAD_ATTRIBUTE_VALUE:
|
||||||
errmsg = "Bad attribute value";
|
errmsg = "Bad attribute value";
|
||||||
break;
|
break;
|
||||||
|
case Library::UNSUPPORTED_FORMAT:
|
||||||
|
errmsg = "File is of unsupported format version";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!err.reason.empty())
|
if (!err.reason.empty())
|
||||||
errmsg += " '" + err.reason + "'";
|
errmsg += " '" + err.reason + "'";
|
||||||
|
|
|
@ -93,6 +93,14 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
|
||||||
if (strcmp(rootnode->Name(),"def") != 0)
|
if (strcmp(rootnode->Name(),"def") != 0)
|
||||||
return Error(BAD_ELEMENT, rootnode->Name());
|
return Error(BAD_ELEMENT, rootnode->Name());
|
||||||
|
|
||||||
|
const char* format_string = rootnode->Attribute("format");
|
||||||
|
int format = 1;
|
||||||
|
if (format_string)
|
||||||
|
format = atoi(format_string);
|
||||||
|
|
||||||
|
if (format > 1)
|
||||||
|
return Error(UNSUPPORTED_FORMAT);
|
||||||
|
|
||||||
for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) {
|
for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) {
|
||||||
std::string nodename = node->Name();
|
std::string nodename = node->Name();
|
||||||
if (nodename == "memory" || nodename == "resource") {
|
if (nodename == "memory" || nodename == "resource") {
|
||||||
|
|
|
@ -46,7 +46,7 @@ class CPPCHECKLIB Library {
|
||||||
public:
|
public:
|
||||||
Library();
|
Library();
|
||||||
|
|
||||||
enum ErrorCode { OK, FILE_NOT_FOUND, BAD_XML, BAD_ELEMENT, MISSING_ATTRIBUTE, BAD_ATTRIBUTE, BAD_ATTRIBUTE_VALUE };
|
enum ErrorCode { OK, FILE_NOT_FOUND, BAD_XML, BAD_ELEMENT, MISSING_ATTRIBUTE, BAD_ATTRIBUTE, BAD_ATTRIBUTE_VALUE, UNSUPPORTED_FORMAT };
|
||||||
|
|
||||||
class Error {
|
class Error {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -39,6 +39,7 @@ private:
|
||||||
TEST_CASE(memory2); // define extra "free" allocation functions
|
TEST_CASE(memory2); // define extra "free" allocation functions
|
||||||
TEST_CASE(resource);
|
TEST_CASE(resource);
|
||||||
TEST_CASE(podtype);
|
TEST_CASE(podtype);
|
||||||
|
TEST_CASE(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
void empty() const {
|
void empty() const {
|
||||||
|
@ -274,6 +275,42 @@ private:
|
||||||
ASSERT_EQUALS(2U, type ? type->size : 0U);
|
ASSERT_EQUALS(2U, type ? type->size : 0U);
|
||||||
ASSERT_EQUALS(0, type ? type->sign : '?');
|
ASSERT_EQUALS(0, type ? type->sign : '?');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void version() const {
|
||||||
|
{
|
||||||
|
const char xmldata [] = "<?xml version=\"1.0\"?>\n"
|
||||||
|
"<def>\n"
|
||||||
|
"</def>";
|
||||||
|
tinyxml2::XMLDocument doc;
|
||||||
|
doc.Parse(xmldata, sizeof(xmldata));
|
||||||
|
|
||||||
|
Library library;
|
||||||
|
Library::Error err = library.load(doc);
|
||||||
|
ASSERT_EQUALS(err.errorcode, Library::OK);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const char xmldata [] = "<?xml version=\"1.0\"?>\n"
|
||||||
|
"<def format=\"1\">\n"
|
||||||
|
"</def>";
|
||||||
|
tinyxml2::XMLDocument doc;
|
||||||
|
doc.Parse(xmldata, sizeof(xmldata));
|
||||||
|
|
||||||
|
Library library;
|
||||||
|
Library::Error err = library.load(doc);
|
||||||
|
ASSERT_EQUALS(err.errorcode, Library::OK);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const char xmldata [] = "<?xml version=\"1.0\"?>\n"
|
||||||
|
"<def format=\"42\">\n"
|
||||||
|
"</def>";
|
||||||
|
tinyxml2::XMLDocument doc;
|
||||||
|
doc.Parse(xmldata, sizeof(xmldata));
|
||||||
|
|
||||||
|
Library library;
|
||||||
|
Library::Error err = library.load(doc);
|
||||||
|
ASSERT_EQUALS(err.errorcode, Library::UNSUPPORTED_FORMAT);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestLibrary)
|
REGISTER_TEST(TestLibrary)
|
||||||
|
|
Loading…
Reference in New Issue