Skip to content

Commit

Permalink
KWSys 2023-11-29 (433f3d23)
Browse files Browse the repository at this point in the history
Code extracted from:

    https://gitlab.kitware.com/utils/kwsys.git

at commit 433f3d23ffa37f8fa6dd42468933f36c28a9e7fa (master).

Upstream Shortlog
-----------------

Ben Boeckel (2):
      46f47034 SharedForward: Drop this component of KWSys
      72e677e9 kwsysPrivate.h: Remove unused build-tree copy

Brad King (8):
      5df8c0a1 RegularExpression: Extend max paren groups from 10 to 32
      bfa688b5 SystemTools: Drop optional FindProgramPath arguments
      093d6e45 DynamicLoader: Update test to avoid using CMAKE_INTDIR
      c3201073 String.hxx: Drop this component of KWSys
      b4492d09 cmake: Drop use of legacy "Dart" module
      51272e80 SystemTools: Avoid macOS copyfile semantic differences as root
      199aa713 RegularExpression: Tell clang-analyzer that program memory is initialized
      9f9ff427 SystemTools: Teach RemoveADirectory to handle non-readable directories

Clemens Wasser (1):
      dd7d92d6 SystemTools: Implement GetEnv via GetEnvironmentVariableW on Win32

Timo Röhling (1):
      9119f1a1 SystemInformation: Tolerate empty /proc/cpuinfo

scivision (7):
      e76a8438 Remove try_compile logging in favor of CMake>=3.26 configure log
      12825be6 lint: use foreach(... IN {ITEMS,LISTS} ...)
      f10cb6ad lint: use modern add_test(NAME ... COMMAND ...)
      ebb95153 lint: set_property(TEST
      f26b1b39 SystemInformation: use std::cerr like rest of KWSys
      3c403fa9 SystemInformation: Replace C-style cast with reinterpret_cast
      7f4459d5 Comeau: Remove undocumented support for this compiler
  • Loading branch information
kwrobot authored and dzenanz committed Jan 24, 2024
1 parent e8b74bb commit 20e9839
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 1,104 deletions.
70 changes: 29 additions & 41 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,7 @@ endif()

# Enable testing if building standalone.
if(KWSYS_STANDALONE)
include(Dart)
mark_as_advanced(BUILD_TESTING DART_ROOT TCL_TCLSH)
if(BUILD_TESTING)
enable_testing()
endif()
include(CTest)
endif()

# Choose default shared/static build if not specified.
Expand Down Expand Up @@ -302,14 +298,6 @@ endif()
set(KWSYS_HEADER_INSTALL_DIR)
set(KWSYS_LIBRARY_INSTALL_DIR)

# Generated source files will need this header.
string(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}"
KWSYS_IN_SOURCE_BUILD)
if(NOT KWSYS_IN_SOURCE_BUILD)
configure_file(${PROJECT_SOURCE_DIR}/kwsysPrivate.h
${PROJECT_BINARY_DIR}/kwsysPrivate.h COPYONLY IMMEDIATE)
endif()

# Select plugin module file name convention.
if(NOT KWSYS_DynamicLoader_PREFIX)
set(KWSYS_DynamicLoader_PREFIX ${CMAKE_SHARED_MODULE_PREFIX})
Expand Down Expand Up @@ -630,15 +618,15 @@ endif()
# Build a list of classes and headers we need to implement the
# selected components. Initialize with required components.
set(KWSYS_CLASSES)
set(KWSYS_H_FILES Configure SharedForward)
set(KWSYS_HXX_FILES Configure String)
set(KWSYS_H_FILES Configure)
set(KWSYS_HXX_FILES Configure)

