diff options
26 files changed, 319 insertions, 141 deletions
diff --git a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake index 8e03eef..5431ab7 100644 --- a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake +++ b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake @@ -1,3 +1,8 @@ +set(CMake_TEST_CTestUpdate_BZR "ON" CACHE BOOL "") +set(CMake_TEST_CTestUpdate_CVS "ON" CACHE BOOL "") +set(CMake_TEST_CTestUpdate_GIT "ON" CACHE BOOL "") +set(CMake_TEST_CTestUpdate_HG "ON" CACHE BOOL "") +set(CMake_TEST_CTestUpdate_SVN "ON" CACHE BOOL "") set(CMake_TEST_FindALSA "ON" CACHE BOOL "") set(CMake_TEST_FindBLAS "All;static=1;Generic" CACHE STRING "") set(CMake_TEST_FindBoost "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_debian10_ninja.cmake b/.gitlab/ci/configure_debian10_ninja.cmake index d50ab1f..1be5381 100644 --- a/.gitlab/ci/configure_debian10_ninja.cmake +++ b/.gitlab/ci/configure_debian10_ninja.cmake @@ -1,3 +1,12 @@ +set(CMake_TEST_CTestUpdate_BZR "ON" CACHE BOOL "") +set(CMake_TEST_CTestUpdate_CVS "ON" CACHE BOOL "") +set(CMake_TEST_CTestUpdate_GIT "ON" CACHE BOOL "") +set(CMake_TEST_CTestUpdate_HG "ON" CACHE BOOL "") +set(CMake_TEST_CTestUpdate_SVN "ON" CACHE BOOL "") +if (NOT "$ENV{CMAKE_CI_NIGHTLY}" STREQUAL "") + set(CMake_TEST_CTestUpdate_P4 "ON" CACHE BOOL "") +endif() + set(CMake_TEST_FindALSA "ON" CACHE BOOL "") set(CMake_TEST_FindBLAS "All;static=1;Generic" CACHE STRING "") set(CMake_TEST_FindBoost "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_fedora35_makefiles.cmake b/.gitlab/ci/configure_fedora35_makefiles.cmake index a482378..91ed55b 100644 --- a/.gitlab/ci/configure_fedora35_makefiles.cmake +++ b/.gitlab/ci/configure_fedora35_makefiles.cmake @@ -1,3 +1,11 @@ +set(CMake_TEST_CTestUpdate_BZR "ON" CACHE BOOL "") +set(CMake_TEST_CTestUpdate_GIT "ON" CACHE BOOL "") +set(CMake_TEST_CTestUpdate_HG "ON" CACHE BOOL "") +set(CMake_TEST_CTestUpdate_SVN "ON" CACHE BOOL "") +if (NOT "$ENV{CMAKE_CI_NIGHTLY}" STREQUAL "") + set(CMake_TEST_CTestUpdate_P4 "ON" CACHE BOOL "") +endif() + set(CMake_TEST_FindALSA "ON" CACHE BOOL "") set(CMake_TEST_FindBLAS "All;static=1;Generic" CACHE STRING "") set(CMake_TEST_FindBoost "ON" CACHE BOOL "") diff --git a/.gitlab/ci/docker/debian10-aarch64/install_deps.sh b/.gitlab/ci/docker/debian10-aarch64/install_deps.sh index d5c5e22..21f0b16 100755 --- a/.gitlab/ci/docker/debian10-aarch64/install_deps.sh +++ b/.gitlab/ci/docker/debian10-aarch64/install_deps.sh @@ -25,6 +25,7 @@ apt-get install -y \ # Packages needed to test CTest. apt-get install -y \ + bzr bzr-xmloutput \ cvs \ subversion \ mercurial diff --git a/.gitlab/ci/docker/debian10/install_deps.sh b/.gitlab/ci/docker/debian10/install_deps.sh index d3d6b67..12a91e6 100755 --- a/.gitlab/ci/docker/debian10/install_deps.sh +++ b/.gitlab/ci/docker/debian10/install_deps.sh @@ -25,6 +25,7 @@ apt-get install -y \ # Packages needed to test CTest. apt-get install -y \ + bzr bzr-xmloutput \ cvs \ subversion \ mercurial @@ -89,4 +90,11 @@ curl -L -O https://github.com/IronLanguages/ironpython2/releases/download/ipy-2. dpkg -i ironpython_2.7.10.deb rm ironpython_2.7.10.deb +# Perforce +curl -L -O https://www.perforce.com/downloads/perforce/r21.2/bin.linux26x86_64/helix-core-server.tgz +echo '72620c55e9389705582506d6f3388005fb4f674888a00a12a51edc2ae37823b3 helix-core-server.tgz' > helix.sha256sum +sha256sum --check helix.sha256sum +tar -C /usr/local/bin -xvzf helix-core-server.tgz -- p4 p4d +rm helix-core-server.tgz + apt-get clean diff --git a/.gitlab/ci/docker/fedora35/install_deps.sh b/.gitlab/ci/docker/fedora35/install_deps.sh index 30214af..038000c 100755 --- a/.gitlab/ci/docker/fedora35/install_deps.sh +++ b/.gitlab/ci/docker/fedora35/install_deps.sh @@ -38,6 +38,7 @@ dnf install --setopt=install_weak_deps=False -y \ # Packages needed to test CTest. dnf install --setopt=install_weak_deps=False -y \ + breezy \ subversion \ mercurial @@ -106,3 +107,10 @@ curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py python2 get-pip.py rm get-pip.py pip2.7 install numpy + +# Perforce +curl -L -O https://www.perforce.com/downloads/perforce/r21.2/bin.linux26x86_64/helix-core-server.tgz +echo '72620c55e9389705582506d6f3388005fb4f674888a00a12a51edc2ae37823b3 helix-core-server.tgz' > helix.sha256sum +sha256sum --check helix.sha256sum +tar -C /usr/local/bin -xvzf helix-core-server.tgz -- p4 p4d +rm helix-core-server.tgz diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index a2da7f9..5e620f5 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -45,7 +45,7 @@ ### Debian .debian10: - image: "kitware/cmake:ci-debian10-x86_64-2021-11-18" + image: "kitware/cmake:ci-debian10-x86_64-2022-02-21" variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci" @@ -60,7 +60,7 @@ CMake_SKIP_INSTALL: 1 .debian10_aarch64: - image: "kitware/cmake:ci-debian10-aarch64-2021-11-18" + image: "kitware/cmake:ci-debian10-aarch64-2022-02-21" variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci" @@ -69,7 +69,7 @@ ### Fedora .fedora35: - image: "kitware/cmake:ci-fedora35-x86_64-2022-02-01" + image: "kitware/cmake:ci-fedora35-x86_64-2022-02-21" variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci/long file name for testing purposes" diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index 69f68f9..602170c 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -7,46 +7,53 @@ CheckTypeSize Check sizeof a type -.. command:: CHECK_TYPE_SIZE +.. command:: check_type_size .. code-block:: cmake - CHECK_TYPE_SIZE(TYPE VARIABLE [BUILTIN_TYPES_ONLY] - [LANGUAGE <language>]) + check_type_size(<type> <variable> [BUILTIN_TYPES_ONLY] + [LANGUAGE <language>]) - Check if the type exists and determine its size. On return, - ``HAVE_${VARIABLE}`` holds the existence of the type, and ``${VARIABLE}`` - holds one of the following: + Check if the type exists and determine its size. Results are reported + in the following variables: - :: + ``HAVE_<variable>`` + Holds a true or false value indicating whether the type exists. - <size> = type has non-zero size <size> - "0" = type has arch-dependent size (see below) - "" = type does not exist + ``<variable>`` + Holds one of the following values: - Both ``HAVE_${VARIABLE}`` and ``${VARIABLE}`` will be created as internal - cache variables. + ``<size>`` + Type has non-zero size ``<size>``. - Furthermore, the variable ``${VARIABLE}_CODE`` holds C preprocessor code - to define the macro ``${VARIABLE}`` to the size of the type, or leave - the macro undefined if the type does not exist. + ``0`` + Type has architecture-dependent size. This may occur when + :variable:`CMAKE_OSX_ARCHITECTURES` has multiple architectures. + In this case ``<variable>_CODE`` contains C preprocessor tests + mapping from each architecture macro to the corresponding type size. + The list of architecture macros is stored in ``<variable>_KEYS``, + and the value for each key is stored in ``<variable>-<key>``. - The variable ``${VARIABLE}`` may be ``0`` when - :variable:`CMAKE_OSX_ARCHITECTURES` has multiple architectures for building - OS X universal binaries. This indicates that the type size varies across - architectures. In this case ``${VARIABLE}_CODE`` contains C preprocessor - tests mapping from each architecture macro to the corresponding type size. - The list of architecture macros is stored in ``${VARIABLE}_KEYS``, and the - value for each key is stored in ``${VARIABLE}-${KEY}``. + "" (empty string) + Type does not exist. - If the ``BUILTIN_TYPES_ONLY`` option is not given, the macro checks for - headers ``<sys/types.h>``, ``<stdint.h>``, and ``<stddef.h>``, and saves - results in ``HAVE_SYS_TYPES_H``, ``HAVE_STDINT_H``, and ``HAVE_STDDEF_H``. - The type size check automatically includes the available headers, thus - supporting checks of types defined in the headers. + ``<variable>_CODE`` + Holds C preprocessor code to define the macro ``<variable>`` to the size + of the type, or to leave the macro undefined if the type does not exist. - If ``LANGUAGE`` is set, the specified compiler will be used to perform the - check. Acceptable values are ``C`` and ``CXX``. + The options are: + + ``BUILTIN_TYPES_ONLY`` + + Support only compiler-builtin types. If *not* given, the macro checks + for headers ``<sys/types.h>``, ``<stdint.h>``, and ``<stddef.h>``, and + saves results in ``HAVE_SYS_TYPES_H``, ``HAVE_STDINT_H``, and + ``HAVE_STDDEF_H``. The type size check automatically includes the + available headers, thus supporting checks of types defined in the headers. + + ``LANGUAGE <language>`` + Use the ``<language>`` compiler to perform the check. + Acceptable values are ``C`` and ``CXX``. Despite the name of the macro you may use it to check the size of more complex expressions, too. To check e.g. for the size of a struct diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 14864d5..292333d 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -353,6 +353,10 @@ External Project Definition When ``GIT_REMOTE_UPDATE_STRATEGY`` is not present, this is the default strategy unless the default has been overridden with ``CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY`` (see below). + Note that if the branch specified in ``GIT_TAG`` is different to + the upstream branch currently being tracked, it is not safe to + perform a rebase. In that situation, ``REBASE`` will silently be + treated as ``CHECKOUT`` instead. ``REBASE_CHECKOUT`` Same as ``REBASE`` except if the rebase fails, an annotated tag will diff --git a/Modules/ExternalProject/gitupdate.cmake.in b/Modules/ExternalProject/gitupdate.cmake.in index 0de2372..7896f62 100644 --- a/Modules/ExternalProject/gitupdate.cmake.in +++ b/Modules/ExternalProject/gitupdate.cmake.in @@ -128,7 +128,7 @@ if(git_update_strategy MATCHES "^REBASE(_CHECKOUT)?$") else() execute_process( - COMMAND "@git_EXECUTABLE@" for-each-ref "--format='%(upstream:short)'" "${current_branch}" + COMMAND "@git_EXECUTABLE@" for-each-ref "--format=%(upstream:short)" "${current_branch}" WORKING_DIRECTORY "@work_dir@" OUTPUT_VARIABLE upstream_branch OUTPUT_STRIP_TRAILING_WHITESPACE diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 78b1c21..352ca92 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 23) -set(CMake_VERSION_PATCH 20220220) +set(CMake_VERSION_PATCH 20220224) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e722fa9..a246c12 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3456,12 +3456,10 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(std::string& flags) const cmSystemTools::OP_GREATER_EQUAL, this->Makefile->GetDefinition("CMAKE_CUDA_COMPILER_VERSION"), "11.5")) { - if (property == "all") { - flags += " -arch=all"; - } else if (property == "all-major") { - flags += " -arch=all-major"; + if (property == "all" || property == "all-major") { + flags = cmStrCat(flags, " -arch=", property); + return; } - return; } if (property == "all") { diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 47cefae..c853c50 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -36,11 +36,6 @@ cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget* target) static_cast<cmLocalGhsMultiGenerator*>(target->GetLocalGenerator())) , Makefile(target->Target->GetMakefile()) , Name(target->GetName()) -#ifdef _WIN32 - , CmdWindowsShell(true) -#else - , CmdWindowsShell(false) -#endif { // Store the configuration name that is being used if (cmValue config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) { @@ -316,19 +311,37 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLine(std::ostream& fout, void cmGhsMultiTargetGenerator::WriteBuildEvents(std::ostream& fout) { - this->WriteBuildEventsHelper( - fout, this->GeneratorTarget->GetPreBuildCommands(), - std::string("prebuild"), std::string("preexecShell")); + this->WriteBuildEventsHelper(fout, + this->GeneratorTarget->GetPreBuildCommands(), + std::string("prebuild"), +#ifdef _WIN32 + std::string("preexecShell") +#else + std::string("preexec") +#endif + ); if (this->TagType != GhsMultiGpj::CUSTOM_TARGET) { - this->WriteBuildEventsHelper( - fout, this->GeneratorTarget->GetPreLinkCommands(), - std::string("prelink"), std::string("preexecShell")); + this->WriteBuildEventsHelper(fout, + this->GeneratorTarget->GetPreLinkCommands(), + std::string("prelink"), +#ifdef _WIN32 + std::string("preexecShell") +#else + std::string("preexec") +#endif + ); } - this->WriteBuildEventsHelper( - fout, this->GeneratorTarget->GetPostBuildCommands(), - std::string("postbuild"), std::string("postexecShell")); + this->WriteBuildEventsHelper(fout, + this->GeneratorTarget->GetPostBuildCommands(), + std::string("postbuild"), +#ifdef _WIN32 + std::string("postexecShell") +#else + std::string("postexec") +#endif + ); } void cmGhsMultiTargetGenerator::WriteBuildEventsHelper( @@ -336,6 +349,13 @@ void cmGhsMultiTargetGenerator::WriteBuildEventsHelper( std::string const& name, std::string const& cmd) { int cmdcount = 0; +#ifdef _WIN32 + std::string fext = ".bat"; + std::string shell; +#else + std::string fext = ".sh"; + std::string shell = "/bin/sh "; +#endif for (cmCustomCommand const& cc : ccv) { cmCustomCommandGenerator ccg(cc, this->ConfigName, this->LocalGenerator); @@ -343,14 +363,14 @@ void cmGhsMultiTargetGenerator::WriteBuildEventsHelper( std::string fname = cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/', this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), - '/', this->Name, '_', name, cmdcount++, - this->CmdWindowsShell ? ".bat" : ".sh"); + '/', this->Name, '_', name, cmdcount++, fext); + cmGeneratedFileStream f(fname); f.SetCopyIfDifferent(true); this->WriteCustomCommandsHelper(f, ccg); f.Close(); if (this->TagType != GhsMultiGpj::CUSTOM_TARGET) { - fout << " :" << cmd << "=\"" << fname << "\"\n"; + fout << " :" << cmd << "=\"" << shell << fname << "\"\n"; } else { fout << fname << "\n :outputName=\"" << fname << ".rule\"\n"; } @@ -409,15 +429,15 @@ void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper( // bool useCall = false; - if (this->CmdWindowsShell) { - std::string suffix; - if (cmd.size() > 4) { - suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size() - 4)); - if (suffix == ".bat" || suffix == ".cmd") { - useCall = true; - } +#ifdef _WIN32 + std::string suffix; + if (cmd.size() > 4) { + suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size() - 4)); + if (suffix == ".bat" || suffix == ".cmd") { + useCall = true; } } +#endif cmSystemTools::ReplaceString(cmd, "/./", "/"); // Convert the command to a relative path only if the current @@ -645,6 +665,11 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj) } } int cmdcount = 0; +#ifdef _WIN32 + std::string fext = ".bat"; +#else + std::string fext = ".sh"; +#endif for (auto& sf : customCommands) { const cmCustomCommand* cc = sf->GetCustomCommand(); cmCustomCommandGenerator ccg(*cc, this->ConfigName, @@ -655,8 +680,8 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj) this->LocalGenerator->GetCurrentBinaryDirectory(), '/', this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), '/', this->Name, "_cc", cmdcount++, '_', - (sf->GetLocation()).GetName(), - this->CmdWindowsShell ? ".bat" : ".sh"); + (sf->GetLocation()).GetName(), fext); + cmGeneratedFileStream f(fname); f.SetCopyIfDifferent(true); this->WriteCustomCommandsHelper(f, ccg); diff --git a/Source/cmGhsMultiTargetGenerator.h b/Source/cmGhsMultiTargetGenerator.h index e9d7537..9289a72 100644 --- a/Source/cmGhsMultiTargetGenerator.h +++ b/Source/cmGhsMultiTargetGenerator.h @@ -78,6 +78,5 @@ private: std::string TargetNameReal; GhsMultiGpj::Types TagType; std::string const Name; - std::string ConfigName; /* CMAKE_BUILD_TYPE */ - bool const CmdWindowsShell; /* custom commands run in cmd.exe or /bin/sh */ + std::string ConfigName; /* CMAKE_BUILD_TYPE */ }; diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index 19bf982..22cbf06 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -1906,7 +1906,7 @@ static void kwsysProcessDestroy(kwsysProcess* cp) (errno == EINTR)) { } if (result > 0) { - /* This child has termianted. */ + /* This child has terminated. */ cp->ForkPIDs[i] = 0; if (--cp->CommandsLeft == 0) { /* All children have terminated. Close the signal pipe diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c index e97973e..17e1507 100644 --- a/Source/kwsys/ProcessWin32.c +++ b/Source/kwsys/ProcessWin32.c @@ -2119,7 +2119,7 @@ static void kwsysProcessSetExitExceptionByIndex(kwsysProcess* cp, int code, KWSYSPE_CASE(Fault, "In-page error"); break; case STATUS_INVALID_HANDLE: - KWSYSPE_CASE(Fault, "Invalid hanlde"); + KWSYSPE_CASE(Fault, "Invalid handle"); break; case STATUS_NONCONTINUABLE_EXCEPTION: KWSYSPE_CASE(Fault, "Noncontinuable exception"); diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 8ebe5ed..65f72c5 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2604,6 +2604,9 @@ if(BUILD_TESTING) # Test CTest Update with BZR if(CMake_TEST_CTestUpdate_BZR) + if(TEST_HOME) + file(MAKE_DIRECTORY "${TEST_HOME}/.bazaar") + endif() find_program(BZR_EXECUTABLE NAMES bzr) mark_as_advanced(BZR_EXECUTABLE) if(NOT BZR_EXECUTABLE) @@ -2671,16 +2674,10 @@ if(BUILD_TESTING) endif() # Test CTest Update with P4 - if(NOT DEFINED CMake_TEST_CTestUpdate_P4 OR CMake_TEST_CTestUpdate_P4) + if(CMake_TEST_CTestUpdate_P4) find_program(P4_EXECUTABLE NAMES p4) find_program(P4D_EXECUTABLE NAMES p4d) mark_as_advanced(P4_EXECUTABLE P4D_EXECUTABLE) - endif() - if(NOT DEFINED CMake_TEST_CTestUpdate_P4 AND P4_EXECUTABLE AND P4D_EXECUTABLE - AND (UNIX OR NOT "${P4_EXECUTABLE};${P4D_EXECUTABLE}" MATCHES "cygwin")) - set(CMake_TEST_CTestUpdate_P4 1) - endif() - if(CMake_TEST_CTestUpdate_P4) if(NOT P4_EXECUTABLE OR NOT P4D_EXECUTABLE) message(FATAL_ERROR "CMake_TEST_CTestUpdate_HG enabled but P4_EXECUTABLE and P4D_EXECUTABLE are not both not found.") endif() diff --git a/Tests/CTestUpdateP4.cmake.in b/Tests/CTestUpdateP4.cmake.in index 5eef9fb..8a99e67 100644 --- a/Tests/CTestUpdateP4.cmake.in +++ b/Tests/CTestUpdateP4.cmake.in @@ -66,6 +66,7 @@ for i in 1 2 3 4 5 6 7 8 9 10; do fi done echo 'Gave up waiting for server to start.' +sed 's/^/ /' '${P4_ROOT}/p4.log' " ) endif() @@ -258,4 +259,4 @@ message("Shutting down p4d") run_child( WORKING_DIRECTORY ${TOP} COMMAND ${P4CMD} admin stop -)
\ No newline at end of file +) diff --git a/Utilities/Git/ignore-revs b/Utilities/Git/ignore-revs new file mode 100644 index 0000000..af058e8 --- /dev/null +++ b/Utilities/Git/ignore-revs @@ -0,0 +1,38 @@ +# LexerParser regeneration +34b7dbbfc37180989b57a0fb25ca4e0010cf992b + +# CMAKE_BOOTSTRAP rename +54e9d38c28d0073f2cc5d690adb5c993e7793c97 + +# CMake code reindentation +2c807b75f3283d30ecde55be5b434be65d0ea141 +932dcce1e63b98739ab547f2146a39310c2d0e1e + +# `#pragma once` +bdca8b01d2d96d63e685e7eca03e0f51f5410fdf + +# clang-format-6 +ed98209ddc8d5e9f5b20cd010c69a25d553b2654 +d7204e649ed4ebb19bb341b4e49eb51514364922 +# Initial clang-format +d9fd2f5402eeaa345691313658e02b51038f570b + +# Fortran parser renaming +98b9645bcebf009643cff4e265cfcd31b56d80f5 + +# Sphinx conversion, reformattings +496ec6036fb2b4ebbae000ee362cdfb7704d08de +df4ed1e9ffcdb6b99ccff9e6f44808fdd2abda56 +3442f2bcc47ccce86124144423b416b98d589b20 +28f08ba25cc60de3fc7cb9eb4b3297ed6fe1dee0 +baaab068f2fa9e736ed85f3ba9b75d96e9339f89 +a77e3086938d46c56f62901531245711dbd55cc4 +f051814ed0e63badbfd68049354f36259dbf4b49 +81759c77af28f367c71e71973d985dc1d7a7c87c + +# Removal of `end*` command arguments +9db3116226cb99fcf54e936c833953abcde9b729 +# Lowercasing command names +77543bde41b0e52c3959016698b529835945d62d +# Removal of trailing whitespace +7bbaa4283de26864b2e55e819db0884771585467 diff --git a/Utilities/Scripts/update-expat.bash b/Utilities/Scripts/update-expat.bash index 2ff3c59..a061adc 100755 --- a/Utilities/Scripts/update-expat.bash +++ b/Utilities/Scripts/update-expat.bash @@ -8,7 +8,7 @@ readonly name="expat" readonly ownership="Expat Upstream <kwrobot@kitware.com>" readonly subtree="Utilities/cmexpat" readonly repo="https://github.com/libexpat/libexpat.git" -readonly tag="R_2_4_4" +readonly tag="R_2_4_6" readonly shortlog=false readonly paths=" expat/lib/asciitab.h diff --git a/Utilities/cmexpat/README.md b/Utilities/cmexpat/README.md index 00e6cca..959c4a6 100644 --- a/Utilities/cmexpat/README.md +++ b/Utilities/cmexpat/README.md @@ -5,7 +5,7 @@ [](https://github.com/libexpat/libexpat/releases) -# Expat, Release 2.4.4 +# Expat, Release 2.4.6 This is Expat, a C library for parsing XML, started by [James Clark](https://en.wikipedia.org/wiki/James_Clark_%28programmer%29) in 1997. diff --git a/Utilities/cmexpat/lib/expat.h b/Utilities/cmexpat/lib/expat.h index 4c5704f..46a0e1b 100644 --- a/Utilities/cmexpat/lib/expat.h +++ b/Utilities/cmexpat/lib/expat.h @@ -1041,7 +1041,7 @@ XML_SetBillionLaughsAttackProtectionActivationThreshold( */ #define XML_MAJOR_VERSION 2 #define XML_MINOR_VERSION 4 -#define XML_MICRO_VERSION 4 +#define XML_MICRO_VERSION 6 #ifdef __cplusplus } diff --git a/Utilities/cmexpat/lib/xmlparse.c b/Utilities/cmexpat/lib/xmlparse.c index 4b43e61..7db28d0 100644 --- a/Utilities/cmexpat/lib/xmlparse.c +++ b/Utilities/cmexpat/lib/xmlparse.c @@ -1,4 +1,4 @@ -/* 2e2c8ce5f11a473d65ec313ab20ceee6afefb355f5405afc06e7204e2e41c8c0 (2.4.4+) +/* a30d2613dcfdef81475a9d1a349134d2d42722172fdaa7d5bb12ed2aa74b9596 (2.4.6+) __ __ _ ___\ \/ /_ __ __ _| |_ / _ \\ /| '_ \ / _` | __| @@ -11,7 +11,7 @@ Copyright (c) 2000-2006 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net> Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net> - Copyright (c) 2005-2009 Steven Solie <ssolie@users.sourceforge.net> + Copyright (c) 2005-2009 Steven Solie <steven@solie.ca> Copyright (c) 2016 Eric Rahm <erahm@mozilla.com> Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org> Copyright (c) 2016 Gaurav <g.gupta@samsung.com> @@ -718,8 +718,7 @@ XML_ParserCreate(const XML_Char *encodingName) { XML_Parser XMLCALL XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) { - XML_Char tmp[2]; - *tmp = nsSep; + XML_Char tmp[2] = {nsSep, 0}; return XML_ParserCreate_MM(encodingName, NULL, tmp); } @@ -1344,8 +1343,7 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, const XML_Char *context, would be otherwise. */ if (parser->m_ns) { - XML_Char tmp[2]; - *tmp = parser->m_namespaceSeparator; + XML_Char tmp[2] = {parser->m_namespaceSeparator, 0}; parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd); } else { parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd); @@ -2563,6 +2561,7 @@ storeRawNames(XML_Parser parser) { while (tag) { int bufSize; int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1); + size_t rawNameLen; char *rawNameBuf = tag->buf + nameLen; /* Stop if already stored. Since m_tagStack is a stack, we can stop at the first entry that has already been copied; everything @@ -2574,7 +2573,11 @@ storeRawNames(XML_Parser parser) { /* For re-use purposes we need to ensure that the size of tag->buf is a multiple of sizeof(XML_Char). */ - bufSize = nameLen + ROUND_UP(tag->rawNameLength, sizeof(XML_Char)); + rawNameLen = ROUND_UP(tag->rawNameLength, sizeof(XML_Char)); + /* Detect and prevent integer overflow. */ + if (rawNameLen > (size_t)INT_MAX - nameLen) + return XML_FALSE; + bufSize = nameLen + (int)rawNameLen; if (bufSize > tag->bufEnd - tag->buf) { char *temp = (char *)REALLOC(parser, tag->buf, bufSize); if (temp == NULL) @@ -3756,6 +3759,17 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, if (! mustBeXML && isXMLNS && (len > xmlnsLen || uri[len] != xmlnsNamespace[len])) isXMLNS = XML_FALSE; + + // NOTE: While Expat does not validate namespace URIs against RFC 3986, + // we have to at least make sure that the XML processor on top of + // Expat (that is splitting tag names by namespace separator into + // 2- or 3-tuples (uri-local or uri-local-prefix)) cannot be confused + // by an attacker putting additional namespace separator characters + // into namespace declarations. That would be ambiguous and not to + // be expected. + if (parser->m_ns && (uri[len] == parser->m_namespaceSeparator)) { + return XML_ERROR_SYNTAX; + } } isXML = isXML && len == xmlLen; isXMLNS = isXMLNS && len == xmlnsLen; @@ -7317,44 +7331,15 @@ nextScaffoldPart(XML_Parser parser) { return next; } -static void -build_node(XML_Parser parser, int src_node, XML_Content *dest, - XML_Content **contpos, XML_Char **strpos) { - DTD *const dtd = parser->m_dtd; /* save one level of indirection */ - dest->type = dtd->scaffold[src_node].type; - dest->quant = dtd->scaffold[src_node].quant; - if (dest->type == XML_CTYPE_NAME) { - const XML_Char *src; - dest->name = *strpos; - src = dtd->scaffold[src_node].name; - for (;;) { - *(*strpos)++ = *src; - if (! *src) - break; - src++; - } - dest->numchildren = 0; - dest->children = NULL; - } else { - unsigned int i; - int cn; - dest->numchildren = dtd->scaffold[src_node].childcnt; - dest->children = *contpos; - *contpos += dest->numchildren; - for (i = 0, cn = dtd->scaffold[src_node].firstchild; i < dest->numchildren; - i++, cn = dtd->scaffold[cn].nextsib) { - build_node(parser, cn, &(dest->children[i]), contpos, strpos); - } - dest->name = NULL; - } -} - static XML_Content * build_model(XML_Parser parser) { + /* Function build_model transforms the existing parser->m_dtd->scaffold + * array of CONTENT_SCAFFOLD tree nodes into a new array of + * XML_Content tree nodes followed by a gapless list of zero-terminated + * strings. */ DTD *const dtd = parser->m_dtd; /* save one level of indirection */ XML_Content *ret; - XML_Content *cpos; - XML_Char *str; + XML_Char *str; /* the current string writing location */ /* Detect and prevent integer overflow. * The preprocessor guard addresses the "always false" warning @@ -7380,10 +7365,96 @@ build_model(XML_Parser parser) { if (! ret) return NULL; - str = (XML_Char *)(&ret[dtd->scaffCount]); - cpos = &ret[1]; + /* What follows is an iterative implementation (of what was previously done + * recursively in a dedicated function called "build_node". The old recursive + * build_node could be forced into stack exhaustion from input as small as a + * few megabyte, and so that was a security issue. Hence, a function call + * stack is avoided now by resolving recursion.) + * + * The iterative approach works as follows: + * + * - We have two writing pointers, both walking up the result array; one does + * the work, the other creates "jobs" for its colleague to do, and leads + * the way: + * + * - The faster one, pointer jobDest, always leads and writes "what job + * to do" by the other, once they reach that place in the + * array: leader "jobDest" stores the source node array index (relative + * to array dtd->scaffold) in field "numchildren". + * + * - The slower one, pointer dest, looks at the value stored in the + * "numchildren" field (which actually holds a source node array index + * at that time) and puts the real data from dtd->scaffold in. + * + * - Before the loop starts, jobDest writes source array index 0 + * (where the root node is located) so that dest will have something to do + * when it starts operation. + * + * - Whenever nodes with children are encountered, jobDest appends + * them as new jobs, in order. As a result, tree node siblings are + * adjacent in the resulting array, for example: + * + * [0] root, has two children + * [1] first child of 0, has three children + * [3] first child of 1, does not have children + * [4] second child of 1, does not have children + * [5] third child of 1, does not have children + * [2] second child of 0, does not have children + * + * Or (the same data) presented in flat array view: + * + * [0] root, has two children + * + * [1] first child of 0, has three children + * [2] second child of 0, does not have children + * + * [3] first child of 1, does not have children + * [4] second child of 1, does not have children + * [5] third child of 1, does not have children + * + * - The algorithm repeats until all target array indices have been processed. + */ + XML_Content *dest = ret; /* tree node writing location, moves upwards */ + XML_Content *const destLimit = &ret[dtd->scaffCount]; + XML_Content *jobDest = ret; /* next free writing location in target array */ + str = (XML_Char *)&ret[dtd->scaffCount]; + + /* Add the starting job, the root node (index 0) of the source tree */ + (jobDest++)->numchildren = 0; + + for (; dest < destLimit; dest++) { + /* Retrieve source tree array index from job storage */ + const int src_node = (int)dest->numchildren; + + /* Convert item */ + dest->type = dtd->scaffold[src_node].type; + dest->quant = dtd->scaffold[src_node].quant; + if (dest->type == XML_CTYPE_NAME) { + const XML_Char *src; + dest->name = str; + src = dtd->scaffold[src_node].name; + for (;;) { + *str++ = *src; + if (! *src) + break; + src++; + } + dest->numchildren = 0; + dest->children = NULL; + } else { + unsigned int i; + int cn; + dest->name = NULL; + dest->numchildren = dtd->scaffold[src_node].childcnt; + dest->children = jobDest; + + /* Append scaffold indices of children to array */ + for (i = 0, cn = dtd->scaffold[src_node].firstchild; + i < dest->numchildren; i++, cn = dtd->scaffold[cn].nextsib) + (jobDest++)->numchildren = (unsigned int)cn; + } + } - build_node(parser, 0, ret, &cpos, &str); return ret; } @@ -7412,7 +7483,7 @@ getElementType(XML_Parser parser, const ENCODING *enc, const char *ptr, static XML_Char * copyString(const XML_Char *s, const XML_Memory_Handling_Suite *memsuite) { - int charsRequired = 0; + size_t charsRequired = 0; XML_Char *result; /* First determine how long the string is */ diff --git a/Utilities/cmexpat/lib/xmlrole.c b/Utilities/cmexpat/lib/xmlrole.c index 77746ee..3f0f5c1 100644 --- a/Utilities/cmexpat/lib/xmlrole.c +++ b/Utilities/cmexpat/lib/xmlrole.c @@ -11,7 +11,7 @@ Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net> Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net> Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> - Copyright (c) 2005-2009 Steven Solie <ssolie@users.sourceforge.net> + Copyright (c) 2005-2009 Steven Solie <steven@solie.ca> Copyright (c) 2016-2021 Sebastian Pipping <sebastian@pipping.org> Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk> Copyright (c) 2019 David Loffredo <loffredo@steptools.com> diff --git a/Utilities/cmexpat/lib/xmltok.c b/Utilities/cmexpat/lib/xmltok.c index 502ca1a..c659983 100644 --- a/Utilities/cmexpat/lib/xmltok.c +++ b/Utilities/cmexpat/lib/xmltok.c @@ -11,8 +11,8 @@ Copyright (c) 2001-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net> Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net> - Copyright (c) 2005-2009 Steven Solie <ssolie@users.sourceforge.net> - Copyright (c) 2016-2021 Sebastian Pipping <sebastian@pipping.org> + Copyright (c) 2005-2009 Steven Solie <steven@solie.ca> + Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org> Copyright (c) 2016 Pascal Cuoq <cuoq@trust-in-soft.com> Copyright (c) 2016 Don Lewis <truckman@apache.org> Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk> @@ -98,11 +98,6 @@ + ((((byte)[1]) & 3) << 1) + ((((byte)[2]) >> 5) & 1)] \ & (1u << (((byte)[2]) & 0x1F))) -#define UTF8_GET_NAMING(pages, p, n) \ - ((n) == 2 \ - ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \ - : ((n) == 3 ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) : 0)) - /* Detection of invalid UTF-8 sequences is based on Table 3.1B of Unicode 3.2: http://www.unicode.org/unicode/reports/tr28/ with the additional restriction of not allowing the Unicode diff --git a/Utilities/cmexpat/lib/xmltok_impl.c b/Utilities/cmexpat/lib/xmltok_impl.c index 0430591..4072b06 100644 --- a/Utilities/cmexpat/lib/xmltok_impl.c +++ b/Utilities/cmexpat/lib/xmltok_impl.c @@ -10,7 +10,7 @@ Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net> Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net> - Copyright (c) 2016-2021 Sebastian Pipping <sebastian@pipping.org> + Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org> Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk> Copyright (c) 2018 Benjamin Peterson <benjamin@python.org> Copyright (c) 2018 Anton Maklakov <antmak.pub@gmail.com> @@ -69,7 +69,7 @@ case BT_LEAD##n: \ if (end - ptr < n) \ return XML_TOK_PARTIAL_CHAR; \ - if (! IS_NAME_CHAR(enc, ptr, n)) { \ + if (IS_INVALID_CHAR(enc, ptr, n) || ! IS_NAME_CHAR(enc, ptr, n)) { \ *nextTokPtr = ptr; \ return XML_TOK_INVALID; \ } \ @@ -98,7 +98,7 @@ case BT_LEAD##n: \ if (end - ptr < n) \ return XML_TOK_PARTIAL_CHAR; \ - if (! IS_NMSTRT_CHAR(enc, ptr, n)) { \ + if (IS_INVALID_CHAR(enc, ptr, n) || ! IS_NMSTRT_CHAR(enc, ptr, n)) { \ *nextTokPtr = ptr; \ return XML_TOK_INVALID; \ } \ @@ -1142,6 +1142,10 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, case BT_LEAD##n: \ if (end - ptr < n) \ return XML_TOK_PARTIAL_CHAR; \ + if (IS_INVALID_CHAR(enc, ptr, n)) { \ + *nextTokPtr = ptr; \ + return XML_TOK_INVALID; \ + } \ if (IS_NMSTRT_CHAR(enc, ptr, n)) { \ ptr += n; \ tok = XML_TOK_NAME; \ @@ -1270,7 +1274,7 @@ PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end, switch (BYTE_TYPE(enc, ptr)) { # define LEAD_CASE(n) \ case BT_LEAD##n: \ - ptr += n; \ + ptr += n; /* NOTE: The encoding has already been validated. */ \ break; LEAD_CASE(2) LEAD_CASE(3) @@ -1339,7 +1343,7 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end, switch (BYTE_TYPE(enc, ptr)) { # define LEAD_CASE(n) \ case BT_LEAD##n: \ - ptr += n; \ + ptr += n; /* NOTE: The encoding has already been validated. */ \ break; LEAD_CASE(2) LEAD_CASE(3) @@ -1518,7 +1522,7 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr, int attsMax, state = inName; \ } # define LEAD_CASE(n) \ - case BT_LEAD##n: \ + case BT_LEAD##n: /* NOTE: The encoding has already been validated. */ \ START_NAME ptr += (n - MINBPC(enc)); \ break; LEAD_CASE(2) @@ -1730,7 +1734,7 @@ PREFIX(nameLength)(const ENCODING *enc, const char *ptr) { switch (BYTE_TYPE(enc, ptr)) { # define LEAD_CASE(n) \ case BT_LEAD##n: \ - ptr += n; \ + ptr += n; /* NOTE: The encoding has already been validated. */ \ break; LEAD_CASE(2) LEAD_CASE(3) @@ -1775,7 +1779,7 @@ PREFIX(updatePosition)(const ENCODING *enc, const char *ptr, const char *end, switch (BYTE_TYPE(enc, ptr)) { # define LEAD_CASE(n) \ case BT_LEAD##n: \ - ptr += n; \ + ptr += n; /* NOTE: The encoding has already been validated. */ \ pos->columnNumber++; \ break; LEAD_CASE(2) |
