diff --git a/CMakeLists.txt b/CMakeLists.txt index c55904a82..4bcfbd129 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,7 +154,6 @@ set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") # Apply patch on submodules apply_patch(${CMAKE_CURRENT_SOURCE_DIR}/external/json) apply_patch(${CMAKE_CURRENT_SOURCE_DIR}/external/json-schema-validator) -apply_patch(${CMAKE_CURRENT_SOURCE_DIR}/external/cxxopts) apply_patch(${CMAKE_CURRENT_SOURCE_DIR}/external/xerces-c) apply_patch(${CMAKE_CURRENT_SOURCE_DIR}/external/yaml-cpp) diff --git a/LICENSE.md b/LICENSE.md index aef27cd9f..fa3d5392c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -39,8 +39,8 @@ or testing purposes. | Component | Version | License | Origin | Usage | | --------- | ------- | ------- | ------ | ----- | |Google C++ Testing Framework|1.11.0|[BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause)|https://github.com/google/googletest.git| Testing | -|cxxopts|2.2.1|[MIT](https://opensource.org/licenses/MIT)|https://github.com/jarro2783/cxxopts.git| packgen | -|yaml-cpp|0.7.0|[MIT](https://opensource.org/licenses/MIT)|https://github.com/jbeder/yaml-cpp.git| packgen | +|cxxopts|3.3.1|[MIT](https://opensource.org/licenses/MIT)|https://github.com/jarro2783/cxxopts.git| cbuildgen, ctrace, packchk, packgen, projmgr, svdconv | +|yaml-cpp|0.9.0|[MIT](https://opensource.org/licenses/MIT)|https://github.com/jbeder/yaml-cpp.git| YmlTree, YmlSchemaChecker, ctrace, packgen, projmgr | |OpenCSD|1.8.3|[BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause)|https://github.com/Linaro/OpenCSD.git| ctrace | |[GetGitRevisionDescription.cmake](./cmake/GetGitRevisionDescription.cmake)||[Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt)||Continuous integration| |[GetGitRevisionDescription.cmake.in](./cmake/GetGitRevisionDescription.cmake.in)||[Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt)||Continuous integration| diff --git a/external/cxxopts b/external/cxxopts index df229cff0..44380e5a4 160000 --- a/external/cxxopts +++ b/external/cxxopts @@ -1 +1 @@ -Subproject commit df229cff0d5b96e146f3f11441f714e8e240cad0 +Subproject commit 44380e5a44706ab7347f400698c703eb2a196202 diff --git a/external/cxxopts.patch b/external/cxxopts.patch deleted file mode 100644 index fe99ecd95..000000000 --- a/external/cxxopts.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp -index af87540..6f7b881 100644 ---- a/include/cxxopts.hpp -+++ b/include/cxxopts.hpp -@@ -2548,7 +2548,11 @@ std::string - Options::help(const std::vector& help_groups) const - { - String result = m_help_string + "\nUsage:\n " + -- toLocalString(m_program) + " " + toLocalString(m_custom_help); -+ toLocalString(m_program); -+ -+ if (!m_custom_help.empty()) { -+ result += " " + toLocalString(m_custom_help); -+ } - - if (!m_positional.empty() && !m_positional_help.empty()) { - result += " " + toLocalString(m_positional_help); diff --git a/external/yaml-cpp b/external/yaml-cpp index f73201411..56e3bb550 160000 --- a/external/yaml-cpp +++ b/external/yaml-cpp @@ -1 +1 @@ -Subproject commit f7320141120f720aecc4c32be25586e7da9eb978 +Subproject commit 56e3bb550c91fd7005566f19c079cb7a503223cf diff --git a/external/yaml-cpp.patch b/external/yaml-cpp.patch index 1e66dc748..ccd1b75a4 100644 --- a/external/yaml-cpp.patch +++ b/external/yaml-cpp.patch @@ -1,11 +1,12 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 46dc180..b746ac1 100644 +index 631bfa3..a450934 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -1,5 +1,5 @@ - # 3.5 is actually available almost everywhere, but this a good minimum --cmake_minimum_required(VERSION 3.4) -+cmake_minimum_required(VERSION 3.10) +@@ -1,6 +1,6 @@ + # 3.5 is actually available almost everywhere. + # 3.30 as the upper policy limit avoids CMake deprecation warnings. +-cmake_minimum_required(VERSION 3.5...3.30) ++cmake_minimum_required(VERSION 3.10...3.30) # enable MSVC_RUNTIME_LIBRARY target property # see https://cmake.org/cmake/help/latest/policy/CMP0091.html @@ -22,10 +23,10 @@ index 976d149..ba73a48 100644 // bool manipulators YesNoBool, // yes, no diff --git a/include/yaml-cpp/exceptions.h b/include/yaml-cpp/exceptions.h -index f6b2602..a4c5537 100644 +index 99e06b2..2a642a4 100644 --- a/include/yaml-cpp/exceptions.h +++ b/include/yaml-cpp/exceptions.h -@@ -87,6 +87,7 @@ const char* const INVALID_ANCHOR = "invalid anchor"; +@@ -89,6 +89,7 @@ const char* const INVALID_ANCHOR = "invalid anchor"; const char* const INVALID_ALIAS = "invalid alias"; const char* const INVALID_TAG = "invalid tag"; const char* const BAD_FILE = "bad file"; @@ -33,7 +34,7 @@ index f6b2602..a4c5537 100644 template inline const std::string KEY_NOT_FOUND_WITH_KEY( -@@ -298,6 +299,16 @@ class YAML_CPP_API BadFile : public Exception { +@@ -300,6 +301,16 @@ class YAML_CPP_API BadFile : public Exception { BadFile(const BadFile&) = default; ~BadFile() YAML_CPP_NOEXCEPT override; }; @@ -77,19 +78,19 @@ index 07cf81a..ed7d9cd 100644 void convert_sequence_to_map(const shared_memory_holder& pMemory); diff --git a/src/emitter.cpp b/src/emitter.cpp -index 4d48307..a188cca 100644 +index e5fc0ea..f98c605 100644 --- a/src/emitter.cpp +++ b/src/emitter.cpp -@@ -721,7 +721,7 @@ Emitter& Emitter::Write(const std::string& str) { +@@ -722,7 +722,7 @@ Emitter& Emitter::Write(const char* str, std::size_t size) { StringEscaping::value stringEscaping = GetStringEscapingStyle(m_pState->GetOutputCharset()); - const StringFormat::value strFormat = -+ const StringFormat::value strFormat = str.compare(0, 2, "|\n") == 0 ? StringFormat::Literal : - Utils::ComputeStringFormat(str, m_pState->GetStringFormat(), ++ const StringFormat::value strFormat = size >= 2 && str[0] == '|' && str[1] == '\n' ? StringFormat::Literal : + Utils::ComputeStringFormat(str, size, m_pState->GetStringFormat(), m_pState->CurGroupFlowType(), stringEscaping == StringEscaping::NonAscii); -@@ -816,6 +816,8 @@ const char* Emitter::ComputeNullName() const { +@@ -821,6 +821,8 @@ const char* Emitter::ComputeNullName() const { return "NULL"; case CamelNull: return "Null"; @@ -111,18 +112,18 @@ index 3dbe401..0dd0b17 100644 _Set(m_nullFmt, value, scope); return true; diff --git a/src/emitterutils.cpp b/src/emitterutils.cpp -index 6cdf6de..b48b7c0 100644 +index 1541e17..f64a2ec 100644 --- a/src/emitterutils.cpp +++ b/src/emitterutils.cpp -@@ -365,7 +365,7 @@ bool WriteDoubleQuotedString(ostream_wrapper& out, const std::string& str, +@@ -366,7 +366,7 @@ bool WriteDoubleQuotedString(ostream_wrapper& out, const char* str, std::size_t - bool WriteLiteralString(ostream_wrapper& out, const std::string& str, + bool WriteLiteralString(ostream_wrapper& out, const char* str, std::size_t size, std::size_t indent) { - out << "|\n"; -+ out << (str.compare(0, 2, "|\n") == 0 ? "" : "|\n"); ++ out << (size >= 2 && str[0] == '|' && str[1] == '\n' ? "" : "|\n"); int codePoint; - for (std::string::const_iterator i = str.begin(); - GetNextCodePointAndAdvance(codePoint, i, str.end());) { + for (const char* i = str; + GetNextCodePointAndAdvance(codePoint, i, str + size);) { diff --git a/src/exceptions.cpp b/src/exceptions.cpp index 43a7976..af99fd6 100644 --- a/src/exceptions.cpp @@ -147,7 +148,7 @@ index c8837f0..5db3ee4 100644 } inline const RegEx Comment() { diff --git a/src/node_data.cpp b/src/node_data.cpp -index 8f5422a..23ad892 100644 +index 6653bc1..dbfb941 100644 --- a/src/node_data.cpp +++ b/src/node_data.cpp @@ -279,7 +279,12 @@ void node_data::reset_map() { @@ -165,13 +166,13 @@ index 8f5422a..23ad892 100644 if (!key.is_defined() || !value.is_defined()) diff --git a/test/integration/load_node_test.cpp b/test/integration/load_node_test.cpp -index 9d0c790..37355aa 100644 +index 49f2b61..653c487 100644 --- a/test/integration/load_node_test.cpp +++ b/test/integration/load_node_test.cpp -@@ -360,5 +360,9 @@ TEST(LoadNodeTest, BlockCRNLEncoded) { - EXPECT_EQ(1, node["followup"].as()); +@@ -447,5 +447,9 @@ TEST(LoadNodeTest, BlockCREncoded) { } + +TEST(LoadNodeTest, NonUniqueMapKey) { + EXPECT_THROW(Load("{a: A, b: B, a: A}"), NonUniqueMapKey); +} diff --git a/libs/ymltree/test/YmlTreeTest.cpp b/libs/ymltree/test/YmlTreeTest.cpp index 5b5e0e300..3f0871235 100644 --- a/libs/ymltree/test/YmlTreeTest.cpp +++ b/libs/ymltree/test/YmlTreeTest.cpp @@ -10,6 +10,7 @@ #include "RteFsUtils.h" #include "XmlFormatter.h" #include "YmlFormatter.h" +#include "yaml-cpp/yaml.h" #include #include @@ -55,6 +56,40 @@ class YmlTreeTestF :public ::testing::Test { }; +TEST(YmlTreeTest, PatchedYamlBehavior) { + EXPECT_THROW(YAML::Load("{a: A, b: B, a: A}"), YAML::NonUniqueMapKey); + + YAML::Node map(YAML::NodeType::Map); + map.force_insert("key", "first"); + EXPECT_NO_THROW(map.force_insert("key", "second")); + EXPECT_EQ(2u, map.size()); + + YAML::Emitter nullEmitter; + ASSERT_TRUE(nullEmitter.SetNullFormat(YAML::EmptyNull)); + nullEmitter << YAML::BeginMap << YAML::Key << "key" << YAML::Value + << YAML::Null << YAML::EndMap; + EXPECT_STREQ("key: ", nullEmitter.c_str()); + + YAML::Emitter literalEmitter; + literalEmitter << std::string("|\n first\n second"); + EXPECT_STREQ(" |\n first\n second", literalEmitter.c_str()); + + const std::string literal = "|\n first\n second"; + YAML::Emitter literalBufferEmitter; + literalBufferEmitter.Write(literal.data(), literal.size()); + EXPECT_STREQ(literalEmitter.c_str(), literalBufferEmitter.c_str()); + + const char shortBuffer[] = {'|', '\n'}; + YAML::Emitter bufferEmitter; + bufferEmitter.Write(shortBuffer, 1); + EXPECT_STREQ("\"|\"", bufferEmitter.c_str()); + + YAML::Emitter ampersandEmitter; + ampersandEmitter << "A&B"; + EXPECT_STREQ("A&B", ampersandEmitter.c_str()); + EXPECT_EQ("A&B", YAML::Load(ampersandEmitter.c_str()).as()); +} + TEST(YmlTreeTest, InvalidInput) { const string yaml_input ="invalid: 1 : 2"; diff --git a/tools/buildmgr/cbuildgen/src/CbuildGen.cpp b/tools/buildmgr/cbuildgen/src/CbuildGen.cpp index f86ac483f..9c66476f0 100644 --- a/tools/buildmgr/cbuildgen/src/CbuildGen.cpp +++ b/tools/buildmgr/cbuildgen/src/CbuildGen.cpp @@ -139,7 +139,7 @@ int CbuildGen::RunCbuildGen(int argc, char **argv, char** envp) { options.parse_positional({"args"}); parseResult = options.parse(argc, argv); } - catch (cxxopts::OptionException& e) { + catch (cxxopts::exceptions::exception& e) { LogMsg("M217", VAL("MSG", e.what())); console.Usage(); return 1; diff --git a/tools/ctrace/docs/THIRD_PARTY_NOTICES.md b/tools/ctrace/docs/THIRD_PARTY_NOTICES.md index 8cad9fa7b..292231f09 100644 --- a/tools/ctrace/docs/THIRD_PARTY_NOTICES.md +++ b/tools/ctrace/docs/THIRD_PARTY_NOTICES.md @@ -7,14 +7,14 @@ provided in `THIRD_PARTY_LICENSES/OpenCSD-NOTICE.txt`. | Component | Version | License | Source | | --------- | ------: | ------------ | -------------------------------------- | -| cxxopts | 3.0.0 | MIT | | -| yaml-cpp | 0.8.0 | MIT | | +| cxxopts | 3.3.1 | MIT | | +| yaml-cpp | 0.9.0 | MIT | | | OpenCSD | 1.8.3 | BSD-3-Clause | | The source revisions used for this notice are pinned by the devtools gitlinks: -- cxxopts: `df229cff0d5b96e146f3f11441f714e8e240cad0` -- yaml-cpp: `f7320141120f720aecc4c32be25586e7da9eb978` +- cxxopts: `44380e5a44706ab7347f400698c703eb2a196202` +- yaml-cpp: `56e3bb550c91fd7005566f19c079cb7a503223cf` - OpenCSD: `59f15320637ce6e510604e7bed550d7ad109d15d` GoogleTest is used only to build the test executable and is not incorporated diff --git a/tools/packchk/src/ParseOptions.cpp b/tools/packchk/src/ParseOptions.cpp index e9a380960..b587c7f93 100644 --- a/tools/packchk/src/ParseOptions.cpp +++ b/tools/packchk/src/ParseOptions.cpp @@ -331,7 +331,7 @@ ParseOptions::Result ParseOptions::Parse(int argc, const char** argv) } } } - catch (cxxopts::OptionException& e) { + catch (cxxopts::exceptions::exception& e) { cerr << fileName << " error: " << e.what() << endl; return Result::Error; } diff --git a/tools/packgen/src/PackGen.cpp b/tools/packgen/src/PackGen.cpp index 31d7117e6..79acead4c 100644 --- a/tools/packgen/src/PackGen.cpp +++ b/tools/packgen/src/PackGen.cpp @@ -85,7 +85,7 @@ int PackGen::RunPackGen(int argc, char **argv) { cout << options.help() << endl; return 0; } - } catch (cxxopts::OptionException& e) { + } catch (cxxopts::exceptions::exception& e) { // Print error cerr << "packgen error: parsing command line failed!" << endl << e.what() << endl; return 1; diff --git a/tools/projmgr/src/ProjMgr.cpp b/tools/projmgr/src/ProjMgr.cpp index fbd50b68d..b76c51fee 100644 --- a/tools/projmgr/src/ProjMgr.cpp +++ b/tools/projmgr/src/ProjMgr.cpp @@ -312,7 +312,7 @@ int ProjMgr::ParseCommandLine(int argc, char** argv) { m_outputDir = parseResult[key].as(); m_outputDir = RteFsUtils::AbsolutePath(m_outputDir).generic_string(); } - } catch (cxxopts::OptionException& e) { + } catch (cxxopts::exceptions::exception& e) { ProjMgrLogger::Get().Error(e.what()); return ErrorCode::ERROR; } diff --git a/tools/projmgr/src/ProjMgrYamlParser.cpp b/tools/projmgr/src/ProjMgrYamlParser.cpp index 7edd75086..0a0873a60 100644 --- a/tools/projmgr/src/ProjMgrYamlParser.cpp +++ b/tools/projmgr/src/ProjMgrYamlParser.cpp @@ -406,7 +406,8 @@ void ProjMgrYamlParser::ParseInt(const YAML::Node& parent, const string& key, in void ProjMgrYamlParser::ParseMapOfStrings(const YAML::Node& parent, const string& key, map& value) { if (parent[key].IsDefined() && parent[key].IsMap()) { for (const auto& item : parent[key]) { - value[item.first.as()] = YAML::IsNullString(item.second.as()) ? "" : item.second.as(); + const auto text = item.second.as(); + value[item.first.as()] = YAML::IsNullString(text.data(), text.size()) ? "" : text; } } } @@ -461,7 +462,7 @@ bool ProjMgrYamlParser::ParseDefine(const YAML::Node& defineNode, vector if (item.IsMap()) { const auto& elements = item.as>(); for (auto element : elements) { - if (YAML::IsNullString(element.second)) { + if (YAML::IsNullString(element.second.data(), element.second.size())) { element.second = ""; } success &= ValidateDefineStr(element.second); @@ -514,7 +515,7 @@ void ProjMgrYamlParser::ParseVectorOfStringPairs(const YAML::Node& parent, const // This is a special case used by the CMSIS csolution extension // and may involve redefinitions if (element.first != "copied-from") { - if (YAML::IsNullString(element.second)) { + if (YAML::IsNullString(element.second.data(), element.second.size())) { element.second = ""; } value.push_back(element); diff --git a/tools/svdconv/SVDConv/src/ParseOptions.cpp b/tools/svdconv/SVDConv/src/ParseOptions.cpp index 085984b26..2054422e7 100644 --- a/tools/svdconv/SVDConv/src/ParseOptions.cpp +++ b/tools/svdconv/SVDConv/src/ParseOptions.cpp @@ -547,7 +547,7 @@ ParseOptions::Result ParseOptions::ParseOpts(int argc, const char* argv[]) } } } - catch (cxxopts::OptionException& e) { + catch (cxxopts::exceptions::exception& e) { cerr << fileName << " error: " << e.what() << endl; return Result::Error; }