# Add selected C++ classes.
set(cppclasses
Directory DynamicLoader Encoding Glob RegularExpression SystemTools
CommandLineArguments FStream SystemInformation ConsoleBuf Status
)
foreach(cpp ${cppclasses})
foreach(cpp IN LISTS cppclasses)
if(KWSYS_USE_${cpp})
# Use the corresponding class.
set(KWSYS_CLASSES ${KWSYS_CLASSES} ${cpp})
Expand All @@ -651,7 +639,7 @@ foreach(cpp ${cppclasses})
endforeach()

# Add selected C components.
foreach(c
foreach(c IN ITEMS
Process Base64 Encoding MD5 Terminal System String
)
if(KWSYS_USE_${c})
Expand Down Expand Up @@ -683,7 +671,7 @@ if(KWSYS_USE_Process)
endif()

# Add selected C sources.
foreach(c Base64 Encoding MD5 Terminal System String)
foreach(c IN ITEMS Base64 Encoding MD5 Terminal System String)
if(KWSYS_USE_${c})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}C.c)
list(APPEND KWSYS_C_SRCS ${c}C.c)
Expand All @@ -694,7 +682,7 @@ foreach(c Base64 Encoding MD5 Terminal System String)
endforeach()

# Configure headers of C++ classes and construct the list of sources.
foreach(c ${KWSYS_CLASSES})
foreach(c IN LISTS KWSYS_CLASSES)
# Add this source to the list of source files for the library.
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}CXX.cxx)
list(APPEND KWSYS_CXX_SRCS ${c}CXX.cxx)
Expand All @@ -716,7 +704,7 @@ foreach(c ${KWSYS_CLASSES})
endforeach()

# Configure C headers.
foreach(h ${KWSYS_H_FILES})
foreach(h IN LISTS KWSYS_H_FILES)
# Configure the header into the given directory.
configure_file(${PROJECT_SOURCE_DIR}/${h}.h.in ${KWSYS_HEADER_DIR}/${h}.h
@ONLY IMMEDIATE)
Expand All @@ -731,7 +719,7 @@ foreach(h ${KWSYS_H_FILES})
endforeach()

# Configure other C++ headers.
foreach(h ${KWSYS_HXX_FILES})
foreach(h IN LISTS KWSYS_HXX_FILES)
# Configure the header into the given directory.
configure_file(${PROJECT_SOURCE_DIR}/${h}.hxx.in ${KWSYS_HEADER_DIR}/${h}.hxx
@ONLY IMMEDIATE)
Expand Down Expand Up @@ -960,9 +948,11 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
add_executable(${KWSYS_NAMESPACE}TestsC ${KWSYS_C_TEST_SRCS})
set_property(TARGET ${KWSYS_NAMESPACE}TestsC PROPERTY LABELS ${KWSYS_LABELS_EXE})
target_link_libraries(${KWSYS_NAMESPACE}TestsC ${KWSYS_TARGET_C_LINK})
foreach(testfile ${KWSYS_C_TESTS})
foreach(testfile IN LISTS KWSYS_C_TESTS)
get_filename_component(test "${testfile}" NAME_WE)
add_test(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}})
add_test(NAME kwsys.${test}
COMMAND ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}}
)
set_property(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
endforeach()

Expand Down Expand Up @@ -1038,6 +1028,10 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY CXX_INCLUDE_WHAT_YOU_USE "")
set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY LABELS ${KWSYS_LABELS_EXE})
target_link_libraries(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_TARGET_LINK})
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(_isMultiConfig)
set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx APPEND PROPERTY COMPILE_DEFINITIONS BUILD_CONFIG="$<CONFIG>")
endif()

