From: JinWang An Date: Fri, 30 Oct 2020 05:30:06 +0000 (+0900) Subject: Imported Upstream version 5.0.1 X-Git-Tag: upstream/5.0.1^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78e3e26a15fe18000a4a98cc4fe7e3c6f4bedf35;p=platform%2Fupstream%2Ftinyxml2.git Imported Upstream version 5.0.1 --- diff --git a/.travis.yml b/.travis.yml index 50e9a6f..0634ccb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,4 +12,4 @@ before_script: cmake . script: - make -j3 - - ./xmltest + - make test diff --git a/CMakeLists.txt b/CMakeLists.txt index bb6a7ce..cec4470 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ endif() project(tinyxml2) include(GNUInstallDirs) +include(CTest) #enable_testing() #CMAKE_BUILD_TOOL @@ -20,7 +21,7 @@ include(GNUInstallDirs) ################################ # set lib version here -set(GENERIC_LIB_VERSION "5.0.0") +set(GENERIC_LIB_VERSION "5.0.1") set(GENERIC_LIB_SOVERSION "5") ################################ @@ -39,7 +40,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") option(BUILD_SHARED_LIBS "build as shared library" ON) option(BUILD_STATIC_LIBS "build as static library" OFF) -option(BUILD_TESTS "build xmltest" ON) +option(BUILD_TESTS "build xmltest (deprecated: Use BUILD_TESTING)" ON) set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) @@ -91,7 +92,7 @@ set_target_properties(tinyxml2_static PROPERTIES SOVERSION "${GENERIC_LIB_SOVERSION}") set_target_properties( tinyxml2_static PROPERTIES OUTPUT_NAME tinyxml2 ) -target_compile_definitions(tinyxml2 PUBLIC -D_CRT_SECURE_NO_WARNINGS) +target_compile_definitions(tinyxml2_static PUBLIC -D_CRT_SECURE_NO_WARNINGS) if(DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11") target_include_directories(tinyxml2_static PUBLIC @@ -99,7 +100,7 @@ if(DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11") $) if(MSVC) - target_compile_definitions(tinyxml2 PUBLIC -D_CRT_SECURE_NO_WARNINGS) + target_compile_definitions(tinyxml2_static PUBLIC -D_CRT_SECURE_NO_WARNINGS) endif(MSVC) else() include_directories(${PROJECT_SOURCE_DIR}) @@ -120,7 +121,7 @@ install(TARGETS tinyxml2_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() -if(BUILD_TESTS) +if(BUILD_TESTING AND BUILD_TESTS) add_executable(xmltest xmltest.cpp) if(BUILD_SHARED_LIBS) add_dependencies(xmltest tinyxml2) @@ -136,6 +137,8 @@ if(BUILD_TESTS) COMMAND ${CMAKE_COMMAND} -E make_directory $/resources/out COMMENT "Configuring xmltest resources directory: ${CMAKE_BINARY_DIR}/resources" ) + + add_test(NAME xmltest COMMAND xmltest) endif() install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) @@ -151,13 +154,15 @@ configure_file(tinyxml2.pc.in tinyxml2.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) # uninstall target -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - IMMEDIATE @ONLY) - -add_custom_target(uninstall - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) +if(NOT TARGET uninstall) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + + add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) +endif() file(WRITE ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake @@ -168,4 +173,4 @@ install(FILES DESTINATION lib/cmake/${CMAKE_PROJECT_NAME}) install(EXPORT ${CMAKE_PROJECT_NAME}Targets - DESTINATION lib/cmake/${CMAKE_PROJECT_NAME}) \ No newline at end of file + DESTINATION lib/cmake/${CMAKE_PROJECT_NAME}) diff --git a/dox b/dox index 9e27136..601feed 100644 --- a/dox +++ b/dox @@ -38,7 +38,7 @@ PROJECT_NAME = "TinyXML-2" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 5.0.0 +PROJECT_NUMBER = 5.0.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tinyxml2.cpp b/tinyxml2.cpp index b8c45e6..3043ab3 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1966,10 +1966,10 @@ const char* XMLDocument::_errorNames[XML_ERROR_COUNT] = { "XML_ERROR_FILE_NOT_FOUND", "XML_ERROR_FILE_COULD_NOT_BE_OPENED", "XML_ERROR_FILE_READ_ERROR", - "XML_ERROR_ELEMENT_MISMATCH", + "UNUSED_XML_ERROR_ELEMENT_MISMATCH", "XML_ERROR_PARSING_ELEMENT", "XML_ERROR_PARSING_ATTRIBUTE", - "XML_ERROR_IDENTIFYING_TAG", + "UNUSED_XML_ERROR_IDENTIFYING_TAG", "XML_ERROR_PARSING_TEXT", "XML_ERROR_PARSING_CDATA", "XML_ERROR_PARSING_COMMENT", @@ -2308,6 +2308,16 @@ void XMLDocument::SetError( XMLError error, const char* str1, const char* str2, return errorName; } +const char* XMLDocument::GetErrorStr1() const +{ + return _errorStr1.GetStr(); +} + +const char* XMLDocument::GetErrorStr2() const +{ + return _errorStr2.GetStr(); +} + const char* XMLDocument::ErrorName() const { return ErrorIDToName(_errorID); diff --git a/tinyxml2.h b/tinyxml2.h index dea324e..e6a0ced 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -100,7 +100,7 @@ distribution. */ static const int TIXML2_MAJOR_VERSION = 5; static const int TIXML2_MINOR_VERSION = 0; -static const int TIXML2_PATCH_VERSION = 0; +static const int TIXML2_PATCH_VERSION = 1; namespace tinyxml2 { @@ -513,10 +513,10 @@ enum XMLError { XML_ERROR_FILE_NOT_FOUND, XML_ERROR_FILE_COULD_NOT_BE_OPENED, XML_ERROR_FILE_READ_ERROR, - XML_ERROR_ELEMENT_MISMATCH, + UNUSED_XML_ERROR_ELEMENT_MISMATCH, // remove at next major version XML_ERROR_PARSING_ELEMENT, XML_ERROR_PARSING_ATTRIBUTE, - XML_ERROR_IDENTIFYING_TAG, + UNUSED_XML_ERROR_IDENTIFYING_TAG, // remove at next major version XML_ERROR_PARSING_TEXT, XML_ERROR_PARSING_CDATA, XML_ERROR_PARSING_COMMENT, @@ -1803,13 +1803,11 @@ public: static const char* ErrorIDToName(XMLError errorID); /// Return a possibly helpful diagnostic location or string. - const char* GetErrorStr1() const { - return _errorStr1.GetStr(); - } + const char* GetErrorStr1() const; + /// Return a possibly helpful secondary diagnostic location or string. - const char* GetErrorStr2() const { - return _errorStr2.GetStr(); - } + const char* GetErrorStr2() const; + /// Return the line where the error occured, or zero if unknown. int GetErrorLineNum() const { diff --git a/xmltest.cpp b/xmltest.cpp index 3ed25b8..276c61b 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -435,10 +435,10 @@ int main( int argc, const char ** argv ) XMLTest( "Programmatic DOM", true, doc->FirstChildElement()->FirstChildElement()->BoolAttribute( "attrib" ) ); int value1 = 10; int value2 = doc->FirstChildElement()->LastChildElement()->IntAttribute( "attrib", 10 ); - int result = doc->FirstChildElement()->LastChildElement()->QueryIntAttribute( "attrib", &value1 ); - XMLTest( "Programmatic DOM", result, (int)XML_NO_ATTRIBUTE ); - XMLTest( "Programmatic DOM", value1, 10 ); - XMLTest( "Programmatic DOM", value2, 10 ); + XMLError result = doc->FirstChildElement()->LastChildElement()->QueryIntAttribute( "attrib", &value1 ); + XMLTest( "Programmatic DOM", XML_NO_ATTRIBUTE, result ); + XMLTest( "Programmatic DOM", 10, value1 ); + XMLTest( "Programmatic DOM", 10, value2 ); doc->Print(); @@ -499,7 +499,7 @@ int main( int argc, const char ** argv ) XMLDocument doc; doc.Parse( error ); - XMLTest( "Bad XML", doc.ErrorID(), XML_ERROR_PARSING_ATTRIBUTE ); + XMLTest( "Bad XML", XML_ERROR_PARSING_ATTRIBUTE, doc.ErrorID() ); } { @@ -510,30 +510,31 @@ int main( int argc, const char ** argv ) XMLElement* ele = doc.FirstChildElement(); - int iVal, result; + int iVal; + XMLError result; double dVal; result = ele->QueryDoubleAttribute( "attr0", &dVal ); - XMLTest( "Query attribute: int as double", result, (int)XML_SUCCESS); - XMLTest( "Query attribute: int as double", (int)dVal, 1 ); - XMLTest( "Query attribute: int as double", (int)ele->DoubleAttribute("attr0"), 1); + XMLTest( "Query attribute: int as double", XML_SUCCESS, result); + XMLTest( "Query attribute: int as double", 1, (int)dVal ); + XMLTest( "Query attribute: int as double", 1, (int)ele->DoubleAttribute("attr0")); result = ele->QueryDoubleAttribute( "attr1", &dVal ); - XMLTest( "Query attribute: double as double", result, (int)XML_SUCCESS); - XMLTest( "Query attribute: double as double", dVal, 2.0 ); - XMLTest( "Query attribute: double as double", ele->DoubleAttribute("attr1"), 2.0 ); + XMLTest( "Query attribute: double as double", XML_SUCCESS, result); + XMLTest( "Query attribute: double as double", 2.0, dVal ); + XMLTest( "Query attribute: double as double", 2.0, ele->DoubleAttribute("attr1") ); result = ele->QueryIntAttribute( "attr1", &iVal ); - XMLTest( "Query attribute: double as int", result, (int)XML_SUCCESS); - XMLTest( "Query attribute: double as int", iVal, 2 ); + XMLTest( "Query attribute: double as int", XML_SUCCESS, result); + XMLTest( "Query attribute: double as int", 2, iVal ); result = ele->QueryIntAttribute( "attr2", &iVal ); - XMLTest( "Query attribute: not a number", result, (int)XML_WRONG_ATTRIBUTE_TYPE ); - XMLTest( "Query attribute: not a number", ele->DoubleAttribute("attr2", 4.0), 4.0 ); + XMLTest( "Query attribute: not a number", XML_WRONG_ATTRIBUTE_TYPE, result ); + XMLTest( "Query attribute: not a number", 4.0, ele->DoubleAttribute("attr2", 4.0) ); result = ele->QueryIntAttribute( "bar", &iVal ); - XMLTest( "Query attribute: does not exist", result, (int)XML_NO_ATTRIBUTE ); - XMLTest( "Query attribute: does not exist", ele->BoolAttribute("bar", true), true ); + XMLTest( "Query attribute: does not exist", XML_NO_ATTRIBUTE, result ); + XMLTest( "Query attribute: does not exist", true, ele->BoolAttribute("bar", true) ); } { @@ -558,7 +559,7 @@ int main( int argc, const char ** argv ) ele->QueryAttribute( "int", &iVal2 ); ele->QueryAttribute( "double", &dVal2 ); - XMLTest( "Attribute match test", ele->Attribute( "str", "strValue" ), "strValue" ); + XMLTest( "Attribute match test", "strValue", ele->Attribute( "str", "strValue" ) ); XMLTest( "Attribute round trip. c-string.", "strValue", cStr ); XMLTest( "Attribute round trip. int.", 1, iVal ); XMLTest( "Attribute round trip. double.", -1, (int)dVal ); @@ -796,7 +797,7 @@ int main( int argc, const char ** argv ) { XMLDocument doc; doc.LoadFile("resources/printer.xml"); - XMLTest("XMLPrinter Stream mode: load", doc.ErrorID(), XML_SUCCESS, true); + XMLTest("XMLPrinter Stream mode: load", XML_SUCCESS, doc.ErrorID(), true); const XMLDocument& cdoc = doc; @@ -829,8 +830,8 @@ int main( int argc, const char ** argv ) doc.Parse( str ); doc.Print(); - XMLTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(), - "I am > the rules!\n...since I make symbolic puns", + XMLTest( "CDATA parse.", "I am > the rules!\n...since I make symbolic puns", + doc.FirstChildElement()->FirstChild()->Value(), false ); } @@ -846,8 +847,9 @@ int main( int argc, const char ** argv ) doc.Parse( str ); doc.Print(); - XMLTest( "CDATA parse. [ tixml1:1480107 ]", doc.FirstChildElement()->FirstChild()->Value(), + XMLTest( "CDATA parse. [ tixml1:1480107 ]", "I am > the rules!\n...since I make symbolic puns", + doc.FirstChildElement()->FirstChild()->Value(), false ); } @@ -864,7 +866,7 @@ int main( int argc, const char ** argv ) XMLNode* childNode0 = parent->InsertEndChild( childText0 ); XMLNode* childNode1 = parent->InsertAfterChild( childNode0, childText1 ); - XMLTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent->LastChild() ), true ); + XMLTest( "Test InsertAfterChild on empty node. ", true, ( childNode1 == parent->LastChild() ) ); } { @@ -919,10 +921,11 @@ int main( int argc, const char ** argv ) XMLDocument doc( false ); doc.Parse( passages ); - XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->Attribute( "context" ), - "Line 5 has "quotation marks" and 'apostrophe marks'." ); - XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->FirstChild()->Value(), - "Crazy &ttk;" ); + XMLTest( "No entity parsing.", + "Line 5 has "quotation marks" and 'apostrophe marks'.", + doc.FirstChildElement()->FirstChildElement()->Attribute( "context" ) ); + XMLTest( "No entity parsing.", "Crazy &ttk;", + doc.FirstChildElement()->FirstChildElement()->FirstChild()->Value() ); doc.Print(); } @@ -931,9 +934,9 @@ int main( int argc, const char ** argv ) XMLDocument doc; doc.Parse( test ); - XMLTest( "dot in names", doc.Error(), false ); - XMLTest( "dot in names", doc.FirstChildElement()->Name(), "a.elem" ); - XMLTest( "dot in names", doc.FirstChildElement()->Attribute( "xmi.version" ), "2.0" ); + XMLTest( "dot in names", false, doc.Error() ); + XMLTest( "dot in names", "a.elem", doc.FirstChildElement()->Name() ); + XMLTest( "dot in names", "2.0", doc.FirstChildElement()->Attribute( "xmi.version" ) ); } { @@ -944,7 +947,7 @@ int main( int argc, const char ** argv ) XMLText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText(); XMLTest( "Entity with one digit.", - text->Value(), "1.1 Start easy ignore fin thickness\n", + "1.1 Start easy ignore fin thickness\n", text->Value(), false ); } @@ -1022,7 +1025,7 @@ int main( int argc, const char ** argv ) XMLDocument doc; doc.Parse( "" ); const char result[] = { 0x0e, 0 }; - XMLTest( "Low entities.", doc.FirstChildElement()->GetText(), result ); + XMLTest( "Low entities.", result, doc.FirstChildElement()->GetText() ); doc.Print(); } @@ -1030,18 +1033,18 @@ int main( int argc, const char ** argv ) // Attribute values with trailing quotes not handled correctly XMLDocument doc; doc.Parse( "" ); - XMLTest( "Throw error with bad end quotes.", doc.Error(), true ); + XMLTest( "Throw error with bad end quotes.", true, doc.Error() ); } { // [ 1663758 ] Failure to report error on bad XML XMLDocument xml; xml.Parse(""); - XMLTest("Missing end tag at end of input", xml.Error(), true); + XMLTest("Missing end tag at end of input", true, xml.Error()); xml.Parse(" "); - XMLTest("Missing end tag with trailing whitespace", xml.Error(), true); + XMLTest("Missing end tag with trailing whitespace", true, xml.Error()); xml.Parse(""); - XMLTest("Mismatched tags", xml.ErrorID(), XML_ERROR_MISMATCHED_ELEMENT); + XMLTest("Mismatched tags", XML_ERROR_MISMATCHED_ELEMENT, xml.ErrorID() ); } @@ -1286,7 +1289,7 @@ int main( int argc, const char ** argv ) doc.Parse( xml ); XMLElement* ele = XMLHandle( doc ).FirstChildElement( "element" ).FirstChild().ToElement(); - XMLTest( "Handle, success, mutable", ele->Value(), "sub" ); + XMLTest( "Handle, success, mutable", "sub", ele->Value() ); XMLHandle docH( doc ); ele = docH.FirstChildElement( "none" ).FirstChildElement( "element" ).ToElement(); @@ -1315,8 +1318,8 @@ int main( int argc, const char ** argv ) doc.Print( &printer ); static const char* result = "\xef\xbb\xbf"; - XMLTest( "BOM and default declaration", printer.CStr(), result, false ); - XMLTest( "CStrSize", printer.CStrSize(), 42, false ); + XMLTest( "BOM and default declaration", result, printer.CStr(), false ); + XMLTest( "CStrSize", 42, printer.CStrSize(), false ); } { const char* xml = "FirstChildElement("entry"); @@ -1803,7 +1806,7 @@ int main( int argc, const char ** argv ) for (const XMLElement* p = playlist->FirstChildElement("property"); p; p = p->NextSiblingElement("property")) { nProperty++; } - XMLTest("Crash bug parsing", nProperty, 2); + XMLTest("Crash bug parsing", 2, nProperty); } // ----------- Line Number Tracking --------------