set(TEST_SYSTEMTOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(TEST_SYSTEMTOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
Expand Down Expand Up @@ -1080,9 +1074,11 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
-p
some junk at the end
)
foreach(testfile ${KWSYS_CXX_TESTS})
foreach(testfile IN LISTS KWSYS_CXX_TESTS)
get_filename_component(test "${testfile}" NAME_WE)
add_test(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}})
add_test(NAME kwsys.${test}
COMMAND ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}}
)
set_property(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
endforeach()

Expand All @@ -1091,10 +1087,12 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
set_property(TARGET ${KWSYS_NAMESPACE}TestProcess PROPERTY LABELS ${KWSYS_LABELS_EXE})
target_link_libraries(${KWSYS_NAMESPACE}TestProcess ${KWSYS_TARGET_C_LINK})
#set(KWSYS_TEST_PROCESS_7 7) # uncomment to run timing-sensitive test locally
foreach(n 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7} 9 10)
add_test(kwsys.testProcess-${n} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n})
foreach(n IN ITEMS 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7} 9 10)
add_test(NAME kwsys.testProcess-${n}
COMMAND ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n}
)
set_property(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST})
set_tests_properties(kwsys.testProcess-${n} PROPERTIES TIMEOUT 120)
set_property(TEST kwsys.testProcess-${n} PROPERTY TIMEOUT 120)
endforeach()

set(testProcess_COMPILE_FLAGS "")
Expand All @@ -1118,22 +1116,12 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
endif()
set_property(SOURCE testProcess.c PROPERTY COMPILE_FLAGS "${testProcess_COMPILE_FLAGS}")

# Test SharedForward
configure_file(${PROJECT_SOURCE_DIR}/testSharedForward.c.in
${PROJECT_BINARY_DIR}/testSharedForward.c @ONLY IMMEDIATE)
add_executable(${KWSYS_NAMESPACE}TestSharedForward
${PROJECT_BINARY_DIR}/testSharedForward.c)
set_property(TARGET ${KWSYS_NAMESPACE}TestSharedForward PROPERTY LABELS ${KWSYS_LABELS_EXE})
add_dependencies(${KWSYS_NAMESPACE}TestSharedForward ${KWSYS_TARGET_C_LINK})
add_test(kwsys.testSharedForward ${EXEC_DIR}/${KWSYS_NAMESPACE}TestSharedForward 1)
set_property(TEST kwsys.testSharedForward PROPERTY LABELS ${KWSYS_LABELS_TEST})

# Configure some test properties.
if(KWSYS_STANDALONE)
# We expect test to fail
set_tests_properties(kwsys.testFail PROPERTIES WILL_FAIL ON)
set_property(TEST kwsys.testFail PROPERTY WILL_FAIL ON)
get_test_property(kwsys.testFail WILL_FAIL wfv)
set_tests_properties(kwsys.testFail PROPERTIES MEASUREMENT "Some Key=Some Value")
set_property(TEST kwsys.testFail PROPERTY MEASUREMENT "Some Key=Some Value")
message(STATUS "GET_TEST_PROPERTY returned: ${wfv}")
endif()

Expand All @@ -1143,7 +1131,7 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)

# Suppress known consistent failures on buggy systems.
if(KWSYS_TEST_BOGUS_FAILURES)
set_tests_properties(${KWSYS_TEST_BOGUS_FAILURES} PROPERTIES WILL_FAIL ON)
set_property(TEST ${KWSYS_TEST_BOGUS_FAILURES} PROPERTY WILL_FAIL ON)
endif()

endif()
Expand Down
13 changes: 6 additions & 7 deletions CommandLineArguments.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
#include KWSYS_HEADER(CommandLineArguments.hxx)

#include KWSYS_HEADER(Configure.hxx)
#include KWSYS_HEADER(String.hxx)

// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
# include "CommandLineArguments.hxx.in"
# include "Configure.hxx.in"
# include "String.hxx.in"
#endif

#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#include <cstdio>
Expand Down Expand Up @@ -52,14 +51,14 @@ struct CommandLineArgumentsCallbackStructure
const char* Help;
};

class CommandLineArgumentsVectorOfStrings : public std::vector<kwsys::String>
class CommandLineArgumentsVectorOfStrings : public std::vector<std::string>
{
};
class CommandLineArgumentsSetOfStrings : public std::set<kwsys::String>
class CommandLineArgumentsSetOfStrings : public std::set<std::string>
{
};
class CommandLineArgumentsMapOfStrucs
: public std::map<kwsys::String, CommandLineArgumentsCallbackStructure>
: public std::map<std::string, CommandLineArgumentsCallbackStructure>
{
};

Expand All @@ -70,7 +69,7 @@ class CommandLineArgumentsInternal

using VectorOfStrings = CommandLineArgumentsVectorOfStrings;
using CallbacksMap = CommandLineArgumentsMapOfStrucs;
using String = kwsys::String;
using String = std::string;
using SetOfStrings = CommandLineArgumentsSetOfStrings;

VectorOfStrings Argv;
Expand Down Expand Up @@ -306,7 +305,7 @@ void CommandLineArguments::GetUnusedArguments(int* argc, char*** argv)

// Copy everything after the LastArgument, since that was not parsed.
for (cc = 0; cc < this->Internals->UnusedArguments.size(); cc++) {
kwsys::String& str = this->Internals->UnusedArguments[cc];
std::string& str = this->Internals->UnusedArguments[cc];
args[cnt] = new char[str.size() + 1];
strcpy(args[cnt], str.c_str());
cnt++;
Expand Down
56 changes: 53 additions & 3 deletions RegularExpression.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ bool RegularExpression::deep_equal(const RegularExpression& rxp) const
20 // no Mark this point in input as start of
// #n.
// OPEN+1 is number 1, etc.
#define CLOSE 30 // no Analogous to OPEN.
#define CLOSE 52 // no Analogous to OPEN.

/*
* Opcode notes:
Expand Down Expand Up @@ -378,6 +378,10 @@ bool RegularExpression::compile(const char* exp)
return false;
}

#ifdef __clang_analyzer__ /* Convince it that the program is initialized. */
memset(this->program, 0, comp.regsize);
#endif

// Second pass: emit code.
comp.regparse = exp;
comp.regnpar = 1;
Expand Down Expand Up @@ -1018,7 +1022,30 @@ int RegExpFind::regmatch(const char* prog)
case OPEN + 6:
case OPEN + 7:
case OPEN + 8:
case OPEN + 9: {
case OPEN + 9:
case OPEN + 10:
case OPEN + 11:
case OPEN + 12:
case OPEN + 13:
case OPEN + 14:
case OPEN + 15:
case OPEN + 16:
case OPEN + 17:
case OPEN + 18:
case OPEN + 19:
case OPEN + 20:
case OPEN + 21:
case OPEN + 22:
case OPEN + 23:
case OPEN + 24:
case OPEN + 25:
case OPEN + 26:
case OPEN + 27:
case OPEN + 28:
case OPEN + 29:
case OPEN + 30:
case OPEN + 31:
case OPEN + 32: {
int no;
const char* save;

Expand Down Expand Up @@ -1046,7 +1073,30 @@ int RegExpFind::regmatch(const char* prog)
case CLOSE + 6:
case CLOSE + 7:
case CLOSE + 8:
case CLOSE + 9: {
case CLOSE + 9:
case CLOSE + 10:
case CLOSE + 11:
case CLOSE + 12:
case CLOSE + 13:
case CLOSE + 14:
case CLOSE + 15:
case CLOSE + 16:
case CLOSE + 17:
case CLOSE + 18:
case CLOSE + 19:
case CLOSE + 20:
case CLOSE + 21:
case CLOSE + 22:
case CLOSE + 23:
case CLOSE + 24:
case CLOSE + 25:
case CLOSE + 26:
case CLOSE + 27:
case CLOSE + 28:
case CLOSE + 29:
case CLOSE + 30:
case CLOSE + 31:
case CLOSE + 32: {
int no;
const char* save;

Expand Down
2 changes: 1 addition & 1 deletion RegularExpression.hxx.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public:

enum
{
NSUBEXP = 10
NSUBEXP = 32
};

private:
Expand Down
Loading

0 comments on commit 20e9839

Please sign in to comment.