summaryrefslogtreecommitdiff
path: root/Source/kwsys
diff options
context:
space:
mode:
Diffstat (limited to 'Source/kwsys')
-rw-r--r--Source/kwsys/Base64.c5
-rw-r--r--Source/kwsys/CMakeLists.txt1317
-rw-r--r--Source/kwsys/CommandLineArguments.cxx44
-rw-r--r--Source/kwsys/Configure.h.in8
-rw-r--r--Source/kwsys/Directory.cxx83
-rw-r--r--Source/kwsys/Directory.hxx.in15
-rw-r--r--Source/kwsys/DynamicLoader.cxx22
-rw-r--r--Source/kwsys/EncodingCXX.cxx4
-rw-r--r--Source/kwsys/ExtraTest.cmake.in2
-rw-r--r--Source/kwsys/Glob.cxx26
-rw-r--r--Source/kwsys/Glob.hxx.in1
-rw-r--r--Source/kwsys/IOStream.cxx255
-rw-r--r--Source/kwsys/IOStream.hxx.in126
-rw-r--r--Source/kwsys/MD5.c30
-rw-r--r--Source/kwsys/Process.h.in4
-rw-r--r--Source/kwsys/ProcessUNIX.c227
-rw-r--r--Source/kwsys/ProcessWin32.c10
-rw-r--r--Source/kwsys/RegularExpression.cxx7
-rw-r--r--Source/kwsys/RegularExpression.hxx.in6
-rw-r--r--Source/kwsys/SharedForward.h.in6
-rw-r--r--Source/kwsys/String.hxx.in8
-rw-r--r--Source/kwsys/System.c2
-rw-r--r--Source/kwsys/SystemInformation.cxx394
-rw-r--r--Source/kwsys/SystemInformation.hxx.in21
-rw-r--r--Source/kwsys/SystemTools.cxx406
-rw-r--r--Source/kwsys/SystemTools.hxx.in41
-rw-r--r--Source/kwsys/hash_fun.hxx.in166
-rw-r--r--Source/kwsys/hash_map.hxx.in423
-rw-r--r--Source/kwsys/hash_set.hxx.in392
-rw-r--r--Source/kwsys/hashtable.hxx.in995
-rw-r--r--Source/kwsys/kwsysPlatformTests.cmake300
-rw-r--r--Source/kwsys/kwsysPlatformTestsC.c37
-rw-r--r--Source/kwsys/kwsysPlatformTestsCXX.cxx161
-rw-r--r--Source/kwsys/testCommandLineArguments.cxx6
-rw-r--r--Source/kwsys/testCommandLineArguments1.cxx10
-rw-r--r--Source/kwsys/testDirectory.cxx37
-rw-r--r--Source/kwsys/testDynamicLoader.cxx2
-rw-r--r--Source/kwsys/testDynload.c2
-rw-r--r--Source/kwsys/testEncoding.cxx27
-rw-r--r--Source/kwsys/testFStream.cxx5
-rw-r--r--Source/kwsys/testHashSTL.cxx64
-rw-r--r--Source/kwsys/testProcess.c17
-rw-r--r--Source/kwsys/testSystemInformation.cxx18
-rw-r--r--Source/kwsys/testSystemTools.cxx112
-rw-r--r--Source/kwsys/testSystemTools.h.in2
45 files changed, 1606 insertions, 4240 deletions
diff --git a/Source/kwsys/Base64.c b/Source/kwsys/Base64.c
index bf876f2d5..42650184a 100644
--- a/Source/kwsys/Base64.c
+++ b/Source/kwsys/Base64.c
@@ -130,7 +130,10 @@ size_t kwsysBase64_Encode(const unsigned char* input, size_t length,
/* Decode 4 bytes into a 3 byte string. */
int kwsysBase64_Decode3(const unsigned char* src, unsigned char* dest)
{
- unsigned char d0, d1, d2, d3;
+ unsigned char d0;
+ unsigned char d1;
+ unsigned char d2;
+ unsigned char d3;
d0 = kwsysBase64DecodeChar(src[0]);
d1 = kwsysBase64DecodeChar(src[1]);
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 09bcdb943..b0a854292 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -11,9 +11,9 @@
# be used. All classes are disabled by default. The CMake listfile
# above this one configures the library as follows:
#
-# SET(KWSYS_NAMESPACE foosys)
-# SET(KWSYS_USE_Directory 1) # Enable Directory class.
-# SUBDIRS(kwsys)
+# set(KWSYS_NAMESPACE foosys)
+# set(KWSYS_USE_Directory 1) # Enable Directory class.
+# add_subdirectory(kwsys)
#
# Optional settings are as follows:
#
@@ -39,8 +39,8 @@
#
# Example:
#
-# SET(KWSYS_HEADER_ROOT ${PROJECT_BINARY_DIR})
-# INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
+# set(KWSYS_HEADER_ROOT ${PROJECT_BINARY_DIR})
+# include_directories(${PROJECT_BINARY_DIR})
#
# KWSYS_CXX_STANDARD = A value for CMAKE_CXX_STANDARD within KWSys.
# Set to empty string to use no default value.
@@ -65,11 +65,11 @@
#
# Example:
#
-# SET(KWSYS_INSTALL_BIN_DIR bin)
-# SET(KWSYS_INSTALL_LIB_DIR lib)
-# SET(KWSYS_INSTALL_INCLUDE_DIR include)
-# SET(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME Runtime)
-# SET(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT Development)
+# set(KWSYS_INSTALL_BIN_DIR bin)
+# set(KWSYS_INSTALL_LIB_DIR lib)
+# set(KWSYS_INSTALL_INCLUDE_DIR include)
+# set(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME Runtime)
+# set(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT Development)
# Once configured, kwsys should be used as follows from C or C++ code:
#
@@ -86,33 +86,33 @@
# any outside mailing list and no documentation of the change will be
# written.
-CMAKE_MINIMUM_REQUIRED(VERSION 3.1 FATAL_ERROR)
-FOREACH(p
+cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
+foreach(p
CMP0056 # CMake 3.2, Honor link flags in try_compile() source-file signature.
CMP0063 # CMake 3.3, Honor visibility properties for all target types.
CMP0067 # CMake 3.8, Honor language standard in try_compile source-file signature.
CMP0069 # CMake 3.9, INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.
)
- IF(POLICY ${p})
- CMAKE_POLICY(SET ${p} NEW)
- ENDIF()
-ENDFOREACH()
+ if(POLICY ${p})
+ cmake_policy(SET ${p} NEW)
+ endif()
+endforeach()
#-----------------------------------------------------------------------------
# If a namespace is not specified, use "kwsys" and enable testing.
# This should be the case only when kwsys is not included inside
# another project and is being tested.
-IF(NOT KWSYS_NAMESPACE)
- SET(KWSYS_NAMESPACE "kwsys")
- SET(KWSYS_STANDALONE 1)
-ENDIF()
+if(NOT KWSYS_NAMESPACE)
+ set(KWSYS_NAMESPACE "kwsys")
+ set(KWSYS_STANDALONE 1)
+endif()
#-----------------------------------------------------------------------------
# The project name is that of the specified namespace.
-PROJECT(${KWSYS_NAMESPACE})
+project(${KWSYS_NAMESPACE})
# Tell CMake how to follow dependencies of sources in this directory.
-SET_PROPERTY(DIRECTORY
+set_property(DIRECTORY
PROPERTY IMPLICIT_DEPENDS_INCLUDE_TRANSFORM
"KWSYS_HEADER(%)=<${KWSYS_NAMESPACE}/%>"
)
@@ -131,309 +131,253 @@ elseif(NOT DEFINED CMAKE_CXX_STANDARD AND NOT DEFINED KWSYS_CXX_STANDARD)
endif()
# Select library components.
-IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
- SET(KWSYS_ENABLE_C 1)
+if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
+ set(KWSYS_ENABLE_C 1)
# Enable all components.
- SET(KWSYS_USE_Base64 1)
- SET(KWSYS_USE_Directory 1)
- SET(KWSYS_USE_DynamicLoader 1)
- SET(KWSYS_USE_Encoding 1)
- SET(KWSYS_USE_Glob 1)
- SET(KWSYS_USE_MD5 1)
- SET(KWSYS_USE_Process 1)
- SET(KWSYS_USE_RegularExpression 1)
- SET(KWSYS_USE_System 1)
- SET(KWSYS_USE_SystemTools 1)
- SET(KWSYS_USE_CommandLineArguments 1)
- SET(KWSYS_USE_Terminal 1)
- SET(KWSYS_USE_IOStream 1)
- SET(KWSYS_USE_FStream 1)
- SET(KWSYS_USE_String 1)
- SET(KWSYS_USE_SystemInformation 1)
- SET(KWSYS_USE_ConsoleBuf 1)
-ENDIF()
+ set(KWSYS_USE_Base64 1)
+ set(KWSYS_USE_Directory 1)
+ set(KWSYS_USE_DynamicLoader 1)
+ set(KWSYS_USE_Encoding 1)
+ set(KWSYS_USE_Glob 1)
+ set(KWSYS_USE_MD5 1)
+ set(KWSYS_USE_Process 1)
+ set(KWSYS_USE_RegularExpression 1)
+ set(KWSYS_USE_System 1)
+ set(KWSYS_USE_SystemTools 1)
+ set(KWSYS_USE_CommandLineArguments 1)
+ set(KWSYS_USE_Terminal 1)
+ set(KWSYS_USE_FStream 1)
+ set(KWSYS_USE_String 1)
+ set(KWSYS_USE_SystemInformation 1)
+ set(KWSYS_USE_ConsoleBuf 1)
+endif()
# Enforce component dependencies.
-IF(KWSYS_USE_SystemTools)
- SET(KWSYS_USE_Directory 1)
- SET(KWSYS_USE_FStream 1)
- SET(KWSYS_USE_Encoding 1)
-ENDIF()
-IF(KWSYS_USE_Glob)
- SET(KWSYS_USE_Directory 1)
- SET(KWSYS_USE_SystemTools 1)
- SET(KWSYS_USE_RegularExpression 1)
- SET(KWSYS_USE_FStream 1)
- SET(KWSYS_USE_Encoding 1)
-ENDIF()
-IF(KWSYS_USE_Process)
- SET(KWSYS_USE_System 1)
- SET(KWSYS_USE_Encoding 1)
-ENDIF()
-IF(KWSYS_USE_SystemInformation)
- SET(KWSYS_USE_Process 1)
-ENDIF()
-IF(KWSYS_USE_System)
- SET(KWSYS_USE_Encoding 1)
-ENDIF()
-IF(KWSYS_USE_Directory)
- SET(KWSYS_USE_Encoding 1)
-ENDIF()
-IF(KWSYS_USE_DynamicLoader)
- SET(KWSYS_USE_Encoding 1)
-ENDIF()
-IF(KWSYS_USE_FStream)
- SET(KWSYS_USE_Encoding 1)
-ENDIF()
-IF(KWSYS_USE_ConsoleBuf)
- SET(KWSYS_USE_Encoding 1)
-ENDIF()
+if(KWSYS_USE_SystemTools)
+ set(KWSYS_USE_Directory 1)
+ set(KWSYS_USE_FStream 1)
+ set(KWSYS_USE_Encoding 1)
+endif()
+if(KWSYS_USE_Glob)
+ set(KWSYS_USE_Directory 1)
+ set(KWSYS_USE_SystemTools 1)
+ set(KWSYS_USE_RegularExpression 1)
+ set(KWSYS_USE_FStream 1)
+ set(KWSYS_USE_Encoding 1)
+endif()
+if(KWSYS_USE_Process)
+ set(KWSYS_USE_System 1)
+ set(KWSYS_USE_Encoding 1)
+endif()
+if(KWSYS_USE_SystemInformation)
+ set(KWSYS_USE_Process 1)
+endif()
+if(KWSYS_USE_System)
+ set(KWSYS_USE_Encoding 1)
+endif()
+if(KWSYS_USE_Directory)
+ set(KWSYS_USE_Encoding 1)
+endif()
+if(KWSYS_USE_DynamicLoader)
+ set(KWSYS_USE_Encoding 1)
+endif()
+if(KWSYS_USE_FStream)
+ set(KWSYS_USE_Encoding 1)
+endif()
+if(KWSYS_USE_ConsoleBuf)
+ set(KWSYS_USE_Encoding 1)
+endif()
# Specify default 8 bit encoding for Windows
-IF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE)
- SET(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_ACP)
-ENDIF()
+if(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE)
+ set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_ACP)
+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()
-ENDIF()
+if(KWSYS_STANDALONE)
+ include(Dart)
+ mark_as_advanced(BUILD_TESTING DART_ROOT TCL_TCLSH)
+ if(BUILD_TESTING)
+ enable_testing()
+ endif()
+endif()
# Choose default shared/static build if not specified.
-IF(NOT DEFINED KWSYS_BUILD_SHARED)
- SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS})
-ENDIF()
+if(NOT DEFINED KWSYS_BUILD_SHARED)
+ set(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS})
+endif()
# Include helper macros.
-INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformTests.cmake)
-INCLUDE(CheckTypeSize)
+include(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformTests.cmake)
+include(CheckTypeSize)
# Do full dependency headers.
-INCLUDE_REGULAR_EXPRESSION("^.*$")
+include_regular_expression("^.*$")
# Use new KWSYS_INSTALL_*_DIR variable names to control installation.
# Take defaults from the old names. Note that there was no old name
# for the bin dir, so we take the old lib dir name so DLLs will be
# installed in a compatible way for old code.
-IF(NOT KWSYS_INSTALL_INCLUDE_DIR)
- STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_INCLUDE_DIR
+if(NOT KWSYS_INSTALL_INCLUDE_DIR)
+ string(REGEX REPLACE "^/" "" KWSYS_INSTALL_INCLUDE_DIR
"${KWSYS_HEADER_INSTALL_DIR}")
-ENDIF()
-IF(NOT KWSYS_INSTALL_LIB_DIR)
- STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_LIB_DIR
+endif()
+if(NOT KWSYS_INSTALL_LIB_DIR)
+ string(REGEX REPLACE "^/" "" KWSYS_INSTALL_LIB_DIR
"${KWSYS_LIBRARY_INSTALL_DIR}")
-ENDIF()
-IF(NOT KWSYS_INSTALL_BIN_DIR)
- STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_BIN_DIR
+endif()
+if(NOT KWSYS_INSTALL_BIN_DIR)
+ string(REGEX REPLACE "^/" "" KWSYS_INSTALL_BIN_DIR
"${KWSYS_LIBRARY_INSTALL_DIR}")
-ENDIF()
+endif()
# Setup header install rules.
-SET(KWSYS_INSTALL_INCLUDE_OPTIONS)
-IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
- SET(KWSYS_INSTALL_INCLUDE_OPTIONS ${KWSYS_INSTALL_INCLUDE_OPTIONS}
+set(KWSYS_INSTALL_INCLUDE_OPTIONS)
+if(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
+ set(KWSYS_INSTALL_INCLUDE_OPTIONS ${KWSYS_INSTALL_INCLUDE_OPTIONS}
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
)
-ENDIF()
+endif()
# Setup library install rules.
-SET(KWSYS_INSTALL_LIBRARY_RULE)
-SET(KWSYS_INSTALL_NAMELINK_RULE)
-IF(KWSYS_INSTALL_LIB_DIR)
- IF(KWSYS_INSTALL_EXPORT_NAME)
- LIST(APPEND KWSYS_INSTALL_LIBRARY_RULE EXPORT ${KWSYS_INSTALL_EXPORT_NAME})
- ENDIF()
+set(KWSYS_INSTALL_LIBRARY_RULE)
+set(KWSYS_INSTALL_NAMELINK_RULE)
+if(KWSYS_INSTALL_LIB_DIR)
+ if(KWSYS_INSTALL_EXPORT_NAME)
+ list(APPEND KWSYS_INSTALL_LIBRARY_RULE EXPORT ${KWSYS_INSTALL_EXPORT_NAME})
+ endif()
# Install the shared library to the lib directory.
- SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
+ set(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR} NAMELINK_SKIP
)
# Assign the shared library to the runtime component.
- IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
- SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
+ if(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
+ set(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
)
- ENDIF()
- IF(KWSYS_BUILD_SHARED)
- SET(KWSYS_INSTALL_NAMELINK_RULE ${KWSYS_INSTALL_NAMELINK_RULE}
+ endif()
+ if(KWSYS_BUILD_SHARED)
+ set(KWSYS_INSTALL_NAMELINK_RULE ${KWSYS_INSTALL_NAMELINK_RULE}
LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR} NAMELINK_ONLY
)
# Assign the namelink to the development component.
- IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
- SET(KWSYS_INSTALL_NAMELINK_RULE ${KWSYS_INSTALL_NAMELINK_RULE}
+ if(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
+ set(KWSYS_INSTALL_NAMELINK_RULE ${KWSYS_INSTALL_NAMELINK_RULE}
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
)
- ENDIF()
- ENDIF()
+ endif()
+ endif()
# Install the archive to the lib directory.
- SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
+ set(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
ARCHIVE DESTINATION ${KWSYS_INSTALL_LIB_DIR}
)
# Assign the archive to the development component.
- IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
- SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
+ if(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
+ set(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
)
- ENDIF()
-ENDIF()
-IF(KWSYS_INSTALL_BIN_DIR)
+ endif()
+endif()
+if(KWSYS_INSTALL_BIN_DIR)
# Install the runtime library to the bin directory.
- SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
+ set(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
RUNTIME DESTINATION ${KWSYS_INSTALL_BIN_DIR}
)
# Assign the runtime library to the runtime component.
- IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
- SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
+ if(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
+ set(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
)
- ENDIF()
-ENDIF()
+ endif()
+endif()
# Do not support old KWSYS_*a_INSTALL_DIR variable names.
-SET(KWSYS_HEADER_INSTALL_DIR)
-SET(KWSYS_LIBRARY_INSTALL_DIR)
+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}"
+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
+if(NOT KWSYS_IN_SOURCE_BUILD)
+ configure_file(${PROJECT_SOURCE_DIR}/kwsysPrivate.h
${PROJECT_BINARY_DIR}/kwsysPrivate.h COPYONLY IMMEDIATE)
-ENDIF()
+endif()
# Select plugin module file name convention.
-IF(NOT KWSYS_DynamicLoader_PREFIX)
- SET(KWSYS_DynamicLoader_PREFIX ${CMAKE_SHARED_MODULE_PREFIX})
-ENDIF()
-IF(NOT KWSYS_DynamicLoader_SUFFIX)
- SET(KWSYS_DynamicLoader_SUFFIX ${CMAKE_SHARED_MODULE_SUFFIX})
-ENDIF()
+if(NOT KWSYS_DynamicLoader_PREFIX)
+ set(KWSYS_DynamicLoader_PREFIX ${CMAKE_SHARED_MODULE_PREFIX})
+endif()
+if(NOT KWSYS_DynamicLoader_SUFFIX)
+ set(KWSYS_DynamicLoader_SUFFIX ${CMAKE_SHARED_MODULE_SUFFIX})
+endif()
#-----------------------------------------------------------------------------
# We require ANSI support from the C compiler. Add any needed flags.
-IF(CMAKE_ANSI_CFLAGS)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
-ENDIF()
+if(CMAKE_ANSI_CFLAGS)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
+endif()
#-----------------------------------------------------------------------------
# Adjust compiler flags for some platforms.
-IF(NOT CMAKE_COMPILER_IS_GNUCXX)
- IF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
- STRING(REGEX MATCH "-timplicit_local"
+if(NOT CMAKE_COMPILER_IS_GNUCXX)
+ if(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+ string(REGEX MATCH "-timplicit_local"
KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL "${CMAKE_CXX_FLAGS}")
- STRING(REGEX MATCH "-no_implicit_include"
+ string(REGEX MATCH "-no_implicit_include"
KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE "${CMAKE_CXX_FLAGS}")
- IF(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local")
- ENDIF()
- IF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no_implicit_include")
- ENDIF()
- ENDIF()
- IF(CMAKE_SYSTEM MATCHES "HP-UX")
- SET(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p")
- IF(CMAKE_CXX_COMPILER_ID MATCHES "HP")
+ if(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local")
+ endif()
+ if(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no_implicit_include")
+ endif()
+ endif()
+ if(CMAKE_SYSTEM MATCHES "HP-UX")
+ set(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p")
+ if(CMAKE_CXX_COMPILER_ID MATCHES "HP")
# it is known that version 3.85 fails and 6.25 works without these flags
- IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4)
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4)
# use new C++ library and improved template support
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98")
- ENDIF()
- ENDIF()
- ENDIF()
-ENDIF()
-IF(KWSYS_STANDALONE)
- IF(CMAKE_CXX_COMPILER_ID STREQUAL SunPro)
- IF(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")
- ELSE()
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stlport4")
- ENDIF()
- ENDIF()
-ENDIF()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98")
+ endif()
+ endif()
+ endif()
+endif()
+if(KWSYS_STANDALONE)
+ if(CMAKE_CXX_COMPILER_ID STREQUAL SunPro)
+ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")
+ else()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stlport4")
+ endif()
+ endif()
+endif()
#-----------------------------------------------------------------------------
# Configure the standard library header wrappers based on compiler's
# capabilities and parent project's request. Enforce 0/1 as only
# possible values for configuration into Configure.hxx.
-# Check existence and uniqueness of long long and __int64.
-KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_LONG_LONG
- "Checking whether C++ compiler has 'long long'" DIRECT)
-KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS___INT64
- "Checking whether C++ compiler has '__int64'" DIRECT)
-IF(KWSYS_CXX_HAS___INT64)
- KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_SAME_LONG_AND___INT64
- "Checking whether long and __int64 are the same type" DIRECT)
- IF(KWSYS_CXX_HAS_LONG_LONG)
- KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_SAME_LONG_LONG_AND___INT64
- "Checking whether long long and __int64 are the same type" DIRECT)
- ENDIF()
-ENDIF()
-
-# Enable the "long long" type if it is available. It is standard in
-# C99 and C++03 but not in earlier standards.
-IF(KWSYS_CXX_HAS_LONG_LONG)
- SET(KWSYS_USE_LONG_LONG 1)
-ELSE()
- SET(KWSYS_USE_LONG_LONG 0)
-ENDIF()
-
-# Enable the "__int64" type if it is available and unique. It is not
-# standard.
-SET(KWSYS_USE___INT64 0)
-IF(KWSYS_CXX_HAS___INT64)
- IF(NOT KWSYS_CXX_SAME_LONG_AND___INT64)
- IF(NOT KWSYS_CXX_SAME_LONG_LONG_AND___INT64)
- SET(KWSYS_USE___INT64 1)
- ENDIF()
- ENDIF()
-ENDIF()
-
-IF(KWSYS_USE_Encoding)
+if(KWSYS_USE_Encoding)
# Look for type size helper macros.
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_WSTRING
"Checking whether wstring is available" DIRECT)
-ENDIF()
-
-IF(KWSYS_USE_IOStream)
- # Determine whether iostreams support long long.
- IF(KWSYS_CXX_HAS_LONG_LONG)
- KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_ISTREAM_LONG_LONG
- "Checking if istream supports long long" DIRECT)
- KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_OSTREAM_LONG_LONG
- "Checking if ostream supports long long" DIRECT)
- ELSE()
- SET(KWSYS_IOS_HAS_ISTREAM_LONG_LONG 0)
- SET(KWSYS_IOS_HAS_OSTREAM_LONG_LONG 0)
- ENDIF()
- IF(KWSYS_CXX_HAS___INT64)
- KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_ISTREAM___INT64
- "Checking if istream supports __int64" DIRECT)
- KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_OSTREAM___INT64
- "Checking if ostream supports __int64" DIRECT)
- ELSE()
- SET(KWSYS_IOS_HAS_ISTREAM___INT64 0)
- SET(KWSYS_IOS_HAS_OSTREAM___INT64 0)
- ENDIF()
-ENDIF()
-
-IF(KWSYS_NAMESPACE MATCHES "^kwsys$")
- SET(KWSYS_NAME_IS_KWSYS 1)
-ELSE()
- SET(KWSYS_NAME_IS_KWSYS 0)
-ENDIF()
-
-IF(KWSYS_BUILD_SHARED)
- SET(KWSYS_BUILD_SHARED 1)
- SET(KWSYS_LIBRARY_TYPE SHARED)
-ELSE()
- SET(KWSYS_BUILD_SHARED 0)
- SET(KWSYS_LIBRARY_TYPE STATIC)
-ENDIF()
+endif()
+
+if(KWSYS_NAMESPACE MATCHES "^kwsys$")
+ set(KWSYS_NAME_IS_KWSYS 1)
+else()
+ set(KWSYS_NAME_IS_KWSYS 0)
+endif()
+
+if(KWSYS_BUILD_SHARED)
+ set(KWSYS_BUILD_SHARED 1)
+ set(KWSYS_LIBRARY_TYPE SHARED)
+else()
+ set(KWSYS_BUILD_SHARED 0)
+ set(KWSYS_LIBRARY_TYPE STATIC)
+endif()
if(NOT DEFINED KWSYS_BUILD_PIC)
set(KWSYS_BUILD_PIC 0)
@@ -446,32 +390,32 @@ KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_PTRDIFF_T
"Checking whether C compiler has ptrdiff_t in stddef.h" DIRECT)
KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_SSIZE_T
"Checking whether C compiler has ssize_t in unistd.h" DIRECT)
-IF(KWSYS_USE_Process)
+if(KWSYS_USE_Process)
KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC
"Checking whether C compiler has clock_gettime" DIRECT)
-ENDIF()
+endif()
-SET_SOURCE_FILES_PROPERTIES(ProcessUNIX.c System.c PROPERTIES
+set_source_files_properties(ProcessUNIX.c System.c PROPERTIES
COMPILE_FLAGS "-DKWSYS_C_HAS_PTRDIFF_T=${KWSYS_C_HAS_PTRDIFF_T} -DKWSYS_C_HAS_SSIZE_T=${KWSYS_C_HAS_SSIZE_T} -DKWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC=${KWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC}"
)
-IF(DEFINED KWSYS_PROCESS_USE_SELECT)
- GET_PROPERTY(ProcessUNIX_FLAGS SOURCE ProcessUNIX.c PROPERTY COMPILE_FLAGS)
- SET_PROPERTY(SOURCE ProcessUNIX.c PROPERTY COMPILE_FLAGS "${ProcessUNIX_FLAGS} -DKWSYSPE_USE_SELECT=${KWSYSPE_USE_SELECT}")
-ENDIF()
-
-IF(KWSYS_USE_DynamicLoader)
- GET_PROPERTY(KWSYS_SUPPORTS_SHARED_LIBS GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
- IF(KWSYS_SUPPORTS_SHARED_LIBS)
- SET(KWSYS_SUPPORTS_SHARED_LIBS 1)
- ELSE()
- SET(KWSYS_SUPPORTS_SHARED_LIBS 0)
- ENDIF()
- SET_PROPERTY(SOURCE DynamicLoader.cxx APPEND PROPERTY COMPILE_DEFINITIONS
+if(DEFINED KWSYS_PROCESS_USE_SELECT)
+ get_property(ProcessUNIX_FLAGS SOURCE ProcessUNIX.c PROPERTY COMPILE_FLAGS)
+ set_property(SOURCE ProcessUNIX.c PROPERTY COMPILE_FLAGS "${ProcessUNIX_FLAGS} -DKWSYSPE_USE_SELECT=${KWSYSPE_USE_SELECT}")
+endif()
+
+if(KWSYS_USE_DynamicLoader)
+ get_property(KWSYS_SUPPORTS_SHARED_LIBS GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
+ if(KWSYS_SUPPORTS_SHARED_LIBS)
+ set(KWSYS_SUPPORTS_SHARED_LIBS 1)
+ else()
+ set(KWSYS_SUPPORTS_SHARED_LIBS 0)
+ endif()
+ set_property(SOURCE DynamicLoader.cxx APPEND PROPERTY COMPILE_DEFINITIONS
KWSYS_SUPPORTS_SHARED_LIBS=${KWSYS_SUPPORTS_SHARED_LIBS})
-ENDIF()
+endif()
-IF(KWSYS_USE_SystemTools)
+if(KWSYS_USE_SystemTools)
if (NOT DEFINED KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP)
set(KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP 1)
endif ()
@@ -494,7 +438,7 @@ IF(KWSYS_USE_SystemTools)
"Checking whether CXX compiler struct stat has st_mtim member" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
"Checking whether CXX compiler struct stat has st_mtimespec member" DIRECT)
- SET_PROPERTY(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS
+ set_property(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS
KWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV}
KWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV}
KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H}
@@ -503,623 +447,564 @@ IF(KWSYS_USE_SystemTools)
KWSYS_CXX_STAT_HAS_ST_MTIM=${KWSYS_CXX_STAT_HAS_ST_MTIM}
KWSYS_CXX_STAT_HAS_ST_MTIMESPEC=${KWSYS_CXX_STAT_HAS_ST_MTIMESPEC}
)
- IF(NOT WIN32)
- IF(KWSYS_STANDALONE)
- OPTION(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES "If true, Windows paths will be supported on Unix as well" ON)
- ENDIF()
- IF(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES)
- SET_PROPERTY(SOURCE SystemTools.cxx testSystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS
+ if(NOT WIN32)
+ if(KWSYS_STANDALONE)
+ option(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES "If true, Windows paths will be supported on Unix as well" ON)
+ endif()
+ if(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES)
+ set_property(SOURCE SystemTools.cxx testSystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS
KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES
)
- ENDIF()
- ENDIF()
+ endif()
+ endif()
# Disable getpwnam for static linux builds since it depends on shared glibc
- GET_PROPERTY(SHARED_LIBS_SUPPORTED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
- IF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT SHARED_LIBS_SUPPORTED)
- SET_PROPERTY(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS
+ get_property(SHARED_LIBS_SUPPORTED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
+ if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT SHARED_LIBS_SUPPORTED)
+ set_property(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS
HAVE_GETPWNAM=0
)
- ENDIF()
-ENDIF()
+ endif()
+endif()
-IF(KWSYS_USE_SystemInformation)
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+if(KWSYS_USE_SystemInformation)
+ set_property(SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P})
- IF(NOT CYGWIN)
- INCLUDE(CheckIncludeFiles)
+ if(NOT CYGWIN)
+ include(CheckIncludeFiles)
CHECK_INCLUDE_FILES("sys/types.h;ifaddrs.h" KWSYS_SYS_HAS_IFADDRS_H)
- IF(KWSYS_SYS_HAS_IFADDRS_H)
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+ if(KWSYS_SYS_HAS_IFADDRS_H)
+ set_property(SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_SYS_HAS_IFADDRS_H=1)
- ENDIF()
- ENDIF()
- IF(WIN32)
- INCLUDE(CheckSymbolExists)
- SET(CMAKE_REQUIRED_LIBRARIES Psapi)
+ endif()
+ endif()
+ if(WIN32)
+ include(CheckSymbolExists)
+ set(CMAKE_REQUIRED_LIBRARIES psapi)
CHECK_SYMBOL_EXISTS(GetProcessMemoryInfo "windows.h;psapi.h" KWSYS_SYS_HAS_PSAPI)
- UNSET(CMAKE_REQUIRED_LIBRARIES)
- IF(KWSYS_SYS_HAS_PSAPI)
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+ unset(CMAKE_REQUIRED_LIBRARIES)
+ if(KWSYS_SYS_HAS_PSAPI)
+ set_property(SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_SYS_HAS_PSAPI=1)
- IF(MSVC70 OR MSVC71)
+ if(MSVC70 OR MSVC71)
# Suppress LNK4089: all references to 'PSAPI.DLL' discarded by /OPT:REF
- SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /IGNORE:4089")
- ENDIF()
- ENDIF()
- ENDIF()
- IF(CMAKE_SYSTEM MATCHES "HP-UX")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /IGNORE:4089")
+ endif()
+ endif()
+ endif()
+ if(CMAKE_SYSTEM MATCHES "HP-UX")
CHECK_INCLUDE_FILES("sys/mpctl.h" KWSYS_SYS_HAS_MPCTL_H)
- IF(KWSYS_SYS_HAS_MPCTL_H)
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+ if(KWSYS_SYS_HAS_MPCTL_H)
+ set_property(SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_SYS_HAS_MPCTL_H=1)
- ENDIF()
- ENDIF()
- IF(CMAKE_SYSTEM MATCHES "BSD")
+ endif()
+ endif()
+ if(CMAKE_SYSTEM MATCHES "BSD")
CHECK_INCLUDE_FILES("machine/cpu.h" KWSYS_SYS_HAS_MACHINE_CPU_H)
- IF(KWSYS_SYS_HAS_MACHINE_CPU_H)
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+ if(KWSYS_SYS_HAS_MACHINE_CPU_H)
+ set_property(SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_SYS_HAS_MACHINE_CPU_H=1)
- ENDIF()
- ENDIF()
+ endif()
+ endif()
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_RLIMIT64
"Checking whether CXX compiler has rlimit64" DIRECT)
- SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)
- IF(KWSYS_CXX_HAS_RLIMIT64)
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+ set(KWSYS_PLATFORM_CXX_TEST_DEFINES)
+ if(KWSYS_CXX_HAS_RLIMIT64)
+ set_property(SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_CXX_HAS_RLIMIT64=1)
- ENDIF()
- KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ATOL
- "Checking whether CXX compiler has atol" DIRECT)
- IF(KWSYS_CXX_HAS_ATOL)
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
- COMPILE_DEFINITIONS KWSYS_CXX_HAS_ATOL=1)
- ENDIF()
- KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ATOLL
- "Checking whether CXX compiler has atoll" DIRECT)
- IF(KWSYS_CXX_HAS_ATOLL)
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
- COMPILE_DEFINITIONS KWSYS_CXX_HAS_ATOLL=1)
- ENDIF()
- KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS__ATOI64
- "Checking whether CXX compiler has _atoi64" DIRECT)
- IF(KWSYS_CXX_HAS__ATOI64)
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
- COMPILE_DEFINITIONS KWSYS_CXX_HAS__ATOI64=1)
- ENDIF()
- IF(UNIX)
- INCLUDE(CheckIncludeFileCXX)
+ endif()
+ if(UNIX)
+ include(CheckIncludeFileCXX)
# check for simple stack trace
# usually it's in libc but on FreeBSD
# it's in libexecinfo
- FIND_LIBRARY(EXECINFO_LIB "execinfo")
- MARK_AS_ADVANCED(EXECINFO_LIB)
- IF (NOT EXECINFO_LIB)
- SET(EXECINFO_LIB "")
- ENDIF()
+ find_library(EXECINFO_LIB "execinfo")
+ mark_as_advanced(EXECINFO_LIB)
+ if (NOT EXECINFO_LIB)
+ set(EXECINFO_LIB "")
+ endif()
CHECK_INCLUDE_FILE_CXX("execinfo.h" KWSYS_CXX_HAS_EXECINFOH)
- IF (KWSYS_CXX_HAS_EXECINFOH)
+ if (KWSYS_CXX_HAS_EXECINFOH)
# we have the backtrace header check if it
# can be used with this compiler
- SET(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES ${EXECINFO_LIB})
+ set(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES ${EXECINFO_LIB})
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BACKTRACE
"Checking whether backtrace works with this C++ compiler" DIRECT)
- SET(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES)
- IF (KWSYS_CXX_HAS_BACKTRACE)
+ set(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES)
+ if (KWSYS_CXX_HAS_BACKTRACE)
# backtrace is supported by this system and compiler.
# now check for the more advanced capabilities.
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+ set_property(SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE=1)
# check for symbol lookup using dladdr
CHECK_INCLUDE_FILE_CXX("dlfcn.h" KWSYS_CXX_HAS_DLFCNH)
- IF (KWSYS_CXX_HAS_DLFCNH)
+ if (KWSYS_CXX_HAS_DLFCNH)
# we have symbol lookup libraries and headers
# check if they can be used with this compiler
- SET(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES ${CMAKE_DL_LIBS})
+ set(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES ${CMAKE_DL_LIBS})
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_DLADDR
"Checking whether dladdr works with this C++ compiler" DIRECT)
- SET(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES)
- IF (KWSYS_CXX_HAS_DLADDR)
+ set(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES)
+ if (KWSYS_CXX_HAS_DLADDR)
# symbol lookup is supported by this system
# and compiler.
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+ set_property(SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP=1)
- ENDIF()
- ENDIF()
+ endif()
+ endif()
# c++ demangling support
# check for cxxabi headers
CHECK_INCLUDE_FILE_CXX("cxxabi.h" KWSYS_CXX_HAS_CXXABIH)
- IF (KWSYS_CXX_HAS_CXXABIH)
+ if (KWSYS_CXX_HAS_CXXABIH)
# check if cxxabi can be used with this
# system and compiler.
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_CXXABI
"Checking whether cxxabi works with this C++ compiler" DIRECT)
- IF (KWSYS_CXX_HAS_CXXABI)
+ if (KWSYS_CXX_HAS_CXXABI)
# c++ demangle using cxxabi is supported with
# this system and compiler
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+ set_property(SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE=1)
- ENDIF()
- ENDIF()
+ endif()
+ endif()
# basic backtrace works better with release build
# don't bother with advanced features for release
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+ set_property(SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS_DEBUG KWSYS_SYSTEMINFORMATION_HAS_DEBUG_BUILD=1)
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+ set_property(SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS_RELWITHDEBINFO KWSYS_SYSTEMINFORMATION_HAS_DEBUG_BUILD=1)
- ENDIF()
- ENDIF()
- ENDIF()
- IF(BORLAND)
- KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BORLAND_ASM
- "Checking whether Borland CXX compiler supports assembler instructions" DIRECT)
- IF(KWSYS_CXX_HAS_BORLAND_ASM)
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
- COMPILE_DEFINITIONS KWSYS_CXX_HAS_BORLAND_ASM=1)
- KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BORLAND_ASM_CPUID
- "Checking whether Borland CXX compiler supports CPUID assembler instruction" DIRECT)
- IF(KWSYS_CXX_HAS_BORLAND_ASM_CPUID)
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
- COMPILE_DEFINITIONS KWSYS_CXX_HAS_BORLAND_ASM_CPUID=1)
- ENDIF()
- ENDIF()
- ENDIF()
- IF(KWSYS_USE___INT64)
- SET_PROPERTY(SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY
- COMPILE_DEFINITIONS KWSYS_USE___INT64=1)
- ENDIF()
- IF(KWSYS_USE_LONG_LONG)
- SET_PROPERTY(SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY
- COMPILE_DEFINITIONS KWSYS_USE_LONG_LONG=1)
- ENDIF()
- IF(KWSYS_IOS_HAS_OSTREAM_LONG_LONG)
- SET_PROPERTY(SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY
- COMPILE_DEFINITIONS KWSYS_IOS_HAS_OSTREAM_LONG_LONG=1)
- ENDIF()
- IF(KWSYS_IOS_HAS_OSTREAM___INT64)
- SET_PROPERTY(SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY
- COMPILE_DEFINITIONS KWSYS_IOS_HAS_OSTREAM___INT64=1)
- ENDIF()
- IF(KWSYS_BUILD_SHARED)
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+ endif()
+ endif()
+ endif()
+ if(KWSYS_BUILD_SHARED)
+ set_property(SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_BUILD_SHARED=1)
- ENDIF()
+ endif()
- IF(UNIX AND NOT CYGWIN)
+ if(UNIX AND NOT CYGWIN)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_GETLOADAVG
"Checking whether CXX compiler has getloadavg" DIRECT)
- IF(KWSYS_CXX_HAS_GETLOADAVG)
- SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+ if(KWSYS_CXX_HAS_GETLOADAVG)
+ set_property(SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_CXX_HAS_GETLOADAVG=1)
- ENDIF()
- ENDIF()
-ENDIF()
+ endif()
+ endif()
+endif()
-IF(KWSYS_USE_FStream)
+if(KWSYS_USE_FStream)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H
"Checking whether <ext/stdio_filebuf.h> is available" DIRECT)
-ENDIF()
+endif()
#-----------------------------------------------------------------------------
# Choose a directory for the generated headers.
-IF(NOT KWSYS_HEADER_ROOT)
- SET(KWSYS_HEADER_ROOT "${PROJECT_BINARY_DIR}")
-ENDIF()
-SET(KWSYS_HEADER_DIR "${KWSYS_HEADER_ROOT}/${KWSYS_NAMESPACE}")
-INCLUDE_DIRECTORIES(${KWSYS_HEADER_ROOT})
+if(NOT KWSYS_HEADER_ROOT)
+ set(KWSYS_HEADER_ROOT "${PROJECT_BINARY_DIR}")
+endif()
+set(KWSYS_HEADER_DIR "${KWSYS_HEADER_ROOT}/${KWSYS_NAMESPACE}")
+include_directories(${KWSYS_HEADER_ROOT})
#-----------------------------------------------------------------------------
-IF(KWSYS_INSTALL_DOC_DIR)
+if(KWSYS_INSTALL_DOC_DIR)
# Assign the license to the runtime component since it must be
# distributed with binary forms of this software.
- IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
- SET(KWSYS_INSTALL_LICENSE_OPTIONS ${KWSYS_INSTALL_LICENSE_OPTIONS}
+ if(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
+ set(KWSYS_INSTALL_LICENSE_OPTIONS ${KWSYS_INSTALL_LICENSE_OPTIONS}
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
)
- ENDIF()
+ endif()
# Install the license under the documentation directory.
- INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt
+ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt
DESTINATION ${KWSYS_INSTALL_DOC_DIR}/${KWSYS_NAMESPACE}
${KWSYS_INSTALL_LICENSE_OPTIONS})
-ENDIF()
+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)
-
-IF(NOT CMake_SOURCE_DIR)
- SET(KWSYS_HXX_FILES ${KWSYS_HXX_FILES}
- hashtable hash_fun hash_map hash_set
- )
-ENDIF()
+set(KWSYS_CLASSES)
+set(KWSYS_H_FILES Configure SharedForward)
+set(KWSYS_HXX_FILES Configure String)
# Add selected C++ classes.
-SET(cppclasses
+set(cppclasses
Directory DynamicLoader Encoding Glob RegularExpression SystemTools
- CommandLineArguments IOStream FStream SystemInformation ConsoleBuf
+ CommandLineArguments FStream SystemInformation ConsoleBuf
)
-FOREACH(cpp ${cppclasses})
- IF(KWSYS_USE_${cpp})
+foreach(cpp ${cppclasses})
+ if(KWSYS_USE_${cpp})
# Use the corresponding class.
- SET(KWSYS_CLASSES ${KWSYS_CLASSES} ${cpp})
+ set(KWSYS_CLASSES ${KWSYS_CLASSES} ${cpp})
# Load component-specific CMake code.
- IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
- INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
- ENDIF()
- ENDIF()
-ENDFOREACH()
+ if(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
+ include(${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
+ endif()
+ endif()
+endforeach()
# Add selected C components.
-FOREACH(c
+foreach(c
Process Base64 Encoding MD5 Terminal System String
)
- IF(KWSYS_USE_${c})
+ if(KWSYS_USE_${c})
# Use the corresponding header file.
- SET(KWSYS_H_FILES ${KWSYS_H_FILES} ${c})
+ set(KWSYS_H_FILES ${KWSYS_H_FILES} ${c})
# Load component-specific CMake code.
- IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
- INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
- ENDIF()
- ENDIF()
-ENDFOREACH()
+ if(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
+ include(${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
+ endif()
+ endif()
+endforeach()
#-----------------------------------------------------------------------------
# Build a list of sources for the library based on components that are
# included.
-SET(KWSYS_C_SRCS)
-SET(KWSYS_CXX_SRCS)
+set(KWSYS_C_SRCS)
+set(KWSYS_CXX_SRCS)
# Add the proper sources for this platform's Process implementation.
-IF(KWSYS_USE_Process)
- IF(NOT UNIX)
+if(KWSYS_USE_Process)
+ if(NOT UNIX)
# Use the Windows implementation.
- SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessWin32.c)
- ELSE()
+ set(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessWin32.c)
+ else()
# Use the UNIX implementation.
- SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c)
- ENDIF()
-ENDIF()
+ set(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c)
+ endif()
+endif()
# Add selected C sources.
-FOREACH(c 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)
- ELSE()
- LIST(APPEND KWSYS_C_SRCS ${c}.c)
- ENDIF()
- ENDIF()
-ENDFOREACH()
+foreach(c 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)
+ else()
+ list(APPEND KWSYS_C_SRCS ${c}.c)
+ endif()
+ endif()
+endforeach()
# Configure headers of C++ classes and construct the list of sources.
-FOREACH(c ${KWSYS_CLASSES})
+foreach(c ${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)
- ELSEIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}.cxx)
- LIST(APPEND KWSYS_CXX_SRCS ${c}.cxx)
- ENDIF()
+ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}CXX.cxx)
+ list(APPEND KWSYS_CXX_SRCS ${c}CXX.cxx)
+ elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}.cxx)
+ list(APPEND KWSYS_CXX_SRCS ${c}.cxx)
+ endif()
# Configure the header for this class.
- CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${c}.hxx.in ${KWSYS_HEADER_DIR}/${c}.hxx
+ configure_file(${PROJECT_SOURCE_DIR}/${c}.hxx.in ${KWSYS_HEADER_DIR}/${c}.hxx
@ONLY IMMEDIATE)
- SET(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${KWSYS_HEADER_DIR}/${c}.hxx)
+ set(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${KWSYS_HEADER_DIR}/${c}.hxx)
# Create an install target for the header.
- IF(KWSYS_INSTALL_INCLUDE_DIR)
- INSTALL(FILES ${KWSYS_HEADER_DIR}/${c}.hxx
+ if(KWSYS_INSTALL_INCLUDE_DIR)
+ install(FILES ${KWSYS_HEADER_DIR}/${c}.hxx
DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
${KWSYS_INSTALL_INCLUDE_OPTIONS})
- ENDIF()
-ENDFOREACH()
+ endif()
+endforeach()
# Configure C headers.
-FOREACH(h ${KWSYS_H_FILES})
+foreach(h ${KWSYS_H_FILES})
# Configure the header into the given directory.
- CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${h}.h.in ${KWSYS_HEADER_DIR}/${h}.h
+ configure_file(${PROJECT_SOURCE_DIR}/${h}.h.in ${KWSYS_HEADER_DIR}/${h}.h
@ONLY IMMEDIATE)
- SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ${KWSYS_HEADER_DIR}/${h}.h)
+ set(KWSYS_C_SRCS ${KWSYS_C_SRCS} ${KWSYS_HEADER_DIR}/${h}.h)
# Create an install target for the header.
- IF(KWSYS_INSTALL_INCLUDE_DIR)
- INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.h
+ if(KWSYS_INSTALL_INCLUDE_DIR)
+ install(FILES ${KWSYS_HEADER_DIR}/${h}.h
DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
${KWSYS_INSTALL_INCLUDE_OPTIONS})
- ENDIF()
-ENDFOREACH()
+ endif()
+endforeach()
# Configure other C++ headers.
-FOREACH(h ${KWSYS_HXX_FILES})
+foreach(h ${KWSYS_HXX_FILES})
# Configure the header into the given directory.
- CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${h}.hxx.in ${KWSYS_HEADER_DIR}/${h}.hxx
+ configure_file(${PROJECT_SOURCE_DIR}/${h}.hxx.in ${KWSYS_HEADER_DIR}/${h}.hxx
@ONLY IMMEDIATE)
- SET(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${KWSYS_HEADER_DIR}/${h}.hxx)
+ set(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${KWSYS_HEADER_DIR}/${h}.hxx)
# Create an install target for the header.
- IF(KWSYS_INSTALL_INCLUDE_DIR)
- INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.hxx
+ if(KWSYS_INSTALL_INCLUDE_DIR)
+ install(FILES ${KWSYS_HEADER_DIR}/${h}.hxx
DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
${KWSYS_INSTALL_INCLUDE_OPTIONS})
- ENDIF()
-ENDFOREACH()
+ endif()
+endforeach()
#-----------------------------------------------------------------------------
# Add the library with the configured name and list of sources.
-IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
- IF(KWSYS_SPLIT_OBJECTS_FROM_INTERFACE)
- SET(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE})
- SET(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE}_objects)
- SET(KWSYS_TARGET_LINK ${KWSYS_NAMESPACE}_private)
- SET(KWSYS_TARGET_INSTALL ${KWSYS_TARGET_INTERFACE} ${KWSYS_TARGET_LINK})
- SET(KWSYS_LINK_DEPENDENCY INTERFACE)
- ADD_LIBRARY(${KWSYS_TARGET_OBJECT} OBJECT
+if(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
+ if(KWSYS_SPLIT_OBJECTS_FROM_INTERFACE)
+ set(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE})
+ set(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE}_objects)
+ set(KWSYS_TARGET_LINK ${KWSYS_NAMESPACE}_private)
+ set(KWSYS_TARGET_INSTALL ${KWSYS_TARGET_INTERFACE} ${KWSYS_TARGET_LINK})
+ set(KWSYS_LINK_DEPENDENCY INTERFACE)
+ add_library(${KWSYS_TARGET_OBJECT} OBJECT
${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
- IF(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC)
- SET_PROPERTY(TARGET ${KWSYS_TARGET_OBJECT} PROPERTY
+ if(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC)
+ set_property(TARGET ${KWSYS_TARGET_OBJECT} PROPERTY
POSITION_INDEPENDENT_CODE TRUE)
- ENDIF()
- ADD_LIBRARY(${KWSYS_TARGET_INTERFACE} INTERFACE)
- ADD_LIBRARY(${KWSYS_TARGET_LINK} INTERFACE)
- TARGET_LINK_LIBRARIES(${KWSYS_TARGET_LINK} INTERFACE
+ endif()
+ add_library(${KWSYS_TARGET_INTERFACE} INTERFACE)
+ add_library(${KWSYS_TARGET_LINK} INTERFACE)
+ target_link_libraries(${KWSYS_TARGET_LINK} INTERFACE
${KWSYS_TARGET_INTERFACE})
- TARGET_SOURCES(${KWSYS_TARGET_LINK} INTERFACE
+ target_sources(${KWSYS_TARGET_LINK} INTERFACE
$<TARGET_OBJECTS:${KWSYS_TARGET_OBJECT}>)
target_compile_features(${KWSYS_TARGET_OBJECT} PRIVATE ${KWSYS_CXX_COMPILE_FEATURES})
target_compile_features(${KWSYS_TARGET_INTERFACE} INTERFACE ${KWSYS_CXX_COMPILE_FEATURES})
- ELSE()
- SET(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE})
- SET(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE})
- SET(KWSYS_TARGET_LINK ${KWSYS_NAMESPACE})
+ else()
+ set(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE})
+ set(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE})
+ set(KWSYS_TARGET_LINK ${KWSYS_NAMESPACE})
set(KWSYS_TARGET_INSTALL ${KWSYS_TARGET_LINK})
- SET(KWSYS_LINK_DEPENDENCY PUBLIC)
- ADD_LIBRARY(${KWSYS_TARGET_INTERFACE} ${KWSYS_LIBRARY_TYPE}
+ set(KWSYS_LINK_DEPENDENCY PUBLIC)
+ add_library(${KWSYS_TARGET_INTERFACE} ${KWSYS_LIBRARY_TYPE}
${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
target_compile_features(${KWSYS_TARGET_INTERFACE} PUBLIC ${KWSYS_CXX_COMPILE_FEATURES})
- ENDIF()
+ endif()
if (KWSYS_ALIAS_TARGET)
add_library(${KWSYS_ALIAS_TARGET} ALIAS ${KWSYS_TARGET_INTERFACE})
endif ()
- SET_TARGET_PROPERTIES(${KWSYS_TARGET_OBJECT} PROPERTIES
+ set_target_properties(${KWSYS_TARGET_OBJECT} PROPERTIES
C_CLANG_TIDY ""
CXX_CLANG_TIDY ""
C_INCLUDE_WHAT_YOU_USE ""
CXX_INCLUDE_WHAT_YOU_USE ""
LABELS "${KWSYS_LABELS_LIB}")
- IF(KWSYS_USE_DynamicLoader)
- IF(UNIX)
- TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
+ if(KWSYS_USE_DynamicLoader)
+ if(UNIX)
+ target_link_libraries(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
${CMAKE_DL_LIBS})
- ENDIF()
- ENDIF()
+ endif()
+ endif()
- IF(KWSYS_USE_SystemInformation)
- IF(WIN32)
- TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} ws2_32)
+ if(KWSYS_USE_SystemInformation)
+ if(WIN32)
+ target_link_libraries(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} ws2_32)
# link in dbghelp.dll for symbol lookup if MSVC 1800 or later
# Note that the dbghelp runtime is part of MS Windows OS
- IF(MSVC_VERSION AND NOT MSVC_VERSION VERSION_LESS 1800)
- TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} dbghelp)
- ENDIF()
- IF(KWSYS_SYS_HAS_PSAPI)
- TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
- Psapi)
- ENDIF()
- ELSEIF(UNIX)
- IF (EXECINFO_LIB AND KWSYS_CXX_HAS_BACKTRACE)
+ if(MSVC_VERSION AND NOT MSVC_VERSION VERSION_LESS 1800)
+ target_link_libraries(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} dbghelp)
+ endif()
+ if(KWSYS_SYS_HAS_PSAPI)
+ target_link_libraries(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
+ psapi)
+ endif()
+ elseif(UNIX)
+ if (EXECINFO_LIB AND KWSYS_CXX_HAS_BACKTRACE)
# backtrace on FreeBSD is not in libc
- TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
+ target_link_libraries(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
${EXECINFO_LIB})
- ENDIF()
- IF (KWSYS_CXX_HAS_DLADDR)
+ endif()
+ if (KWSYS_CXX_HAS_DLADDR)
# for symbol lookup using dladdr
- TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
+ target_link_libraries(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
${CMAKE_DL_LIBS})
- ENDIF()
- IF (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
- TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
+ endif()
+ if (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ target_link_libraries(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
socket)
- ENDIF()
- ENDIF()
- ENDIF()
+ endif()
+ endif()
+ endif()
# Apply user-defined target properties to the library.
- IF(KWSYS_PROPERTIES_CXX)
- SET_TARGET_PROPERTIES(${KWSYS_TARGET_INTERFACE} PROPERTIES
+ if(KWSYS_PROPERTIES_CXX)
+ set_target_properties(${KWSYS_TARGET_INTERFACE} PROPERTIES
${KWSYS_PROPERTIES_CXX})
- ENDIF()
+ endif()
# Set up include usage requirement
- IF(COMMAND TARGET_INCLUDE_DIRECTORIES)
- TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_INTERFACE} INTERFACE
+ if(COMMAND TARGET_INCLUDE_DIRECTORIES)
+ target_include_directories(${KWSYS_TARGET_INTERFACE} INTERFACE
$<BUILD_INTERFACE:${KWSYS_HEADER_ROOT}>)
- IF(KWSYS_INSTALL_INCLUDE_DIR)
- TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_INTERFACE} INTERFACE
+ if(KWSYS_INSTALL_INCLUDE_DIR)
+ target_include_directories(${KWSYS_TARGET_INTERFACE} INTERFACE
$<INSTALL_INTERFACE:${KWSYS_INSTALL_INCLUDE_DIR}>)
- ENDIF()
- ENDIF()
+ endif()
+ endif()
# Create an install target for the library.
- IF(KWSYS_INSTALL_LIBRARY_RULE)
- INSTALL(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_LIBRARY_RULE})
- ENDIF()
- IF(KWSYS_INSTALL_NAMELINK_RULE)
- INSTALL(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_NAMELINK_RULE})
- ENDIF()
-ENDIF()
+ if(KWSYS_INSTALL_LIBRARY_RULE)
+ install(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_LIBRARY_RULE})
+ endif()
+ if(KWSYS_INSTALL_NAMELINK_RULE)
+ install(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_NAMELINK_RULE})
+ endif()
+endif()
# Add a C-only library if requested.
-IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
- IF(KWSYS_SPLIT_OBJECTS_FROM_INTERFACE)
- SET(KWSYS_TARGET_C_INTERFACE ${KWSYS_NAMESPACE}_c)
- SET(KWSYS_TARGET_C_OBJECT ${KWSYS_NAMESPACE}_c_objects)
- SET(KWSYS_TARGET_C_LINK ${KWSYS_NAMESPACE}_c_private)
- SET(KWSYS_TARGET_C_INSTALL
+if(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
+ if(KWSYS_SPLIT_OBJECTS_FROM_INTERFACE)
+ set(KWSYS_TARGET_C_INTERFACE ${KWSYS_NAMESPACE}_c)
+ set(KWSYS_TARGET_C_OBJECT ${KWSYS_NAMESPACE}_c_objects)
+ set(KWSYS_TARGET_C_LINK ${KWSYS_NAMESPACE}_c_private)
+ set(KWSYS_TARGET_C_INSTALL
${KWSYS_TARGET_C_INTERFACE} ${KWSYS_TARGET_C_LINK})
- SET(KWSYS_LINK_DEPENDENCY INTERFACE)
- ADD_LIBRARY(${KWSYS_TARGET_C_OBJECT} OBJECT ${KWSYS_C_SRCS})
- IF(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC)
- SET_PROPERTY(TARGET ${KWSYS_TARGET_C_OBJECT} PROPERTY
+ set(KWSYS_LINK_DEPENDENCY INTERFACE)
+ add_library(${KWSYS_TARGET_C_OBJECT} OBJECT ${KWSYS_C_SRCS})
+ if(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC)
+ set_property(TARGET ${KWSYS_TARGET_C_OBJECT} PROPERTY
POSITION_INDEPENDENT_CODE TRUE)
- ENDIF()
- ADD_LIBRARY(${KWSYS_TARGET_C_INTERFACE} INTERFACE)
- ADD_LIBRARY(${KWSYS_TARGET_C_LINK} INTERFACE)
- TARGET_LINK_LIBRARIES(${KWSYS_TARGET_C_LINK} INTERFACE
+ endif()
+ add_library(${KWSYS_TARGET_C_INTERFACE} INTERFACE)
+ add_library(${KWSYS_TARGET_C_LINK} INTERFACE)
+ target_link_libraries(${KWSYS_TARGET_C_LINK} INTERFACE
${KWSYS_TARGET_C_INTERFACE})
- TARGET_SOURCES(${KWSYS_TARGET_C_LINK} INTERFACE
+ target_sources(${KWSYS_TARGET_C_LINK} INTERFACE
$<TARGET_OBJECTS:${KWSYS_TARGET_C_OBJECT}>)
- ELSE()
- SET(KWSYS_TARGET_C_INTERFACE ${KWSYS_NAMESPACE}_c)
- SET(KWSYS_TARGET_C_OBJECT ${KWSYS_NAMESPACE}_c)
- SET(KWSYS_TARGET_C_LINK ${KWSYS_NAMESPACE}_c)
- SET(KWSYS_TARGET_C_INSTALL ${KWSYS_TARGET_C_LINK})
- SET(KWSYS_LINK_DEPENDENCY PUBLIC)
- ADD_LIBRARY(${KWSYS_TARGET_C_INTERFACE} ${KWSYS_LIBRARY_TYPE}
+ else()
+ set(KWSYS_TARGET_C_INTERFACE ${KWSYS_NAMESPACE}_c)
+ set(KWSYS_TARGET_C_OBJECT ${KWSYS_NAMESPACE}_c)
+ set(KWSYS_TARGET_C_LINK ${KWSYS_NAMESPACE}_c)
+ set(KWSYS_TARGET_C_INSTALL ${KWSYS_TARGET_C_LINK})
+ set(KWSYS_LINK_DEPENDENCY PUBLIC)
+ add_library(${KWSYS_TARGET_C_INTERFACE} ${KWSYS_LIBRARY_TYPE}
${KWSYS_C_SRCS})
- ENDIF()
- SET_TARGET_PROPERTIES(${KWSYS_TARGET_C_OBJECT} PROPERTIES
+ endif()
+ set_target_properties(${KWSYS_TARGET_C_OBJECT} PROPERTIES
LABELS "${KWSYS_LABELS_LIB}")
# Apply user-defined target properties to the library.
- IF(KWSYS_PROPERTIES_C)
- SET_TARGET_PROPERTIES(${KWSYS_TARGET_C_INTERFACE} PROPERTIES
+ if(KWSYS_PROPERTIES_C)
+ set_target_properties(${KWSYS_TARGET_C_INTERFACE} PROPERTIES
${KWSYS_PROPERTIES_C})
- ENDIF()
+ endif()
# Set up include usage requirement
- IF(COMMAND TARGET_INCLUDE_DIRECTORIES)
- TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_C_INTERFACE} INTERFACE
+ if(COMMAND TARGET_INCLUDE_DIRECTORIES)
+ target_include_directories(${KWSYS_TARGET_C_INTERFACE} INTERFACE
$<BUILD_INTERFACE:${KWSYS_HEADER_ROOT}>)
- IF(KWSYS_INSTALL_INCLUDE_DIR)
- TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_C_INTERFACE} INTERFACE
+ if(KWSYS_INSTALL_INCLUDE_DIR)
+ target_include_directories(${KWSYS_TARGET_C_INTERFACE} INTERFACE
$<INSTALL_INTERFACE:${KWSYS_INSTALL_INCLUDE_DIR}>)
- ENDIF()
- ENDIF()
+ endif()
+ endif()
# Create an install target for the library.
- IF(KWSYS_INSTALL_LIBRARY_RULE)
- INSTALL(TARGETS ${KWSYS_TARGET_C_INSTALL})
- ENDIF()
-ENDIF()
+ if(KWSYS_INSTALL_LIBRARY_RULE)
+ install(TARGETS ${KWSYS_TARGET_C_INSTALL})
+ endif()
+endif()
# For building kwsys itself, we use a macro defined on the command
# line to configure the namespace in the C and C++ source files.
-ADD_DEFINITIONS("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}")
+add_definitions("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}")
# Disable deprecation warnings for standard C functions.
-IF(MSVC OR (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "Intel" OR
+if(MSVC OR (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "Intel" OR
(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))))
- ADD_DEFINITIONS(
+ add_definitions(
-D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_WARNINGS
-D_SCL_SECURE_NO_DEPRECATE
)
-ENDIF()
+endif()
-IF(WIN32)
+if(WIN32)
# Help enforce the use of wide Windows apis.
- ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
-ENDIF()
+ add_definitions(-DUNICODE -D_UNICODE)
+endif()
-IF(KWSYS_USE_String)
+if(KWSYS_USE_String)
# Activate code in "String.c". See the comment in the source.
- SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES
+ set_source_files_properties(String.c PROPERTIES
COMPILE_FLAGS "-DKWSYS_STRING_C")
-ENDIF()
+endif()
-IF(KWSYS_USE_Encoding)
+if(KWSYS_USE_Encoding)
# Set default 8 bit encoding in "EndcodingC.c".
- SET_PROPERTY(SOURCE EncodingC.c EncodingCXX.cxx APPEND PROPERTY COMPILE_DEFINITIONS
+ set_property(SOURCE EncodingC.c EncodingCXX.cxx APPEND PROPERTY COMPILE_DEFINITIONS
KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE})
-ENDIF()
+endif()
#-----------------------------------------------------------------------------
# Setup testing if not being built as part of another project.
-IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
- IF(BUILD_TESTING)
+if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
+ if(BUILD_TESTING)
# Compute the location of executables.
- SET(EXEC_DIR "${CMAKE_CURRENT_BINARY_DIR}")
- IF(EXECUTABLE_OUTPUT_PATH)
- SET(EXEC_DIR "${EXECUTABLE_OUTPUT_PATH}")
- ENDIF()
+ set(EXEC_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+ if(CMAKE_RUNTIME_OUTPUT_DIRECTORY)
+ set(EXEC_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
+ endif()
# C tests
- SET(KWSYS_C_TESTS
+ set(KWSYS_C_TESTS
testEncode.c
testTerminal.c
)
- IF(KWSYS_STANDALONE)
- SET(KWSYS_C_TESTS ${KWSYS_C_TESTS} testFail.c)
- ENDIF()
- CREATE_TEST_SOURCELIST(
+ if(KWSYS_STANDALONE)
+ set(KWSYS_C_TESTS ${KWSYS_C_TESTS} testFail.c)
+ endif()
+ create_test_sourcelist(
KWSYS_C_TEST_SRCS ${KWSYS_NAMESPACE}TestsC.c
${KWSYS_C_TESTS}
)
- 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})
+ 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})
get_filename_component(test "${testfile}" NAME_WE)
- ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}})
- SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
- ENDFOREACH()
+ add_test(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}})
+ set_property(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
+ endforeach()
# C++ tests
- IF(NOT WATCOM AND NOT CMake_SOURCE_DIR)
- SET(KWSYS_CXX_TESTS
- testHashSTL.cxx
- )
- ENDIF()
- SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
+ set(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
testConfigure.cxx
testSystemTools.cxx
testCommandLineArguments.cxx
testCommandLineArguments1.cxx
testDirectory.cxx
)
- IF(KWSYS_STL_HAS_WSTRING)
- SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
+ if(KWSYS_STL_HAS_WSTRING)
+ set(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
testEncoding.cxx
)
- ENDIF()
- IF(KWSYS_USE_FStream)
- SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
+ endif()
+ if(KWSYS_USE_FStream)
+ set(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
testFStream.cxx
)
- ENDIF()
- IF(KWSYS_USE_ConsoleBuf)
- ADD_EXECUTABLE(testConsoleBufChild testConsoleBufChild.cxx)
- SET_PROPERTY(TARGET testConsoleBufChild PROPERTY C_CLANG_TIDY "")
- SET_PROPERTY(TARGET testConsoleBufChild PROPERTY CXX_CLANG_TIDY "")
- SET_PROPERTY(TARGET testConsoleBufChild PROPERTY C_INCLUDE_WHAT_YOU_USE "")
- SET_PROPERTY(TARGET testConsoleBufChild PROPERTY CXX_INCLUDE_WHAT_YOU_USE "")
- SET_PROPERTY(TARGET testConsoleBufChild PROPERTY LABELS ${KWSYS_LABELS_EXE})
- TARGET_LINK_LIBRARIES(testConsoleBufChild ${KWSYS_TARGET_LINK})
- SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
+ endif()
+ if(KWSYS_USE_ConsoleBuf)
+ add_executable(testConsoleBufChild testConsoleBufChild.cxx)
+ set_property(TARGET testConsoleBufChild PROPERTY C_CLANG_TIDY "")
+ set_property(TARGET testConsoleBufChild PROPERTY CXX_CLANG_TIDY "")
+ set_property(TARGET testConsoleBufChild PROPERTY C_INCLUDE_WHAT_YOU_USE "")
+ set_property(TARGET testConsoleBufChild PROPERTY CXX_INCLUDE_WHAT_YOU_USE "")
+ set_property(TARGET testConsoleBufChild PROPERTY LABELS ${KWSYS_LABELS_EXE})
+ target_link_libraries(testConsoleBufChild ${KWSYS_TARGET_LINK})
+ set(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
testConsoleBuf.cxx
)
- IF(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "19.0.23506")
set_property(SOURCE testConsoleBuf.cxx testConsoleBufChild.cxx PROPERTY COMPILE_FLAGS /utf-8)
- ENDIF()
- SET_PROPERTY(SOURCE testConsoleBuf.cxx APPEND PROPERTY COMPILE_DEFINITIONS
+ endif()
+ set_property(SOURCE testConsoleBuf.cxx APPEND PROPERTY COMPILE_DEFINITIONS
KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE})
- ENDIF()
- IF(KWSYS_USE_SystemInformation)
- SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation.cxx)
- ENDIF()
- IF(KWSYS_USE_DynamicLoader)
- SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader.cxx)
+ endif()
+ if(KWSYS_USE_SystemInformation)
+ set(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation.cxx)
+ endif()
+ if(KWSYS_USE_DynamicLoader)
+ set(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader.cxx)
# If kwsys contains the DynamicLoader, need extra library
- ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c)
- SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB})
- ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestDynload ${KWSYS_TARGET_INTERFACE})
+ add_library(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c)
+ set_property(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB})
+ add_dependencies(${KWSYS_NAMESPACE}TestDynload ${KWSYS_TARGET_INTERFACE})
if (WIN32)
# Windows tests supported flags.
@@ -1134,33 +1019,33 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
add_dependencies(${KWSYS_NAMESPACE}TestDynloadUse ${KWSYS_TARGET_INTERFACE})
target_link_libraries(${KWSYS_NAMESPACE}TestDynloadUse PRIVATE ${KWSYS_NAMESPACE}TestDynloadImpl)
endif ()
- ENDIF()
- CREATE_TEST_SOURCELIST(
+ endif()
+ create_test_sourcelist(
KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx
${KWSYS_CXX_TESTS}
)
- ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_CXX_TEST_SRCS})
- SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY C_CLANG_TIDY "")
- SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY CXX_CLANG_TIDY "")
- SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY C_INCLUDE_WHAT_YOU_USE "")
- 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})
-
- SET(TEST_SYSTEMTOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
- SET(TEST_SYSTEMTOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
- CONFIGURE_FILE(
+ add_executable(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_CXX_TEST_SRCS})
+ set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY C_CLANG_TIDY "")
+ set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY CXX_CLANG_TIDY "")
+ set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY C_INCLUDE_WHAT_YOU_USE "")
+ 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})
+
+ set(TEST_SYSTEMTOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+ set(TEST_SYSTEMTOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+ configure_file(
${PROJECT_SOURCE_DIR}/testSystemTools.h.in
${PROJECT_BINARY_DIR}/testSystemTools.h)
- INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
+ include_directories(${PROJECT_BINARY_DIR})
- IF(CTEST_TEST_KWSYS)
- CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ExtraTest.cmake.in"
+ if(CTEST_TEST_KWSYS)
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ExtraTest.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
- SET_DIRECTORY_PROPERTIES(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
- ENDIF()
+ set_directory_properties(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
+ endif()
- SET(KWSYS_TEST_ARGS_testCommandLineArguments
+ set(KWSYS_TEST_ARGS_testCommandLineArguments
--another-bool-variable
--long3=opt
--set-bool-arg1
@@ -1179,7 +1064,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
-C=test
--long2 hello
)
- SET(KWSYS_TEST_ARGS_testCommandLineArguments1
+ set(KWSYS_TEST_ARGS_testCommandLineArguments1
--ignored
-n 24
--second-ignored
@@ -1188,73 +1073,71 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
-p
some junk at the end
)
- FOREACH(testfile ${KWSYS_CXX_TESTS})
+ foreach(testfile ${KWSYS_CXX_TESTS})
get_filename_component(test "${testfile}" NAME_WE)
- ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}})
- SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
- ENDFOREACH()
+ add_test(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}})
+ set_property(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
+ endforeach()
# Process tests.
- ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestProcess testProcess.c)
- SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestProcess PROPERTY LABELS ${KWSYS_LABELS_EXE})
- TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestProcess ${KWSYS_TARGET_C_LINK})
- IF(NOT CYGWIN)
- SET(KWSYS_TEST_PROCESS_7 7)
- ENDIF()
- 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})
- SET_PROPERTY(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST})
- SET_TESTS_PROPERTIES(kwsys.testProcess-${n} PROPERTIES TIMEOUT 120)
- ENDFOREACH()
-
- SET(testProcess_COMPILE_FLAGS "")
+ add_executable(${KWSYS_NAMESPACE}TestProcess testProcess.c)
+ 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})
+ set_property(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST})
+ set_tests_properties(kwsys.testProcess-${n} PROPERTIES TIMEOUT 120)
+ endforeach()
+
+ set(testProcess_COMPILE_FLAGS "")
# Some Apple compilers produce bad optimizations in this source.
- IF(APPLE AND CMAKE_C_COMPILER_ID MATCHES "^(GNU|LLVM)$")
- SET(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -O0")
- ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "XL")
+ if(APPLE AND CMAKE_C_COMPILER_ID MATCHES "^(GNU|LLVM)$")
+ set(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -O0")
+ elseif(CMAKE_C_COMPILER_ID STREQUAL "XL")
# Tell IBM XL not to warn about our test infinite loop
- IF(CMAKE_SYSTEM MATCHES "Linux.*ppc64le"
+ if(CMAKE_SYSTEM MATCHES "Linux.*ppc64le"
AND CMAKE_C_COMPILER_VERSION VERSION_LESS "16.1.0"
AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS "13.1.1")
# v13.1.[1-6] on Linux ppc64le is clang based and does not accept
# the -qsuppress option, so just suppress all warnings.
- SET(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -w")
- ELSE()
- SET(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -qsuppress=1500-010")
- ENDIF()
- ENDIF()
- IF(CMAKE_C_FLAGS MATCHES "-fsanitize=")
- SET(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -DCRASH_USING_ABORT")
- ENDIF()
- SET_PROPERTY(SOURCE testProcess.c PROPERTY COMPILE_FLAGS "${testProcess_COMPILE_FLAGS}")
+ set(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -w")
+ else()
+ set(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -qsuppress=1500-010")
+ endif()
+ endif()
+ if(CMAKE_C_FLAGS MATCHES "-fsanitize=")
+ set(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -DCRASH_USING_ABORT")
+ endif()
+ set_property(SOURCE testProcess.c PROPERTY COMPILE_FLAGS "${testProcess_COMPILE_FLAGS}")
# Test SharedForward
- CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/testSharedForward.c.in
+ configure_file(${PROJECT_SOURCE_DIR}/testSharedForward.c.in
${PROJECT_BINARY_DIR}/testSharedForward.c @ONLY IMMEDIATE)
- ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestSharedForward
+ 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})
+ 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)
+ if(KWSYS_STANDALONE)
# We expect test to fail
- SET_TESTS_PROPERTIES(kwsys.testFail PROPERTIES WILL_FAIL ON)
- GET_TEST_PROPERTY(kwsys.testFail WILL_FAIL wfv)
- SET_TESTS_PROPERTIES(kwsys.testFail PROPERTIES MEASUREMENT "Some Key=Some Value")
- MESSAGE(STATUS "GET_TEST_PROPERTY returned: ${wfv}")
- ENDIF()
+ set_tests_properties(kwsys.testFail PROPERTIES WILL_FAIL ON)
+ get_test_property(kwsys.testFail WILL_FAIL wfv)
+ set_tests_properties(kwsys.testFail PROPERTIES MEASUREMENT "Some Key=Some Value")
+ message(STATUS "GET_TEST_PROPERTY returned: ${wfv}")
+ endif()
# Set up ctest custom configuration file.
- CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/CTestCustom.cmake.in
+ configure_file(${PROJECT_SOURCE_DIR}/CTestCustom.cmake.in
${PROJECT_BINARY_DIR}/CTestCustom.cmake @ONLY)
# Suppress known consistent failures on buggy systems.
- IF(KWSYS_TEST_BOGUS_FAILURES)
- SET_TESTS_PROPERTIES(${KWSYS_TEST_BOGUS_FAILURES} PROPERTIES WILL_FAIL ON)
- ENDIF()
+ if(KWSYS_TEST_BOGUS_FAILURES)
+ set_tests_properties(${KWSYS_TEST_BOGUS_FAILURES} PROPERTIES WILL_FAIL ON)
+ endif()
- ENDIF()
-ENDIF()
+ endif()
+endif()
diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx
index 3fd195561..e45db36ac 100644
--- a/Source/kwsys/CommandLineArguments.cxx
+++ b/Source/kwsys/CommandLineArguments.cxx
@@ -20,9 +20,9 @@
#include <sstream>
#include <vector>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#ifdef _MSC_VER
# pragma warning(disable : 4786)
@@ -66,26 +66,21 @@ class CommandLineArgumentsMapOfStrucs
class CommandLineArgumentsInternal
{
public:
- CommandLineArgumentsInternal()
- : UnknownArgumentCallback{ nullptr }
- , ClientData{ nullptr }
- , LastArgument{ 0 }
- {
- }
+ CommandLineArgumentsInternal() = default;
- typedef CommandLineArgumentsVectorOfStrings VectorOfStrings;
- typedef CommandLineArgumentsMapOfStrucs CallbacksMap;
- typedef kwsys::String String;
- typedef CommandLineArgumentsSetOfStrings SetOfStrings;
+ using VectorOfStrings = CommandLineArgumentsVectorOfStrings;
+ using CallbacksMap = CommandLineArgumentsMapOfStrucs;
+ using String = kwsys::String;
+ using SetOfStrings = CommandLineArgumentsSetOfStrings;
VectorOfStrings Argv;
String Argv0;
CallbacksMap Callbacks;
- CommandLineArguments::ErrorCallbackType UnknownArgumentCallback;
- void* ClientData;
+ CommandLineArguments::ErrorCallbackType UnknownArgumentCallback{ nullptr };
+ void* ClientData{ nullptr };
- VectorOfStrings::size_type LastArgument;
+ VectorOfStrings::size_type LastArgument{ 0 };
VectorOfStrings UnusedArguments;
};
@@ -424,8 +419,7 @@ void CommandLineArguments::SetUnknownArgumentCallback(
const char* CommandLineArguments::GetHelp(const char* arg)
{
- CommandLineArguments::Internal::CallbacksMap::iterator it =
- this->Internals->Callbacks.find(arg);
+ auto it = this->Internals->Callbacks.find(arg);
if (it == this->Internals->Callbacks.end()) {
return nullptr;
}
@@ -434,8 +428,7 @@ const char* CommandLineArguments::GetHelp(const char* arg)
// one point to if this one is pointing to another argument.
CommandLineArgumentsCallbackStructure* cs = &(it->second);
for (;;) {
- CommandLineArguments::Internal::CallbacksMap::iterator hit =
- this->Internals->Callbacks.find(cs->Help);
+ auto hit = this->Internals->Callbacks.find(cs->Help);
if (hit == this->Internals->Callbacks.end()) {
break;
}
@@ -470,9 +463,8 @@ void CommandLineArguments::GenerateHelp()
// Collapse all arguments into the map of vectors of all arguments that do
// the same thing.
CommandLineArguments::Internal::CallbacksMap::iterator it;
- typedef std::map<CommandLineArguments::Internal::String,
- CommandLineArguments::Internal::SetOfStrings>
- MapArgs;
+ using MapArgs = std::map<CommandLineArguments::Internal::String,
+ CommandLineArguments::Internal::SetOfStrings>;
MapArgs mp;
MapArgs::iterator mpit, smpit;
for (it = this->Internals->Callbacks.begin();
@@ -709,7 +701,7 @@ bool CommandLineArguments::PopulateVariable(
if (cs->Callback) {
if (!cs->Callback(cs->Argument, value, cs->CallData)) {
this->Internals->LastArgument--;
- return 0;
+ return false;
}
}
CommandLineArguments_DEBUG("Set argument: " << cs->Argument << " to "
@@ -759,10 +751,10 @@ bool CommandLineArguments::PopulateVariable(
std::cerr << "Got unknown variable type: \"" << cs->VariableType
<< "\"" << std::endl;
this->Internals->LastArgument--;
- return 0;
+ return false;
}
}
- return 1;
+ return true;
}
} // namespace KWSYS_NAMESPACE
diff --git a/Source/kwsys/Configure.h.in b/Source/kwsys/Configure.h.in
index 5323c57be..8a237cea3 100644
--- a/Source/kwsys/Configure.h.in
+++ b/Source/kwsys/Configure.h.in
@@ -13,9 +13,6 @@
/* Disable some warnings inside kwsys source files. */
#if defined(KWSYS_NAMESPACE)
-# if defined(__BORLANDC__)
-# pragma warn - 8027 /* function not inlined. */
-# endif
# if defined(__INTEL_COMPILER)
# pragma warning(disable : 1572) /* floating-point equality test */
# endif
@@ -68,11 +65,6 @@
# pragma warning(disable : 4710) /* function not inlined */
# pragma warning(disable : 4786) /* identifier truncated in debug info */
# endif
-# if defined(__BORLANDC__) && !defined(__cplusplus)
-/* Code has no effect; raised by winnt.h in C (not C++) when ignoring an
- unused parameter using "(param)" syntax (i.e. no cast to void). */
-# pragma warn - 8019
-# endif
#endif
/* MSVC 6.0 in release mode will warn about code it produces with its
diff --git a/Source/kwsys/Directory.cxx b/Source/kwsys/Directory.cxx
index e3791826b..0c2190aee 100644
--- a/Source/kwsys/Directory.cxx
+++ b/Source/kwsys/Directory.cxx
@@ -35,6 +35,18 @@ Directory::Directory()
this->Internal = new DirectoryInternals;
}
+Directory::Directory(Directory&& other)
+{
+ this->Internal = other.Internal;
+ other.Internal = nullptr;
+}
+
+Directory& Directory::operator=(Directory&& other)
+{
+ std::swap(this->Internal, other.Internal);
+ return *this;
+}
+
Directory::~Directory()
{
delete this->Internal;
@@ -80,26 +92,12 @@ void Directory::Clear()
# include <sys/stat.h>
# include <sys/types.h>
-// Wide function names can vary depending on compiler:
-# ifdef __BORLANDC__
-# define _wfindfirst_func __wfindfirst
-# define _wfindnext_func __wfindnext
-# else
-# define _wfindfirst_func _wfindfirst
-# define _wfindnext_func _wfindnext
-# endif
-
namespace KWSYS_NAMESPACE {
-bool Directory::Load(const std::string& name)
+bool Directory::Load(const std::string& name, std::string* errorMessage)
{
this->Clear();
-# if (defined(_MSC_VER) && _MSC_VER < 1300) || defined(__BORLANDC__)
- // Older Visual C++ and Embarcadero compilers.
- long srchHandle;
-# else // Newer Visual C++
intptr_t srchHandle;
-# endif
char* buf;
size_t n = name.size();
if (name.back() == '/' || name.back() == '\\') {
@@ -118,8 +116,8 @@ bool Directory::Load(const std::string& name)
struct _wfinddata_t data; // data of current file
// Now put them into the file array
- srchHandle = _wfindfirst_func(
- (wchar_t*)Encoding::ToWindowsExtendedPath(buf).c_str(), &data);
+ srchHandle =
+ _wfindfirst((wchar_t*)Encoding::ToWindowsExtendedPath(buf).c_str(), &data);
delete[] buf;
if (srchHandle == -1) {
@@ -129,19 +127,15 @@ bool Directory::Load(const std::string& name)
// Loop through names
do {
this->Internal->Files.push_back(Encoding::ToNarrow(data.name));
- } while (_wfindnext_func(srchHandle, &data) != -1);
+ } while (_wfindnext(srchHandle, &data) != -1);
this->Internal->Path = name;
return _findclose(srchHandle) != -1;
}
-unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
+unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name,
+ std::string* errorMessage)
{
-# if (defined(_MSC_VER) && _MSC_VER < 1300) || defined(__BORLANDC__)
- // Older Visual C++ and Embarcadero compilers.
- long srchHandle;
-# else // Newer Visual C++
intptr_t srchHandle;
-# endif
char* buf;
size_t n = name.size();
if (name.back() == '/') {
@@ -154,8 +148,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
struct _wfinddata_t data; // data of current file
// Now put them into the file array
- srchHandle =
- _wfindfirst_func((wchar_t*)Encoding::ToWide(buf).c_str(), &data);
+ srchHandle = _wfindfirst((wchar_t*)Encoding::ToWide(buf).c_str(), &data);
delete[] buf;
if (srchHandle == -1) {
@@ -166,7 +159,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
unsigned long count = 0;
do {
count++;
- } while (_wfindnext_func(srchHandle, &data) != -1);
+ } while (_wfindnext(srchHandle, &data) != -1);
_findclose(srchHandle);
return count;
}
@@ -180,6 +173,8 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
# include <sys/types.h>
# include <dirent.h>
+# include <errno.h>
+# include <string.h>
// PGI with glibc has trouble with dirent and large file support:
// http://www.pgroup.com/userforum/viewtopic.php?
@@ -197,29 +192,46 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
namespace KWSYS_NAMESPACE {
-bool Directory::Load(const std::string& name)
+bool Directory::Load(const std::string& name, std::string* errorMessage)
{
this->Clear();
+ errno = 0;
DIR* dir = opendir(name.c_str());
if (!dir) {
- return 0;
+ if (errorMessage != nullptr) {
+ *errorMessage = std::string(strerror(errno));
+ }
+ return false;
}
+ errno = 0;
for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir)) {
- this->Internal->Files.push_back(d->d_name);
+ this->Internal->Files.emplace_back(d->d_name);
+ }
+ if (errno != 0) {
+ if (errorMessage != nullptr) {
+ *errorMessage = std::string(strerror(errno));
+ }
+ return false;
}
+
this->Internal->Path = name;
closedir(dir);
- return 1;
+ return true;
}
-unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
+unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name,
+ std::string* errorMessage)
{
+ errno = 0;
DIR* dir = opendir(name.c_str());
if (!dir) {
+ if (errorMessage != nullptr) {
+ *errorMessage = std::string(strerror(errno));
+ }
return 0;
}
@@ -227,6 +239,13 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir)) {
count++;
}
+ if (errno != 0) {
+ if (errorMessage != nullptr) {
+ *errorMessage = std::string(strerror(errno));
+ }
+ return false;
+ }
+
closedir(dir);
return count;
}
diff --git a/Source/kwsys/Directory.hxx.in b/Source/kwsys/Directory.hxx.in
index ad8c51b86..7bc9db024 100644
--- a/Source/kwsys/Directory.hxx.in
+++ b/Source/kwsys/Directory.hxx.in
@@ -23,6 +23,11 @@ class @KWSYS_NAMESPACE@_EXPORT Directory
{
public:
Directory();
+ Directory(Directory&& other);
+ Directory(const Directory&) = delete;
+ Directory& operator=(const Directory&) = delete;
+ Directory& operator=(Directory&& other);
+ bool operator==(const Directory&) = delete;
~Directory();
/**
@@ -30,7 +35,7 @@ public:
* in that directory. 0 is returned if the directory can not be
* opened, 1 if it is opened.
*/
- bool Load(const std::string&);
+ bool Load(const std::string&, std::string* errorMessage = nullptr);
/**
* Return the number of files in the current directory.
@@ -41,7 +46,8 @@ public:
* Return the number of files in the specified directory.
* A higher performance static method.
*/
- static unsigned long GetNumberOfFilesInDirectory(const std::string&);
+ static unsigned long GetNumberOfFilesInDirectory(
+ const std::string&, std::string* errorMessage = nullptr);
/**
* Return the file at the given index, the indexing is 0 based
@@ -62,10 +68,7 @@ public:
private:
// Private implementation details.
DirectoryInternals* Internal;
-
- Directory(const Directory&); // Not implemented.
- void operator=(const Directory&); // Not implemented.
-}; // End Class: Directory
+}; // End Class: Directory
} // namespace @KWSYS_NAMESPACE@
diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx
index a4b864118..66ee9eafa 100644
--- a/Source/kwsys/DynamicLoader.cxx
+++ b/Source/kwsys/DynamicLoader.cxx
@@ -246,17 +246,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
// should have a tool to help get the symbol with the desired
// calling convention. Currently we assume cdecl.
//
- // Borland:
- // __cdecl = "_func" (default)
- // __fastcall = "@_func"
- // __stdcall = "func"
- //
- // Watcom:
- // __cdecl = "_func"
- // __fastcall = "@_func@X"
- // __stdcall = "_func@X"
- // __watcall = "func_" (default)
- //
// MSVC:
// __cdecl = "func" (default)
// __fastcall = "@_func@X"
@@ -265,20 +254,9 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
// Note that the "@X" part of the name above is the total size (in
// bytes) of the arguments on the stack.
void* result;
-# if defined(__BORLANDC__) || defined(__WATCOMC__)
- // Need to prepend symbols with '_'
- std::string ssym = '_' + sym;
- const char* rsym = ssym.c_str();
-# else
const char* rsym = sym.c_str();
-# endif
result = (void*)GetProcAddress(lib, rsym);
-// Hack to cast pointer-to-data to pointer-to-function.
-# ifdef __WATCOMC__
- return *(DynamicLoader::SymbolPointer*)(&result);
-# else
return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
-# endif
}
# define DYNLOAD_ERROR_BUFFER_SIZE 1024
diff --git a/Source/kwsys/EncodingCXX.cxx b/Source/kwsys/EncodingCXX.cxx
index 5cad934ec..c68c73c8e 100644
--- a/Source/kwsys/EncodingCXX.cxx
+++ b/Source/kwsys/EncodingCXX.cxx
@@ -17,8 +17,8 @@
# include "Encoding.hxx.in"
#endif
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
#include <vector>
#ifdef _MSC_VER
diff --git a/Source/kwsys/ExtraTest.cmake.in b/Source/kwsys/ExtraTest.cmake.in
index e8c0a1cdb..4cec9e295 100644
--- a/Source/kwsys/ExtraTest.cmake.in
+++ b/Source/kwsys/ExtraTest.cmake.in
@@ -1 +1 @@
-MESSAGE("*** This message is generated by message inside a file that is included in DartTestfile.txt ***")
+message("*** This message is generated by message inside a file that is included in DartTestfile.txt ***")
diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx
index 34bb0d0fe..5452f733b 100644
--- a/Source/kwsys/Glob.cxx
+++ b/Source/kwsys/Glob.cxx
@@ -23,9 +23,9 @@
#include <string>
#include <vector>
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
+#include <cctype>
+#include <cstdio>
+#include <cstring>
namespace KWSYS_NAMESPACE {
#if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
// On Windows and Apple, no difference between lower and upper case
@@ -182,7 +182,15 @@ bool Glob::RecurseDirectory(std::string::size_type start,
const std::string& dir, GlobMessages* messages)
{
kwsys::Directory d;
- if (!d.Load(dir)) {
+ std::string errorMessage;
+ if (!d.Load(dir, &errorMessage)) {
+ if (messages) {
+ if (!errorMessage.empty()) {
+ messages->push_back(Message(Glob::warning,
+ "Error listing directory '" + dir +
+ "'! Reason: '" + errorMessage + "'"));
+ }
+ }
return true;
}
unsigned long cc;
@@ -278,7 +286,9 @@ void Glob::ProcessDirectory(std::string::size_type start,
// std::cout << "ProcessDirectory: " << dir << std::endl;
bool last = (start == this->Internals->Expressions.size() - 1);
if (last && this->Recurse) {
- this->RecurseDirectory(start, dir, messages);
+ if (kwsys::SystemTools::FileIsDirectory(dir)) {
+ this->RecurseDirectory(start, dir, messages);
+ }
return;
}
@@ -385,10 +395,9 @@ bool Glob::FindFiles(const std::string& inexpr, GlobMessages* messages)
}
if (skip > 0) {
- expr = expr.substr(skip);
+ expr.erase(0, skip);
}
- cexpr = "";
for (cc = 0; cc < expr.size(); cc++) {
int ch = expr[cc];
if (ch == '/') {
@@ -415,8 +424,7 @@ bool Glob::FindFiles(const std::string& inexpr, GlobMessages* messages)
void Glob::AddExpression(const std::string& expr)
{
- this->Internals->Expressions.push_back(
- kwsys::RegularExpression(this->PatternToRegex(expr)));
+ this->Internals->Expressions.emplace_back(this->PatternToRegex(expr));
}
void Glob::SetRelative(const char* dir)
diff --git a/Source/kwsys/Glob.hxx.in b/Source/kwsys/Glob.hxx.in
index 170766f4b..b5a34d59a 100644
--- a/Source/kwsys/Glob.hxx.in
+++ b/Source/kwsys/Glob.hxx.in
@@ -28,6 +28,7 @@ public:
enum MessageType
{
error,
+ warning,
cyclicRecursion
};
diff --git a/Source/kwsys/IOStream.cxx b/Source/kwsys/IOStream.cxx
deleted file mode 100644
index e21f87d45..000000000
--- a/Source/kwsys/IOStream.cxx
+++ /dev/null
@@ -1,255 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
-#include "kwsysPrivate.h"
-#include KWSYS_HEADER(Configure.hxx)
-
-// Include the streams library.
-#include <iostream>
-#include KWSYS_HEADER(IOStream.hxx)
-
-// Work-around CMake dependency scanning limitation. This must
-// duplicate the above list of headers.
-#if 0
-# include "Configure.hxx.in"
-# include "IOStream.hxx.in"
-#endif
-
-// Implement the rest of this file only if it is needed.
-#if KWSYS_IOS_NEED_OPERATORS_LL
-
-# include <stdio.h> // sscanf, sprintf
-# include <string.h> // memchr
-
-# if defined(_MAX_INT_DIG)
-# define KWSYS_IOS_INT64_MAX_DIG _MAX_INT_DIG
-# else
-# define KWSYS_IOS_INT64_MAX_DIG 32
-# endif
-
-namespace KWSYS_NAMESPACE {
-
-// Scan an input stream for an integer value.
-static int IOStreamScanStream(std::istream& is, char* buffer)
-{
- // Prepare to write to buffer.
- char* out = buffer;
- char* end = buffer + KWSYS_IOS_INT64_MAX_DIG - 1;
-
- // Look for leading sign.
- if (is.peek() == '+') {
- *out++ = '+';
- is.ignore();
- } else if (is.peek() == '-') {
- *out++ = '-';
- is.ignore();
- }
-
- // Determine the base. If not specified in the stream, try to
- // detect it from the input. A leading 0x means hex, and a leading
- // 0 alone means octal.
- int base = 0;
- int flags = is.flags() & std::ios_base::basefield;
- if (flags == std::ios_base::oct) {
- base = 8;
- } else if (flags == std::ios_base::dec) {
- base = 10;
- } else if (flags == std::ios_base::hex) {
- base = 16;
- }
- bool foundDigit = false;
- bool foundNonZero = false;
- if (is.peek() == '0') {
- foundDigit = true;
- is.ignore();
- if ((is.peek() == 'x' || is.peek() == 'X') && (base == 0 || base == 16)) {
- base = 16;
- foundDigit = false;
- is.ignore();
- } else if (base == 0) {
- base = 8;
- }
- }
-
- // Determine the range of digits allowed for this number.
- const char* digits = "0123456789abcdefABCDEF";
- int maxDigitIndex = 10;
- if (base == 8) {
- maxDigitIndex = 8;
- } else if (base == 16) {
- maxDigitIndex = 10 + 6 + 6;
- }
-
- // Scan until an invalid digit is found.
- for (; is.peek() != EOF; is.ignore()) {
- if (memchr(digits, *out = (char)is.peek(), maxDigitIndex) != 0) {
- if ((foundNonZero || *out != '0') && out < end) {
- ++out;
- foundNonZero = true;
- }
- foundDigit = true;
- } else {
- break;
- }
- }
-
- // Correct the buffer contents for degenerate cases.
- if (foundDigit && !foundNonZero) {
- *out++ = '0';
- } else if (!foundDigit) {
- out = buffer;
- }
-
- // Terminate the string in the buffer.
- *out = '\0';
-
- return base;
-}
-
-// Read an integer value from an input stream.
-template <class T>
-std::istream& IOStreamScanTemplate(std::istream& is, T& value, char type)
-{
- int state = std::ios_base::goodbit;
-
- // Skip leading whitespace.
- std::istream::sentry okay(is);
-
- if (okay) {
- try {
- // Copy the string to a buffer and construct the format string.
- char buffer[KWSYS_IOS_INT64_MAX_DIG];
-# if defined(_MSC_VER)
- char format[] = "%I64_";
- const int typeIndex = 4;
-# else
- char format[] = "%ll_";
- const int typeIndex = 3;
-# endif
- switch (IOStreamScanStream(is, buffer)) {
- case 8:
- format[typeIndex] = 'o';
- break;
- case 0: // Default to decimal if not told otherwise.
- case 10:
- format[typeIndex] = type;
- break;
- case 16:
- format[typeIndex] = 'x';
- break;
- };
-
- // Use sscanf to parse the number from the buffer.
- T result;
- int success = (sscanf(buffer, format, &result) == 1) ? 1 : 0;
-
- // Set flags for resulting state.
- if (is.peek() == EOF) {
- state |= std::ios_base::eofbit;
- }
- if (!success) {
- state |= std::ios_base::failbit;
- } else {
- value = result;
- }
- } catch (...) {
- state |= std::ios_base::badbit;
- }
- }
-
- is.setstate(std::ios_base::iostate(state));
- return is;
-}
-
-// Print an integer value to an output stream.
-template <class T>
-std::ostream& IOStreamPrintTemplate(std::ostream& os, T value, char type)
-{
- std::ostream::sentry okay(os);
- if (okay) {
- try {
- // Construct the format string.
- char format[8];
- char* f = format;
- *f++ = '%';
- if (os.flags() & std::ios_base::showpos) {
- *f++ = '+';
- }
- if (os.flags() & std::ios_base::showbase) {
- *f++ = '#';
- }
-# if defined(_MSC_VER)
- *f++ = 'I';
- *f++ = '6';
- *f++ = '4';
-# else
- *f++ = 'l';
- *f++ = 'l';
-# endif
- long bflags = os.flags() & std::ios_base::basefield;
- if (bflags == std::ios_base::oct) {
- *f++ = 'o';
- } else if (bflags != std::ios_base::hex) {
- *f++ = type;
- } else if (os.flags() & std::ios_base::uppercase) {
- *f++ = 'X';
- } else {
- *f++ = 'x';
- }
- *f = '\0';
-
- // Use sprintf to print to a buffer and then write the
- // buffer to the stream.
- char buffer[2 * KWSYS_IOS_INT64_MAX_DIG];
- sprintf(buffer, format, value);
- os << buffer;
- } catch (...) {
- os.clear(os.rdstate() | std::ios_base::badbit);
- }
- }
- return os;
-}
-
-# if !KWSYS_IOS_HAS_ISTREAM_LONG_LONG
-// Implement input stream operator for IOStreamSLL.
-std::istream& IOStreamScan(std::istream& is, IOStreamSLL& value)
-{
- return IOStreamScanTemplate(is, value, 'd');
-}
-
-// Implement input stream operator for IOStreamULL.
-std::istream& IOStreamScan(std::istream& is, IOStreamULL& value)
-{
- return IOStreamScanTemplate(is, value, 'u');
-}
-# endif
-
-# if !KWSYS_IOS_HAS_OSTREAM_LONG_LONG
-// Implement output stream operator for IOStreamSLL.
-std::ostream& IOStreamPrint(std::ostream& os, IOStreamSLL value)
-{
- return IOStreamPrintTemplate(os, value, 'd');
-}
-
-// Implement output stream operator for IOStreamULL.
-std::ostream& IOStreamPrint(std::ostream& os, IOStreamULL value)
-{
- return IOStreamPrintTemplate(os, value, 'u');
-}
-# endif
-
-} // namespace KWSYS_NAMESPACE
-
-#else
-
-namespace KWSYS_NAMESPACE {
-
-// Create one public symbol in this object file to avoid warnings from
-// archivers.
-void IOStreamSymbolToAvoidWarning();
-void IOStreamSymbolToAvoidWarning()
-{
-}
-
-} // namespace KWSYS_NAMESPACE
-
-#endif // KWSYS_IOS_NEED_OPERATORS_LL
diff --git a/Source/kwsys/IOStream.hxx.in b/Source/kwsys/IOStream.hxx.in
deleted file mode 100644
index db8a23ef5..000000000
--- a/Source/kwsys/IOStream.hxx.in
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
-#ifndef @KWSYS_NAMESPACE@_IOStream_hxx
-#define @KWSYS_NAMESPACE@_IOStream_hxx
-
-#include <iosfwd>
-
-/* Define these macros temporarily to keep the code readable. */
-#if !defined(KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
-#endif
-
-/* Whether istream supports long long. */
-#define @KWSYS_NAMESPACE@_IOS_HAS_ISTREAM_LONG_LONG \
- @KWSYS_IOS_HAS_ISTREAM_LONG_LONG@
-
-/* Whether ostream supports long long. */
-#define @KWSYS_NAMESPACE@_IOS_HAS_OSTREAM_LONG_LONG \
- @KWSYS_IOS_HAS_OSTREAM_LONG_LONG@
-
-/* Determine whether we need to define the streaming operators for
- long long or __int64. */
-#if @KWSYS_USE_LONG_LONG@
-# if !@KWSYS_NAMESPACE@_IOS_HAS_ISTREAM_LONG_LONG || \
- !@KWSYS_NAMESPACE@_IOS_HAS_OSTREAM_LONG_LONG
-# define @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL 1
-namespace @KWSYS_NAMESPACE@ {
-typedef long long IOStreamSLL;
-typedef unsigned long long IOStreamULL;
-}
-# endif
-#elif defined(_MSC_VER) && _MSC_VER < 1300
-# define @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL 1
-namespace @KWSYS_NAMESPACE@ {
-typedef __int64 IOStreamSLL;
-typedef unsigned __int64 IOStreamULL;
-}
-#endif
-#if !defined(@KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL)
-# define @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL 0
-#endif
-
-#if @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL
-# if !@KWSYS_NAMESPACE@_IOS_HAS_ISTREAM_LONG_LONG
-
-/* Input stream operator implementation functions. */
-namespace @KWSYS_NAMESPACE@ {
-kwsysEXPORT std::istream& IOStreamScan(std::istream&, IOStreamSLL&);
-kwsysEXPORT std::istream& IOStreamScan(std::istream&, IOStreamULL&);
-}
-
-/* Provide input stream operator for long long. */
-# if !defined(@KWSYS_NAMESPACE@_IOS_NO_ISTREAM_LONG_LONG) && \
- !defined(KWSYS_IOS_ISTREAM_LONG_LONG_DEFINED)
-# define KWSYS_IOS_ISTREAM_LONG_LONG_DEFINED
-# define @KWSYS_NAMESPACE@_IOS_ISTREAM_LONG_LONG_DEFINED
-inline std::istream& operator>>(std::istream& is,
- @KWSYS_NAMESPACE@::IOStreamSLL& value)
-{
- return @KWSYS_NAMESPACE@::IOStreamScan(is, value);
-}
-# endif
-
-/* Provide input stream operator for unsigned long long. */
-# if !defined(@KWSYS_NAMESPACE@_IOS_NO_ISTREAM_UNSIGNED_LONG_LONG) && \
- !defined(KWSYS_IOS_ISTREAM_UNSIGNED_LONG_LONG_DEFINED)
-# define KWSYS_IOS_ISTREAM_UNSIGNED_LONG_LONG_DEFINED
-# define @KWSYS_NAMESPACE@_IOS_ISTREAM_UNSIGNED_LONG_LONG_DEFINED
-inline std::istream& operator>>(std::istream& is,
- @KWSYS_NAMESPACE@::IOStreamULL& value)
-{
- return @KWSYS_NAMESPACE@::IOStreamScan(is, value);
-}
-# endif
-# endif /* !@KWSYS_NAMESPACE@_IOS_HAS_ISTREAM_LONG_LONG */
-
-# if !@KWSYS_NAMESPACE@_IOS_HAS_OSTREAM_LONG_LONG
-
-/* Output stream operator implementation functions. */
-namespace @KWSYS_NAMESPACE@ {
-kwsysEXPORT std::ostream& IOStreamPrint(std::ostream&, IOStreamSLL);
-kwsysEXPORT std::ostream& IOStreamPrint(std::ostream&, IOStreamULL);
-}
-
-/* Provide output stream operator for long long. */
-# if !defined(@KWSYS_NAMESPACE@_IOS_NO_OSTREAM_LONG_LONG) && \
- !defined(KWSYS_IOS_OSTREAM_LONG_LONG_DEFINED)
-# define KWSYS_IOS_OSTREAM_LONG_LONG_DEFINED
-# define @KWSYS_NAMESPACE@_IOS_OSTREAM_LONG_LONG_DEFINED
-inline std::ostream& operator<<(std::ostream& os,
- @KWSYS_NAMESPACE@::IOStreamSLL value)
-{
- return @KWSYS_NAMESPACE@::IOStreamPrint(os, value);
-}
-# endif
-
-/* Provide output stream operator for unsigned long long. */
-# if !defined(@KWSYS_NAMESPACE@_IOS_NO_OSTREAM_UNSIGNED_LONG_LONG) && \
- !defined(KWSYS_IOS_OSTREAM_UNSIGNED_LONG_LONG_DEFINED)
-# define KWSYS_IOS_OSTREAM_UNSIGNED_LONG_LONG_DEFINED
-# define @KWSYS_NAMESPACE@_IOS_OSTREAM_UNSIGNED_LONG_LONG_DEFINED
-inline std::ostream& operator<<(std::ostream& os,
- @KWSYS_NAMESPACE@::IOStreamULL value)
-{
- return @KWSYS_NAMESPACE@::IOStreamPrint(os, value);
-}
-# endif
-# endif /* !@KWSYS_NAMESPACE@_IOS_HAS_OSTREAM_LONG_LONG */
-#endif /* @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL */
-
-/* Undefine temporary macros. */
-#if !defined(KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-# undef kwsysEXPORT
-#endif
-
-/* If building a C++ file in kwsys itself, give the source file
- access to the macros without a configured namespace. */
-#if defined(KWSYS_NAMESPACE)
-# define KWSYS_IOS_HAS_ISTREAM_LONG_LONG \
- @KWSYS_NAMESPACE@_IOS_HAS_ISTREAM_LONG_LONG
-# define KWSYS_IOS_HAS_OSTREAM_LONG_LONG \
- @KWSYS_NAMESPACE@_IOS_HAS_OSTREAM_LONG_LONG
-# define KWSYS_IOS_NEED_OPERATORS_LL @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL
-#endif
-
-#endif
diff --git a/Source/kwsys/MD5.c b/Source/kwsys/MD5.c
index 97cf9ba68..fb18a5bba 100644
--- a/Source/kwsys/MD5.c
+++ b/Source/kwsys/MD5.c
@@ -171,8 +171,10 @@ typedef struct md5_state_s
static void md5_process(md5_state_t* pms, const md5_byte_t* data /*[64]*/)
{
- md5_word_t a = pms->abcd[0], b = pms->abcd[1], c = pms->abcd[2],
- d = pms->abcd[3];
+ md5_word_t a = pms->abcd[0];
+ md5_word_t b = pms->abcd[1];
+ md5_word_t c = pms->abcd[2];
+ md5_word_t d = pms->abcd[3];
md5_word_t t;
#if BYTE_ORDER > 0
/* Define storage only for big-endian CPUs. */
@@ -227,9 +229,10 @@ static void md5_process(md5_state_t* pms, const md5_byte_t* data /*[64]*/)
# else
# define xbuf X /* (static only) */
# endif
- for (i = 0; i < 16; ++i, xp += 4)
+ for (i = 0; i < 16; ++i, xp += 4) {
xbuf[i] =
(md5_word_t)(xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24));
+ }
}
#endif
}
@@ -367,34 +370,39 @@ static void md5_append(md5_state_t* pms, const md5_byte_t* data, size_t nbytes)
size_t offset = (pms->count[0] >> 3) & 63;
md5_word_t nbits = (md5_word_t)(nbytes << 3);
- if (nbytes <= 0)
+ if (nbytes <= 0) {
return;
+ }
/* Update the message length. */
pms->count[1] += (md5_word_t)(nbytes >> 29);
pms->count[0] += nbits;
- if (pms->count[0] < nbits)
+ if (pms->count[0] < nbits) {
pms->count[1]++;
+ }
/* Process an initial partial block. */
if (offset) {
size_t copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
memcpy(pms->buf + offset, p, copy);
- if (offset + copy < 64)
+ if (offset + copy < 64) {
return;
+ }
p += copy;
left -= copy;
md5_process(pms, pms->buf);
}
/* Process full blocks. */
- for (; left >= 64; p += 64, left -= 64)
+ for (; left >= 64; p += 64, left -= 64) {
md5_process(pms, p);
+ }
/* Process a final partial block. */
- if (left)
+ if (left) {
memcpy(pms->buf, p, left);
+ }
}
/* Finish the message and return the digest. */
@@ -409,14 +417,16 @@ static void md5_finish(md5_state_t* pms, md5_byte_t digest[16])
int i;
/* Save the length before padding. */
- for (i = 0; i < 8; ++i)
+ for (i = 0; i < 8; ++i) {
data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
+ }
/* Pad to 56 bytes mod 64. */
md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
/* Append the length. */
md5_append(pms, data, 8);
- for (i = 0; i < 16; ++i)
+ for (i = 0; i < 16; ++i) {
digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
+ }
}
#if defined(__clang__) && !defined(__INTEL_COMPILER)
diff --git a/Source/kwsys/Process.h.in b/Source/kwsys/Process.h.in
index 73ea9dbfc..9f2162b3d 100644
--- a/Source/kwsys/Process.h.in
+++ b/Source/kwsys/Process.h.in
@@ -180,8 +180,8 @@ kwsysEXPORT void kwsysProcess_SetPipeShared(kwsysProcess* cp, int pipe,
* write end of the pipe will be closed in the parent process and the
* read end will be closed in the child process.
*/
-kwsysEXPORT void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe,
- kwsysProcess_Pipe_Handle p[2]);
+kwsysEXPORT void kwsysProcess_SetPipeNative(
+ kwsysProcess* cp, int pipe, const kwsysProcess_Pipe_Handle p[2]);
/**
* Get/Set a possibly platform-specific option. Possible options are:
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index f65690b31..cc4552913 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -152,10 +152,11 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
static void kwsysProcessDestroy(kwsysProcess* cp);
static int kwsysProcessSetupOutputPipeFile(int* p, const char* name);
static int kwsysProcessSetupOutputPipeNative(int* p, int des[2]);
-static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
+static int kwsysProcessGetTimeoutTime(kwsysProcess* cp,
+ const double* userTimeout,
kwsysProcessTime* timeoutTime);
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
- double* userTimeout,
+ const double* userTimeout,
kwsysProcessTimeNative* timeoutLength,
int zeroIsExpired);
static kwsysProcessTime kwsysProcessTimeGetCurrent(void);
@@ -431,8 +432,8 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command)
char const* const* c = command;
kwsysProcess_ptrdiff_t n = 0;
kwsysProcess_ptrdiff_t i = 0;
- while (*c++)
- ;
+ while (*c++) {
+ }
n = c - command - 1;
newCommands[cp->NumberOfCommands] =
(char**)malloc((size_t)(n + 1) * sizeof(char*));
@@ -571,7 +572,7 @@ void kwsysProcess_SetPipeShared(kwsysProcess* cp, int prPipe, int shared)
}
}
-void kwsysProcess_SetPipeNative(kwsysProcess* cp, int prPipe, int p[2])
+void kwsysProcess_SetPipeNative(kwsysProcess* cp, int prPipe, const int p[2])
{
int* pPipeNative = 0;
@@ -684,7 +685,8 @@ const char* kwsysProcess_GetErrorString(kwsysProcess* cp)
{
if (!cp) {
return "Process management structure could not be allocated";
- } else if (cp->State == kwsysProcess_State_Error) {
+ }
+ if (cp->State == kwsysProcess_State_Error) {
return cp->ErrorMessage;
}
return "Success";
@@ -694,7 +696,8 @@ const char* kwsysProcess_GetExceptionString(kwsysProcess* cp)
{
if (!(cp && cp->ProcessResults && (cp->NumberOfCommands > 0))) {
return "GetExceptionString called with NULL process management structure";
- } else if (cp->State == kwsysProcess_State_Exception) {
+ }
+ if (cp->State == kwsysProcess_State_Exception) {
return cp->ProcessResults[cp->NumberOfCommands - 1].ExitExceptionString;
}
return "No exception";
@@ -786,8 +789,8 @@ void kwsysProcess_Execute(kwsysProcess* cp)
/* Some platforms specify that the chdir call may be
interrupted. Repeat the call until it finishes. */
- while (((r = chdir(cp->WorkingDirectory)) < 0) && (errno == EINTR))
- ;
+ while (((r = chdir(cp->WorkingDirectory)) < 0) && (errno == EINTR)) {
+ }
if (r < 0) {
kwsysProcessCleanup(cp, 1);
return;
@@ -1013,8 +1016,8 @@ void kwsysProcess_Execute(kwsysProcess* cp)
if (cp->RealWorkingDirectory) {
/* Some platforms specify that the chdir call may be
interrupted. Repeat the call until it finishes. */
- while ((chdir(cp->RealWorkingDirectory) < 0) && (errno == EINTR))
- ;
+ while ((chdir(cp->RealWorkingDirectory) < 0) && (errno == EINTR)) {
+ }
free(cp->RealWorkingDirectory);
cp->RealWorkingDirectory = 0;
}
@@ -1099,22 +1102,22 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length,
if (wd.PipeId) {
/* Data are ready on a pipe. */
return wd.PipeId;
- } else if (wd.Expired) {
+ }
+ if (wd.Expired) {
/* A timeout has expired. */
if (wd.User) {
/* The user timeout has expired. It has no time left. */
return kwsysProcess_Pipe_Timeout;
- } else {
- /* The process timeout has expired. Kill the children now. */
- kwsysProcess_Kill(cp);
- cp->Killed = 0;
- cp->TimeoutExpired = 1;
- return kwsysProcess_Pipe_None;
}
- } else {
- /* No pipes are left open. */
+
+ /* The process timeout has expired. Kill the children now. */
+ kwsysProcess_Kill(cp);
+ cp->Killed = 0;
+ cp->TimeoutExpired = 1;
return kwsysProcess_Pipe_None;
}
+ /* No pipes are left open. */
+ return kwsysProcess_Pipe_None;
}
static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
@@ -1144,8 +1147,8 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
read until the operation is not interrupted. */
while (((n = read(cp->PipeReadEnds[i], cp->PipeBuffer,
KWSYSPE_PIPE_BUFFER_SIZE)) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
if (n > 0) {
/* We have data on this pipe. */
if (i == KWSYSPE_PIPE_SIGNAL) {
@@ -1183,7 +1186,7 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
/* Make sure the set is empty (it should always be empty here
anyway). */
- FD_ZERO(&cp->PipeSet);
+ FD_ZERO(&cp->PipeSet); // NOLINT(readability-isolate-declaration)
/* Setup a timeout if required. */
if (wd->TimeoutTime.tv_sec < 0) {
@@ -1218,15 +1221,16 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
/* Run select to block until data are available. Repeat call
until it is not interrupted. */
while (((numReady = select(max + 1, &cp->PipeSet, 0, 0, timeout)) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
/* Check result of select. */
if (numReady == 0) {
/* Select's timeout expired. */
wd->Expired = 1;
return 1;
- } else if (numReady < 0) {
+ }
+ if (numReady < 0) {
/* Select returned an error. Leave the error description in the
pipe buffer. */
strncpy(cp->ErrorMessage, strerror(errno), KWSYSPE_PIPE_BUFFER_SIZE);
@@ -1366,11 +1370,13 @@ int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout)
cp->ProcessResults[prPipe].State = kwsysProcess_StateByIndex_Exited;
cp->ProcessResults[prPipe].ExitException = kwsysProcess_Exception_None;
cp->ProcessResults[prPipe].ExitValue =
+ // NOLINTNEXTLINE(google-readability-casting)
(int)WEXITSTATUS(cp->ProcessResults[prPipe].ExitCode);
} else if (WIFSIGNALED(cp->ProcessResults[prPipe].ExitCode)) {
/* The child received an unhandled signal. */
cp->ProcessResults[prPipe].State = kwsysProcess_State_Exception;
kwsysProcessSetExitExceptionByIndex(
+ // NOLINTNEXTLINE(google-readability-casting)
cp, (int)WTERMSIG(cp->ProcessResults[prPipe].ExitCode), prPipe);
} else {
/* Error getting the child return code. */
@@ -1449,8 +1455,8 @@ void kwsysProcess_Kill(kwsysProcess* cp)
/* Reap the child. Keep trying until the call is not
interrupted. */
- while ((waitpid(cp->ForkPIDs[i], &status, 0) < 0) && (errno == EINTR))
- ;
+ while ((waitpid(cp->ForkPIDs[i], &status, 0) < 0) && (errno == EINTR)) {
+ }
}
}
@@ -1501,7 +1507,7 @@ static int kwsysProcessInitialize(kwsysProcess* cp)
cp->PipesLeft = 0;
cp->CommandsLeft = 0;
#if KWSYSPE_USE_SELECT
- FD_ZERO(&cp->PipeSet);
+ FD_ZERO(&cp->PipeSet); // NOLINT(readability-isolate-declaration)
#endif
cp->State = kwsysProcess_State_Starting;
cp->Killed = 0;
@@ -1590,16 +1596,16 @@ static void kwsysProcessCleanup(kwsysProcess* cp, int error)
/* Reap the child. Keep trying until the call is not
interrupted. */
while ((waitpid(cp->ForkPIDs[i], &status, 0) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
}
}
}
/* Restore the working directory. */
if (cp->RealWorkingDirectory) {
- while ((chdir(cp->RealWorkingDirectory) < 0) && (errno == EINTR))
- ;
+ while ((chdir(cp->RealWorkingDirectory) < 0) && (errno == EINTR)) {
+ }
}
}
@@ -1635,8 +1641,8 @@ static void kwsysProcessCleanupDescriptor(int* pfd)
if (pfd && *pfd > 2) {
/* Keep trying to close until it is not interrupted by a
* signal. */
- while ((close(*pfd) < 0) && (errno == EINTR))
- ;
+ while ((close(*pfd) < 0) && (errno == EINTR)) {
+ }
*pfd = -1;
}
}
@@ -1661,8 +1667,8 @@ static void kwsysProcessClosePipes(kwsysProcess* cp)
read until the operation is not interrupted. */
while ((read(cp->PipeReadEnds[i], cp->PipeBuffer,
KWSYSPE_PIPE_BUFFER_SIZE) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
}
#endif
@@ -1689,7 +1695,8 @@ int decc$set_child_standard_streams(int fd1, int fd2, int fd3);
static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
kwsysProcessCreateInformation* si)
{
- sigset_t mask, old_mask;
+ sigset_t mask;
+ sigset_t old_mask;
int pgidPipe[2];
char tmp;
ssize_t readRes;
@@ -1817,8 +1824,8 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
/* Make sure the child is in the process group before we proceed. This
avoids race conditions with calls to the kill function that we make for
signalling process groups. */
- while ((readRes = read(pgidPipe[0], &tmp, 1)) > 0)
- ;
+ while ((readRes = read(pgidPipe[0], &tmp, 1)) > 0) {
+ }
if (readRes < 0) {
sigprocmask(SIG_SETMASK, &old_mask, 0);
kwsysProcessCleanupDescriptor(&si->ErrorPipe[0]);
@@ -1846,8 +1853,8 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
/* Keep trying to read until the operation is not interrupted. */
while (((n = read(si->ErrorPipe[0], cp->ErrorMessage + total,
(size_t)(KWSYSPE_PIPE_BUFFER_SIZE - total))) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
if (n > 0) {
total += n;
}
@@ -1872,7 +1879,8 @@ static void kwsysProcessDestroy(kwsysProcess* cp)
int i;
/* Temporarily disable signals that access ForkPIDs. We don't want them to
read a reaped PID, and writes to ForkPIDs are not atomic. */
- sigset_t mask, old_mask;
+ sigset_t mask;
+ sigset_t old_mask;
sigemptyset(&mask);
sigaddset(&mask, SIGINT);
sigaddset(&mask, SIGTERM);
@@ -1885,8 +1893,8 @@ static void kwsysProcessDestroy(kwsysProcess* cp)
int result;
while (((result = waitpid(cp->ForkPIDs[i], &cp->CommandExitCodes[i],
WNOHANG)) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
if (result > 0) {
/* This child has termianted. */
cp->ForkPIDs[i] = 0;
@@ -1959,7 +1967,8 @@ static int kwsysProcessSetupOutputPipeNative(int* p, int des[2])
/* Get the time at which either the process or user timeout will
expire. Returns 1 if the user timeout is first, and 0 otherwise. */
-static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
+static int kwsysProcessGetTimeoutTime(kwsysProcess* cp,
+ const double* userTimeout,
kwsysProcessTime* timeoutTime)
{
/* The first time this is called, we need to calculate the time at
@@ -1991,35 +2000,33 @@ static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
/* Get the length of time before the given timeout time arrives.
Returns 1 if the time has already arrived, and 0 otherwise. */
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
- double* userTimeout,
+ const double* userTimeout,
kwsysProcessTimeNative* timeoutLength,
int zeroIsExpired)
{
if (timeoutTime->tv_sec < 0) {
/* No timeout time has been requested. */
return 0;
- } else {
- /* Calculate the remaining time. */
- kwsysProcessTime currentTime = kwsysProcessTimeGetCurrent();
- kwsysProcessTime timeLeft =
- kwsysProcessTimeSubtract(*timeoutTime, currentTime);
- if (timeLeft.tv_sec < 0 && userTimeout && *userTimeout <= 0) {
- /* Caller has explicitly requested a zero timeout. */
- timeLeft.tv_sec = 0;
- timeLeft.tv_usec = 0;
- }
+ }
+ /* Calculate the remaining time. */
+ kwsysProcessTime currentTime = kwsysProcessTimeGetCurrent();
+ kwsysProcessTime timeLeft =
+ kwsysProcessTimeSubtract(*timeoutTime, currentTime);
+ if (timeLeft.tv_sec < 0 && userTimeout && *userTimeout <= 0) {
+ /* Caller has explicitly requested a zero timeout. */
+ timeLeft.tv_sec = 0;
+ timeLeft.tv_usec = 0;
+ }
- if (timeLeft.tv_sec < 0 ||
- (timeLeft.tv_sec == 0 && timeLeft.tv_usec == 0 && zeroIsExpired)) {
- /* Timeout has already expired. */
- return 1;
- } else {
- /* There is some time left. */
- timeoutLength->tv_sec = timeLeft.tv_sec;
- timeoutLength->tv_usec = timeLeft.tv_usec;
- return 0;
- }
+ if (timeLeft.tv_sec < 0 ||
+ (timeLeft.tv_sec == 0 && timeLeft.tv_usec == 0 && zeroIsExpired)) {
+ /* Timeout has already expired. */
+ return 1;
}
+ /* There is some time left. */
+ timeoutLength->tv_sec = timeLeft.tv_sec;
+ timeoutLength->tv_usec = timeLeft.tv_usec;
+ return 0;
}
static kwsysProcessTime kwsysProcessTimeGetCurrent(void)
@@ -2424,41 +2431,39 @@ static pid_t kwsysProcessFork(kwsysProcess* cp,
if (middle_pid < 0) {
/* Fork failed. Return as if we were not detaching. */
return middle_pid;
- } else if (middle_pid == 0) {
+ }
+ if (middle_pid == 0) {
/* This is the intermediate process. Create the real child. */
pid_t child_pid = fork();
if (child_pid == 0) {
/* This is the real child process. There is nothing to do here. */
return 0;
- } else {
- /* Use the error pipe to report the pid to the real parent. */
- while ((write(si->ErrorPipe[1], &child_pid, sizeof(child_pid)) < 0) &&
- (errno == EINTR))
- ;
-
- /* Exit without cleanup. The parent holds all resources. */
- kwsysProcessExit();
- return 0; /* Never reached, but avoids SunCC warning. */
}
- } else {
- /* This is the original parent process. The intermediate
- process will use the error pipe to report the pid of the
- detached child. */
- pid_t child_pid;
- int status;
- while ((read(si->ErrorPipe[0], &child_pid, sizeof(child_pid)) < 0) &&
- (errno == EINTR))
- ;
+ /* Use the error pipe to report the pid to the real parent. */
+ while ((write(si->ErrorPipe[1], &child_pid, sizeof(child_pid)) < 0) &&
+ (errno == EINTR)) {
+ }
- /* Wait for the intermediate process to exit and clean it up. */
- while ((waitpid(middle_pid, &status, 0) < 0) && (errno == EINTR))
- ;
- return child_pid;
+ /* Exit without cleanup. The parent holds all resources. */
+ kwsysProcessExit();
+ return 0; /* Never reached, but avoids SunCC warning. */
}
- } else {
- /* Not creating a detached process. Use normal fork. */
- return fork();
+ /* This is the original parent process. The intermediate
+ process will use the error pipe to report the pid of the
+ detached child. */
+ pid_t child_pid;
+ int status;
+ while ((read(si->ErrorPipe[0], &child_pid, sizeof(child_pid)) < 0) &&
+ (errno == EINTR)) {
+ }
+
+ /* Wait for the intermediate process to exit and clean it up. */
+ while ((waitpid(middle_pid, &status, 0) < 0) && (errno == EINTR)) {
+ }
+ return child_pid;
}
+ /* Not creating a detached process. Use normal fork. */
+ return fork();
}
#endif
@@ -2563,7 +2568,8 @@ static void kwsysProcessKill(pid_t process_id)
/* Make sure the process started and provided a valid header. */
if (ps && fscanf(ps, "%*[^\n]\n") != EOF) {
/* Look for processes whose parent is the process being killed. */
- int pid, ppid;
+ int pid;
+ int ppid;
while (fscanf(ps, KWSYSPE_PS_FORMAT, &pid, &ppid) == 2) {
if (ppid == process_id) {
/* Recursively kill this child and its children. */
@@ -2725,8 +2731,8 @@ static int kwsysProcessesAdd(kwsysProcess* cp)
sigemptyset(&newSigAction.sa_mask);
while ((sigaction(SIGCHLD, &newSigAction,
&kwsysProcessesOldSigChldAction) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
/* Install our handler for SIGINT / SIGTERM. Repeat call until
it is not interrupted. */
@@ -2734,15 +2740,15 @@ static int kwsysProcessesAdd(kwsysProcess* cp)
sigaddset(&newSigAction.sa_mask, SIGTERM);
while ((sigaction(SIGINT, &newSigAction,
&kwsysProcessesOldSigIntAction) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
sigemptyset(&newSigAction.sa_mask);
sigaddset(&newSigAction.sa_mask, SIGINT);
while ((sigaction(SIGTERM, &newSigAction,
&kwsysProcessesOldSigIntAction) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
}
}
@@ -2773,14 +2779,14 @@ static void kwsysProcessesRemove(kwsysProcess* cp)
/* Restore the signal handlers. Repeat call until it is not
interrupted. */
while ((sigaction(SIGCHLD, &kwsysProcessesOldSigChldAction, 0) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
while ((sigaction(SIGINT, &kwsysProcessesOldSigIntAction, 0) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
while ((sigaction(SIGTERM, &kwsysProcessesOldSigTermAction, 0) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
/* Free the table of process pointers since it is now empty.
This is safe because the signal handler has been removed. */
@@ -2806,7 +2812,10 @@ static void kwsysProcessesSignalHandler(int signum
#endif
)
{
- int i, j, procStatus, old_errno = errno;
+ int i;
+ int j;
+ int procStatus;
+ int old_errno = errno;
#if KWSYSPE_USE_SIGINFO
(void)info;
(void)ucontext;
@@ -2863,8 +2872,8 @@ static void kwsysProcessesSignalHandler(int signum
memset(&defSigAction, 0, sizeof(defSigAction));
defSigAction.sa_handler = SIG_DFL;
sigemptyset(&defSigAction.sa_mask);
- while ((sigaction(signum, &defSigAction, 0) < 0) && (errno == EINTR))
- ;
+ while ((sigaction(signum, &defSigAction, 0) < 0) && (errno == EINTR)) {
+ }
/* Unmask the signal. */
sigemptyset(&unblockSet);
sigaddset(&unblockSet, signum);
diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c
index 68c52185e..12670762d 100644
--- a/Source/kwsys/ProcessWin32.c
+++ b/Source/kwsys/ProcessWin32.c
@@ -31,9 +31,6 @@ a UNIX-style select system call.
#include <io.h> /* _unlink */
#include <stdio.h> /* sprintf */
#include <string.h> /* strlen, strdup */
-#ifdef __WATCOMC__
-# define _unlink unlink
-#endif
#ifndef _MAX_FNAME
# define _MAX_FNAME 4096
@@ -48,11 +45,6 @@ a UNIX-style select system call.
# pragma warning(disable : 4706)
#endif
-#if defined(__BORLANDC__)
-# pragma warn - 8004 /* assigned a value that is never used */
-# pragma warn - 8060 /* Assignment inside if() condition. */
-#endif
-
/* There are pipes for the process pipeline's stdout and stderr. */
#define KWSYSPE_PIPE_COUNT 2
#define KWSYSPE_PIPE_STDOUT 0
@@ -761,7 +753,7 @@ void kwsysProcess_SetPipeShared(kwsysProcess* cp, int pipe, int shared)
}
}
-void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe, HANDLE p[2])
+void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe, const HANDLE p[2])
{
HANDLE* pPipeNative = 0;
diff --git a/Source/kwsys/RegularExpression.cxx b/Source/kwsys/RegularExpression.cxx
index 5e6f8da50..4f74eba53 100644
--- a/Source/kwsys/RegularExpression.cxx
+++ b/Source/kwsys/RegularExpression.cxx
@@ -28,8 +28,8 @@
# include "RegularExpression.hxx.in"
#endif
-#include <stdio.h>
-#include <string.h>
+#include <cstdio>
+#include <cstring>
namespace KWSYS_NAMESPACE {
@@ -367,8 +367,7 @@ bool RegularExpression::compile(const char* exp)
// Allocate space.
//#ifndef _WIN32
- if (this->program != nullptr)
- delete[] this->program;
+ delete[] this->program;
//#endif
this->program = new char[comp.regsize];
this->progsize = static_cast<int>(comp.regsize);
diff --git a/Source/kwsys/RegularExpression.hxx.in b/Source/kwsys/RegularExpression.hxx.in
index d11db8828..2709cde5f 100644
--- a/Source/kwsys/RegularExpression.hxx.in
+++ b/Source/kwsys/RegularExpression.hxx.in
@@ -26,12 +26,6 @@
#include <string>
-/* Disable useless Borland warnings. KWSys tries not to force things
- on its includers, but there is no choice here. */
-#if defined(__BORLANDC__)
-# pragma warn - 8027 /* function not inlined. */
-#endif
-
namespace @KWSYS_NAMESPACE@ {
// Forward declaration
diff --git a/Source/kwsys/SharedForward.h.in b/Source/kwsys/SharedForward.h.in
index 5716cd4f1..091334b75 100644
--- a/Source/kwsys/SharedForward.h.in
+++ b/Source/kwsys/SharedForward.h.in
@@ -66,12 +66,6 @@
# endif
# endif
-# if defined(__BORLANDC__) && !defined(__cplusplus)
-/* Code has no effect; raised by winnt.h in C (not C++) when ignoring an
- unused parameter using "(param)" syntax (i.e. no cast to void). */
-# pragma warn - 8019
-# endif
-
/* Full path to the directory in which this executable is built. Do
not include a trailing slash. */
# if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD)
diff --git a/Source/kwsys/String.hxx.in b/Source/kwsys/String.hxx.in
index db1cf22a9..c36f4ce4a 100644
--- a/Source/kwsys/String.hxx.in
+++ b/Source/kwsys/String.hxx.in
@@ -52,14 +52,6 @@ public:
}
}; // End Class: String
-#if defined(__WATCOMC__)
-inline bool operator<(String const& l, String const& r)
-{
- return (static_cast<std::string const&>(l) <
- static_cast<std::string const&>(r));
-}
-#endif
-
} // namespace @KWSYS_NAMESPACE@
#endif
diff --git a/Source/kwsys/System.c b/Source/kwsys/System.c
index d43cc6fbb..dbfd2fd16 100644
--- a/Source/kwsys/System.c
+++ b/Source/kwsys/System.c
@@ -22,7 +22,7 @@ typedef ptrdiff_t kwsysSystem_ptrdiff_t;
typedef int kwsysSystem_ptrdiff_t;
#endif
-static int kwsysSystem__AppendByte(char* local, char** begin, char** end,
+static int kwsysSystem__AppendByte(const char* local, char** begin, char** end,
int* size, char c)
{
/* Allocate space for the character. */
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index 6ec6e48ff..ed1cdc0ab 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -64,9 +64,9 @@ typedef int siginfo_t;
#else
# include <sys/types.h>
-# include <errno.h> // extern int errno;
+# include <cerrno> // extern int errno;
+# include <csignal>
# include <fcntl.h>
-# include <signal.h>
# include <sys/resource.h> // getrlimit
# include <sys/time.h>
# include <sys/utsname.h> // int uname(struct utsname *buf);
@@ -132,7 +132,7 @@ typedef int siginfo_t;
# endif
# endif
# if defined(KWSYS_CXX_HAS_RLIMIT64)
-typedef struct rlimit64 ResourceLimitType;
+using ResourceLimitType = struct rlimit64;
# define GetResourceLimit getrlimit64
# else
typedef struct rlimit ResourceLimitType;
@@ -163,39 +163,11 @@ typedef struct rlimit ResourceLimitType;
# undef KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP
#endif
-#include <ctype.h> // int isdigit(int c);
+#include <cctype> // int isdigit(int c);
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <memory.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if defined(KWSYS_USE_LONG_LONG)
-# if defined(KWSYS_IOS_HAS_OSTREAM_LONG_LONG)
-# define iostreamLongLong(x) (x)
-# else
-# define iostreamLongLong(x) ((long)(x))
-# endif
-#elif defined(KWSYS_USE___INT64)
-# if defined(KWSYS_IOS_HAS_OSTREAM___INT64)
-# define iostreamLongLong(x) (x)
-# else
-# define iostreamLongLong(x) ((long)(x))
-# endif
-#else
-# error "No Long Long"
-#endif
-
-#if defined(KWSYS_CXX_HAS_ATOLL)
-# define atoLongLong atoll
-#else
-# if defined(KWSYS_CXX_HAS__ATOI64)
-# define atoLongLong _atoi64
-# elif defined(KWSYS_CXX_HAS_ATOL)
-# define atoLongLong atol
-# else
-# define atoLongLong atoi
-# endif
-#endif
#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(_WIN64) && \
!defined(__clang__)
@@ -204,15 +176,15 @@ typedef struct rlimit ResourceLimitType;
# define USE_ASM_INSTRUCTIONS 0
#endif
-#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__clang__)
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__clang__) && \
+ !defined(_M_ARM64)
# include <intrin.h>
# define USE_CPUID_INTRINSICS 1
#else
# define USE_CPUID_INTRINSICS 0
#endif
-#if USE_ASM_INSTRUCTIONS || USE_CPUID_INTRINSICS || \
- defined(KWSYS_CXX_HAS_BORLAND_ASM_CPUID)
+#if USE_ASM_INSTRUCTIONS || USE_CPUID_INTRINSICS
# define USE_CPUID 1
#else
# define USE_CPUID 0
@@ -272,21 +244,6 @@ static bool call_cpuid(int select, int result[4])
}
memcpy(result, tmp, sizeof(tmp));
-# elif defined(KWSYS_CXX_HAS_BORLAND_ASM_CPUID)
- unsigned int a, b, c, d;
- __asm {
- mov EAX, select;
- cpuid
- mov a, EAX;
- mov b, EBX;
- mov c, ECX;
- mov d, EDX;
- }
-
- result[0] = a;
- result[1] = b;
- result[2] = c;
- result[3] = d;
# endif
// The cpuid instruction succeeded.
@@ -303,34 +260,33 @@ T min(T a, T b)
}
extern "C" {
-typedef void (*SigAction)(int, siginfo_t*, void*);
+using SigAction = void (*)(int, siginfo_t*, void*);
}
// Define SystemInformationImplementation class
-typedef void (*DELAY_FUNC)(unsigned int uiMS);
+using DELAY_FUNC = void (*)(unsigned int);
class SystemInformationImplementation
{
public:
- typedef SystemInformation::LongLong LongLong;
SystemInformationImplementation();
- ~SystemInformationImplementation();
+ ~SystemInformationImplementation() = default;
- const char* GetVendorString();
+ const char* GetVendorString() const;
const char* GetVendorID();
- std::string GetTypeID();
- std::string GetFamilyID();
- std::string GetModelID();
- std::string GetModelName();
- std::string GetSteppingCode();
- const char* GetExtendedProcessorName();
- const char* GetProcessorSerialNumber();
- int GetProcessorCacheSize();
- unsigned int GetLogicalProcessorsPerPhysical();
- float GetProcessorClockFrequency();
- int GetProcessorAPICID();
- int GetProcessorCacheXSize(long int);
- bool DoesCPUSupportFeature(long int);
+ std::string GetTypeID() const;
+ std::string GetFamilyID() const;
+ std::string GetModelID() const;
+ std::string GetModelName() const;
+ std::string GetSteppingCode() const;
+ const char* GetExtendedProcessorName() const;
+ const char* GetProcessorSerialNumber() const;
+ int GetProcessorCacheSize() const;
+ unsigned int GetLogicalProcessorsPerPhysical() const;
+ float GetProcessorClockFrequency() const;
+ int GetProcessorAPICID() const;
+ int GetProcessorCacheXSize(long int) const;
+ bool DoesCPUSupportFeature(long int) const;
const char* GetOSName();
const char* GetHostname();
@@ -339,29 +295,29 @@ public:
const char* GetOSVersion();
const char* GetOSPlatform();
- bool Is64Bits();
+ bool Is64Bits() const;
- unsigned int GetNumberOfLogicalCPU(); // per physical cpu
- unsigned int GetNumberOfPhysicalCPU();
+ unsigned int GetNumberOfLogicalCPU() const; // per physical cpu
+ unsigned int GetNumberOfPhysicalCPU() const;
bool DoesCPUSupportCPUID();
// Retrieve memory information in MiB.
- size_t GetTotalVirtualMemory();
- size_t GetAvailableVirtualMemory();
- size_t GetTotalPhysicalMemory();
- size_t GetAvailablePhysicalMemory();
+ size_t GetTotalVirtualMemory() const;
+ size_t GetAvailableVirtualMemory() const;
+ size_t GetTotalPhysicalMemory() const;
+ size_t GetAvailablePhysicalMemory() const;
- LongLong GetProcessId();
+ long long GetProcessId();
// Retrieve memory information in KiB.
- LongLong GetHostMemoryTotal();
- LongLong GetHostMemoryAvailable(const char* envVarName);
- LongLong GetHostMemoryUsed();
+ long long GetHostMemoryTotal();
+ long long GetHostMemoryAvailable(const char* hostLimitEnvVarName);
+ long long GetHostMemoryUsed();
- LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName,
- const char* procLimitEnvVarName);
- LongLong GetProcMemoryUsed();
+ long long GetProcMemoryAvailable(const char* hostLimitEnvVarName,
+ const char* procLimitEnvVarName);
+ long long GetProcMemoryUsed();
double GetLoadAverage();
@@ -377,60 +333,103 @@ public:
void RunMemoryCheck();
public:
- typedef struct tagID
+ using ID = struct tagID
+
{
+
int Type;
+
int Family;
+
int Model;
+
int Revision;
+
int ExtendedFamily;
+
int ExtendedModel;
+
std::string ProcessorName;
+
std::string Vendor;
+
std::string SerialNumber;
+
std::string ModelName;
- } ID;
+ };
+
+ using CPUPowerManagement = struct tagCPUPowerManagement
- typedef struct tagCPUPowerManagement
{
+
bool HasVoltageID;
+
bool HasFrequencyID;
+
bool HasTempSenseDiode;
- } CPUPowerManagement;
+ };
+
+ using CPUExtendedFeatures = struct tagCPUExtendedFeatures
- typedef struct tagCPUExtendedFeatures
{
+
bool Has3DNow;
+
bool Has3DNowPlus;
+
bool SupportsMP;
+
bool HasMMXPlus;
+
bool HasSSEMMX;
+
unsigned int LogicalProcessorsPerPhysical;
+
int APIC_ID;
+
CPUPowerManagement PowerManagement;
- } CPUExtendedFeatures;
+ };
+
+ using CPUFeatures = struct CPUtagFeatures
- typedef struct CPUtagFeatures
{
+
bool HasFPU;
+
bool HasTSC;
+
bool HasMMX;
+
bool HasSSE;
+
bool HasSSEFP;
+
bool HasSSE2;
+
bool HasIA64;
+
bool HasAPIC;
+
bool HasCMOV;
+
bool HasMTRR;
+
bool HasACPI;
+
bool HasSerial;
+
bool HasThermal;
+
int CPUSpeed;
+
int L1CacheSize;
+
int L2CacheSize;
+
int L3CacheSize;
+
CPUExtendedFeatures ExtendedFeatures;
- } CPUFeatures;
+ };
enum Manufacturer
{
@@ -476,8 +475,9 @@ protected:
void CPUCountWindows(); // For windows
unsigned char GetAPICId(); // For windows
- bool IsSMTSupported();
- static LongLong GetCyclesDifference(DELAY_FUNC, unsigned int); // For windows
+ bool IsSMTSupported() const;
+ static long long GetCyclesDifference(DELAY_FUNC,
+ unsigned int); // For windows
// For Linux and Cygwin, /proc/cpuinfo formats are slightly different
bool RetreiveInformationFromCpuInfoFile();
@@ -768,42 +768,41 @@ std::string SystemInformation::GetMemoryDescription(
const char* hostLimitEnvVarName, const char* procLimitEnvVarName)
{
std::ostringstream oss;
- oss << "Host Total: " << iostreamLongLong(this->GetHostMemoryTotal())
+ oss << "Host Total: " << this->GetHostMemoryTotal()
<< " KiB, Host Available: "
- << iostreamLongLong(this->GetHostMemoryAvailable(hostLimitEnvVarName))
+ << this->GetHostMemoryAvailable(hostLimitEnvVarName)
<< " KiB, Process Available: "
- << iostreamLongLong(this->GetProcMemoryAvailable(hostLimitEnvVarName,
- procLimitEnvVarName))
+ << this->GetProcMemoryAvailable(hostLimitEnvVarName, procLimitEnvVarName)
<< " KiB";
return oss.str();
}
// host memory info in units of KiB.
-SystemInformation::LongLong SystemInformation::GetHostMemoryTotal()
+long long SystemInformation::GetHostMemoryTotal()
{
return this->Implementation->GetHostMemoryTotal();
}
-SystemInformation::LongLong SystemInformation::GetHostMemoryAvailable(
+long long SystemInformation::GetHostMemoryAvailable(
const char* hostLimitEnvVarName)
{
return this->Implementation->GetHostMemoryAvailable(hostLimitEnvVarName);
}
-SystemInformation::LongLong SystemInformation::GetHostMemoryUsed()
+long long SystemInformation::GetHostMemoryUsed()
{
return this->Implementation->GetHostMemoryUsed();
}
// process memory info in units of KiB.
-SystemInformation::LongLong SystemInformation::GetProcMemoryAvailable(
+long long SystemInformation::GetProcMemoryAvailable(
const char* hostLimitEnvVarName, const char* procLimitEnvVarName)
{
return this->Implementation->GetProcMemoryAvailable(hostLimitEnvVarName,
procLimitEnvVarName);
}
-SystemInformation::LongLong SystemInformation::GetProcMemoryUsed()
+long long SystemInformation::GetProcMemoryUsed()
{
return this->Implementation->GetProcMemoryUsed();
}
@@ -813,7 +812,7 @@ double SystemInformation::GetLoadAverage()
return this->Implementation->GetLoadAverage();
}
-SystemInformation::LongLong SystemInformation::GetProcessId()
+long long SystemInformation::GetProcessId()
{
return this->Implementation->GetProcessId();
}
@@ -885,7 +884,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines)
*pBuf = '\0';
pBuf += 1;
}
- lines.push_back(buf);
+ lines.emplace_back(buf);
++nRead;
}
if (ferror(file)) {
@@ -899,7 +898,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines)
int LoadLines(const char* fileName, std::vector<std::string>& lines)
{
FILE* file = fopen(fileName, "r");
- if (file == 0) {
+ if (file == nullptr) {
return 0;
}
int nRead = LoadLines(file, lines);
@@ -1322,9 +1321,9 @@ std::string SymbolProperties::GetFileName(const std::string& path) const
{
std::string file(path);
if (!this->ReportPath) {
- size_t at = file.rfind("/");
+ size_t at = file.rfind('/');
if (at != std::string::npos) {
- file = file.substr(at + 1);
+ file.erase(0, at + 1);
}
}
return file;
@@ -1464,10 +1463,6 @@ SystemInformationImplementation::SystemInformationImplementation()
this->OSIs64Bit = (sizeof(void*) == 8);
}
-SystemInformationImplementation::~SystemInformationImplementation()
-{
-}
-
void SystemInformationImplementation::RunCPUCheck()
{
#ifdef _WIN32
@@ -1564,7 +1559,7 @@ void SystemInformationImplementation::RunMemoryCheck()
}
/** Get the vendor string */
-const char* SystemInformationImplementation::GetVendorString()
+const char* SystemInformationImplementation::GetVendorString() const
{
return this->ChipID.Vendor.c_str();
}
@@ -1760,7 +1755,7 @@ const char* SystemInformationImplementation::GetVendorID()
}
/** Return the type ID of the CPU */
-std::string SystemInformationImplementation::GetTypeID()
+std::string SystemInformationImplementation::GetTypeID() const
{
std::ostringstream str;
str << this->ChipID.Type;
@@ -1768,7 +1763,7 @@ std::string SystemInformationImplementation::GetTypeID()
}
/** Return the family of the CPU present */
-std::string SystemInformationImplementation::GetFamilyID()
+std::string SystemInformationImplementation::GetFamilyID() const
{
std::ostringstream str;
str << this->ChipID.Family;
@@ -1776,7 +1771,7 @@ std::string SystemInformationImplementation::GetFamilyID()
}
// Return the model of CPU present */
-std::string SystemInformationImplementation::GetModelID()
+std::string SystemInformationImplementation::GetModelID() const
{
std::ostringstream str;
str << this->ChipID.Model;
@@ -1784,13 +1779,13 @@ std::string SystemInformationImplementation::GetModelID()
}
// Return the model name of CPU present */
-std::string SystemInformationImplementation::GetModelName()
+std::string SystemInformationImplementation::GetModelName() const
{
return this->ChipID.ModelName;
}
/** Return the stepping code of the CPU present. */
-std::string SystemInformationImplementation::GetSteppingCode()
+std::string SystemInformationImplementation::GetSteppingCode() const
{
std::ostringstream str;
str << this->ChipID.Revision;
@@ -1798,44 +1793,46 @@ std::string SystemInformationImplementation::GetSteppingCode()
}
/** Return the stepping code of the CPU present. */
-const char* SystemInformationImplementation::GetExtendedProcessorName()
+const char* SystemInformationImplementation::GetExtendedProcessorName() const
{
return this->ChipID.ProcessorName.c_str();
}
/** Return the serial number of the processor
* in hexadecimal: xxxx-xxxx-xxxx-xxxx-xxxx-xxxx. */
-const char* SystemInformationImplementation::GetProcessorSerialNumber()
+const char* SystemInformationImplementation::GetProcessorSerialNumber() const
{
return this->ChipID.SerialNumber.c_str();
}
/** Return the logical processors per physical */
unsigned int SystemInformationImplementation::GetLogicalProcessorsPerPhysical()
+ const
{
return this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical;
}
/** Return the processor clock frequency. */
-float SystemInformationImplementation::GetProcessorClockFrequency()
+float SystemInformationImplementation::GetProcessorClockFrequency() const
{
return this->CPUSpeedInMHz;
}
/** Return the APIC ID. */
-int SystemInformationImplementation::GetProcessorAPICID()
+int SystemInformationImplementation::GetProcessorAPICID() const
{
return this->Features.ExtendedFeatures.APIC_ID;
}
/** Return the L1 cache size. */
-int SystemInformationImplementation::GetProcessorCacheSize()
+int SystemInformationImplementation::GetProcessorCacheSize() const
{
return this->Features.L1CacheSize;
}
/** Return the chosen cache size. */
-int SystemInformationImplementation::GetProcessorCacheXSize(long int dwCacheID)
+int SystemInformationImplementation::GetProcessorCacheXSize(
+ long int dwCacheID) const
{
switch (dwCacheID) {
case SystemInformation::CPU_FEATURE_L1CACHE:
@@ -1848,7 +1845,8 @@ int SystemInformationImplementation::GetProcessorCacheXSize(long int dwCacheID)
return -1;
}
-bool SystemInformationImplementation::DoesCPUSupportFeature(long int dwFeature)
+bool SystemInformationImplementation::DoesCPUSupportFeature(
+ long int dwFeature) const
{
bool bHasFeature = false;
@@ -2128,7 +2126,7 @@ void SystemInformationImplementation::FindManufacturer(
this->ChipManufacturer = HP; // Hewlett-Packard
else if (this->ChipID.Vendor == "Motorola")
this->ChipManufacturer = Motorola; // Motorola Microelectronics
- else if (family.substr(0, 7) == "PA-RISC")
+ else if (family.compare(0, 7, "PA-RISC") == 0)
this->ChipManufacturer = HP; // Hewlett-Packard
else
this->ChipManufacturer = UnknownManufacturer; // Unknown manufacturer
@@ -2843,7 +2841,7 @@ static void SystemInformationStripLeadingSpace(std::string& str)
// post-process the name.
std::string::size_type pos = str.find_first_not_of(" ");
if (pos != std::string::npos) {
- str = str.substr(pos);
+ str.erase(0, pos);
}
}
#endif
@@ -3344,8 +3342,8 @@ std::string SystemInformationImplementation::ExtractValueFromCpuInfoFile(
size_t pos = buffer.find(word, init);
if (pos != std::string::npos) {
this->CurrentPositionInFile = pos;
- pos = buffer.find(":", pos);
- size_t pos2 = buffer.find("\n", pos);
+ pos = buffer.find(':', pos);
+ size_t pos2 = buffer.find('\n', pos);
if (pos != std::string::npos && pos2 != std::string::npos) {
// It may happen that the beginning matches, but this is still not the
// requested key.
@@ -3358,7 +3356,9 @@ std::string SystemInformationImplementation::ExtractValueFromCpuInfoFile(
return this->ExtractValueFromCpuInfoFile(buffer, word, pos2);
}
}
- return buffer.substr(pos + 2, pos2 - pos - 2);
+ buffer.erase(0, pos + 2);
+ buffer.resize(pos2 - pos - 2);
+ return buffer;
}
}
this->CurrentPositionInFile = std::string::npos;
@@ -3409,7 +3409,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
// We want to record the total number of cores in this->NumberOfPhysicalCPU
// (checking only the first proc)
std::string Cores = this->ExtractValueFromCpuInfoFile(buffer, "cpu cores");
- unsigned int NumberOfCoresPerSocket = (unsigned int)atoi(Cores.c_str());
+ auto NumberOfCoresPerSocket = (unsigned int)atoi(Cores.c_str());
NumberOfCoresPerSocket = std::max(NumberOfCoresPerSocket, 1u);
this->NumberOfPhysicalCPU =
NumberOfCoresPerSocket * (unsigned int)NumberOfSockets;
@@ -3441,7 +3441,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
// Linux Sparc: CPU speed is in Hz and encoded in hexadecimal
CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer, "Cpu0ClkTck");
this->CPUSpeedInMHz =
- static_cast<float>(strtoull(CPUSpeed.c_str(), 0, 16)) / 1000000.0f;
+ static_cast<float>(strtoull(CPUSpeed.c_str(), nullptr, 16)) / 1000000.0f;
}
#endif
@@ -3502,13 +3502,12 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
cachename.push_back("D-cache"); // e.g. PA-RISC
this->Features.L1CacheSize = 0;
- for (size_t index = 0; index < cachename.size(); index++) {
- std::string cacheSize =
- this->ExtractValueFromCpuInfoFile(buffer, cachename[index]);
+ for (auto& index : cachename) {
+ std::string cacheSize = this->ExtractValueFromCpuInfoFile(buffer, index);
if (!cacheSize.empty()) {
pos = cacheSize.find(" KB");
if (pos != std::string::npos) {
- cacheSize = cacheSize.substr(0, pos);
+ cacheSize.resize(pos);
}
this->Features.L1CacheSize += atoi(cacheSize.c_str());
}
@@ -3584,8 +3583,7 @@ bool SystemInformationImplementation::QueryProcessor()
/**
Get total system RAM in units of KiB.
*/
-SystemInformation::LongLong
-SystemInformationImplementation::GetHostMemoryTotal()
+long long SystemInformationImplementation::GetHostMemoryTotal()
{
#if defined(_WIN32)
# if defined(_MSC_VER) && _MSC_VER < 1300
@@ -3600,7 +3598,7 @@ SystemInformationImplementation::GetHostMemoryTotal()
return statex.ullTotalPhys / 1024;
# endif
#elif defined(__linux)
- SystemInformation::LongLong memTotal = 0;
+ long long memTotal = 0;
int ierr = GetFieldFromFile("/proc/meminfo", "MemTotal:", memTotal);
if (ierr) {
return -1;
@@ -3623,11 +3621,10 @@ SystemInformationImplementation::GetHostMemoryTotal()
Get total system RAM in units of KiB. This may differ from the
host total if a host-wide resource limit is applied.
*/
-SystemInformation::LongLong
-SystemInformationImplementation::GetHostMemoryAvailable(
+long long SystemInformationImplementation::GetHostMemoryAvailable(
const char* hostLimitEnvVarName)
{
- SystemInformation::LongLong memTotal = this->GetHostMemoryTotal();
+ long long memTotal = this->GetHostMemoryTotal();
// the following mechanism is provided for systems that
// apply resource limits across groups of processes.
@@ -3638,8 +3635,7 @@ SystemInformationImplementation::GetHostMemoryAvailable(
if (hostLimitEnvVarName) {
const char* hostLimitEnvVarValue = getenv(hostLimitEnvVarName);
if (hostLimitEnvVarValue) {
- SystemInformation::LongLong hostLimit =
- atoLongLong(hostLimitEnvVarValue);
+ long long hostLimit = std::atoll(hostLimitEnvVarValue);
if (hostLimit > 0) {
memTotal = min(hostLimit, memTotal);
}
@@ -3653,20 +3649,17 @@ SystemInformationImplementation::GetHostMemoryAvailable(
Get total system RAM in units of KiB. This may differ from the
host total if a per-process resource limit is applied.
*/
-SystemInformation::LongLong
-SystemInformationImplementation::GetProcMemoryAvailable(
+long long SystemInformationImplementation::GetProcMemoryAvailable(
const char* hostLimitEnvVarName, const char* procLimitEnvVarName)
{
- SystemInformation::LongLong memAvail =
- this->GetHostMemoryAvailable(hostLimitEnvVarName);
+ long long memAvail = this->GetHostMemoryAvailable(hostLimitEnvVarName);
// the following mechanism is provide for systems where rlimits
// are not employed. Units are in KiB.
if (procLimitEnvVarName) {
const char* procLimitEnvVarValue = getenv(procLimitEnvVarName);
if (procLimitEnvVarValue) {
- SystemInformation::LongLong procLimit =
- atoLongLong(procLimitEnvVarValue);
+ long long procLimit = std::atoll(procLimitEnvVarValue);
if (procLimit > 0) {
memAvail = min(procLimit, memAvail);
}
@@ -3678,28 +3671,24 @@ SystemInformationImplementation::GetProcMemoryAvailable(
ResourceLimitType rlim;
ierr = GetResourceLimit(RLIMIT_DATA, &rlim);
if ((ierr == 0) && (rlim.rlim_cur != RLIM_INFINITY)) {
- memAvail =
- min((SystemInformation::LongLong)rlim.rlim_cur / 1024, memAvail);
+ memAvail = min((long long)rlim.rlim_cur / 1024, memAvail);
}
ierr = GetResourceLimit(RLIMIT_AS, &rlim);
if ((ierr == 0) && (rlim.rlim_cur != RLIM_INFINITY)) {
- memAvail =
- min((SystemInformation::LongLong)rlim.rlim_cur / 1024, memAvail);
+ memAvail = min((long long)rlim.rlim_cur / 1024, memAvail);
}
#elif defined(__APPLE__)
struct rlimit rlim;
int ierr;
ierr = getrlimit(RLIMIT_DATA, &rlim);
if ((ierr == 0) && (rlim.rlim_cur != RLIM_INFINITY)) {
- memAvail =
- min((SystemInformation::LongLong)rlim.rlim_cur / 1024, memAvail);
+ memAvail = min((long long)rlim.rlim_cur / 1024, memAvail);
}
ierr = getrlimit(RLIMIT_RSS, &rlim);
if ((ierr == 0) && (rlim.rlim_cur != RLIM_INFINITY)) {
- memAvail =
- min((SystemInformation::LongLong)rlim.rlim_cur / 1024, memAvail);
+ memAvail = min((long long)rlim.rlim_cur / 1024, memAvail);
}
#endif
@@ -3709,8 +3698,7 @@ SystemInformationImplementation::GetProcMemoryAvailable(
/**
Get RAM used by all processes in the host, in units of KiB.
*/
-SystemInformation::LongLong
-SystemInformationImplementation::GetHostMemoryUsed()
+long long SystemInformationImplementation::GetHostMemoryUsed()
{
#if defined(_WIN32)
# if defined(_MSC_VER) && _MSC_VER < 1300
@@ -3727,39 +3715,38 @@ SystemInformationImplementation::GetHostMemoryUsed()
#elif defined(__linux)
// First try to use MemAvailable, but it only works on newer kernels
const char* names2[3] = { "MemTotal:", "MemAvailable:", nullptr };
- SystemInformation::LongLong values2[2] = { SystemInformation::LongLong(0) };
+ long long values2[2] = { 0 };
int ierr = GetFieldsFromFile("/proc/meminfo", names2, values2);
if (ierr) {
const char* names4[5] = { "MemTotal:", "MemFree:", "Buffers:", "Cached:",
nullptr };
- SystemInformation::LongLong values4[4] = { SystemInformation::LongLong(
- 0) };
+ long long values4[4] = { 0 };
ierr = GetFieldsFromFile("/proc/meminfo", names4, values4);
if (ierr) {
return ierr;
}
- SystemInformation::LongLong& memTotal = values4[0];
- SystemInformation::LongLong& memFree = values4[1];
- SystemInformation::LongLong& memBuffers = values4[2];
- SystemInformation::LongLong& memCached = values4[3];
+ long long& memTotal = values4[0];
+ long long& memFree = values4[1];
+ long long& memBuffers = values4[2];
+ long long& memCached = values4[3];
return memTotal - memFree - memBuffers - memCached;
}
- SystemInformation::LongLong& memTotal = values2[0];
- SystemInformation::LongLong& memAvail = values2[1];
+ long long& memTotal = values2[0];
+ long long& memAvail = values2[1];
return memTotal - memAvail;
#elif defined(__APPLE__)
- SystemInformation::LongLong psz = getpagesize();
+ long long psz = getpagesize();
if (psz < 1) {
return -1;
}
const char* names[3] = { "Pages wired down:", "Pages active:", nullptr };
- SystemInformation::LongLong values[2] = { SystemInformation::LongLong(0) };
+ long long values[2] = { 0 };
int ierr = GetFieldsFromCommand("vm_stat", names, values);
if (ierr) {
return -1;
}
- SystemInformation::LongLong& vmWired = values[0];
- SystemInformation::LongLong& vmActive = values[1];
+ long long& vmWired = values[0];
+ long long& vmActive = values[1];
return ((vmActive + vmWired) * psz) / 1024;
#else
return 0;
@@ -3770,8 +3757,7 @@ SystemInformationImplementation::GetHostMemoryUsed()
Get system RAM used by the process associated with the given
process id in units of KiB.
*/
-SystemInformation::LongLong
-SystemInformationImplementation::GetProcMemoryUsed()
+long long SystemInformationImplementation::GetProcMemoryUsed()
{
#if defined(_WIN32) && defined(KWSYS_SYS_HAS_PSAPI)
long pid = GetCurrentProcessId();
@@ -3788,14 +3774,14 @@ SystemInformationImplementation::GetProcMemoryUsed()
}
return pmc.WorkingSetSize / 1024;
#elif defined(__linux)
- SystemInformation::LongLong memUsed = 0;
+ long long memUsed = 0;
int ierr = GetFieldFromFile("/proc/self/status", "VmRSS:", memUsed);
if (ierr) {
return -1;
}
return memUsed;
#elif defined(__APPLE__)
- SystemInformation::LongLong memUsed = 0;
+ long long memUsed = 0;
pid_t pid = getpid();
std::ostringstream oss;
oss << "ps -o rss= -p " << pid;
@@ -3859,7 +3845,7 @@ double SystemInformationImplementation::GetLoadAverage()
/**
Get the process id of the running process.
*/
-SystemInformation::LongLong SystemInformationImplementation::GetProcessId()
+long long SystemInformationImplementation::GetProcessId()
{
#if defined(_WIN32)
return GetCurrentProcessId();
@@ -3893,7 +3879,7 @@ std::string SystemInformationImplementation::GetProgramStack(int firstFrame,
int wholePath)
{
std::ostringstream oss;
- std::string programStack = "";
+ std::string programStack;
#ifdef KWSYS_SYSTEMINFORMATION_HAS_DBGHELP
(void)wholePath;
@@ -4249,39 +4235,44 @@ bool SystemInformationImplementation::QueryMemory()
}
/** */
-size_t SystemInformationImplementation::GetTotalVirtualMemory()
+size_t SystemInformationImplementation::GetTotalVirtualMemory() const
{
return this->TotalVirtualMemory;
}
/** */
-size_t SystemInformationImplementation::GetAvailableVirtualMemory()
+size_t SystemInformationImplementation::GetAvailableVirtualMemory() const
{
return this->AvailableVirtualMemory;
}
-size_t SystemInformationImplementation::GetTotalPhysicalMemory()
+size_t SystemInformationImplementation::GetTotalPhysicalMemory() const
{
return this->TotalPhysicalMemory;
}
/** */
-size_t SystemInformationImplementation::GetAvailablePhysicalMemory()
+size_t SystemInformationImplementation::GetAvailablePhysicalMemory() const
{
return this->AvailablePhysicalMemory;
}
/** Get Cycle differences */
-SystemInformation::LongLong
-SystemInformationImplementation::GetCyclesDifference(DELAY_FUNC DelayFunction,
- unsigned int uiParameter)
+long long SystemInformationImplementation::GetCyclesDifference(
+ DELAY_FUNC DelayFunction, unsigned int uiParameter)
{
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
unsigned __int64 stamp1, stamp2;
+# ifdef _M_ARM64
+ stamp1 = _ReadStatusReg(ARM64_PMCCNTR_EL0);
+ DelayFunction(uiParameter);
+ stamp2 = _ReadStatusReg(ARM64_PMCCNTR_EL0);
+# else
stamp1 = __rdtsc();
DelayFunction(uiParameter);
stamp2 = __rdtsc();
+# endif
return stamp2 - stamp1;
#elif USE_ASM_INSTRUCTIONS
@@ -4350,7 +4341,7 @@ void SystemInformationImplementation::DelayOverhead(unsigned int uiMS)
}
/** Works only for windows */
-bool SystemInformationImplementation::IsSMTSupported()
+bool SystemInformationImplementation::IsSMTSupported() const
{
return this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical > 1;
}
@@ -4399,12 +4390,12 @@ void SystemInformationImplementation::CPUCountWindows()
DWORD Length = 0;
DWORD rc = pGetLogicalProcessorInformation(nullptr, &Length);
assert(FALSE == rc);
- (void)rc; // Silence unused variable warning in Borland C++ 5.81
+ (void)rc; // Silence unused variable warning
assert(GetLastError() == ERROR_INSUFFICIENT_BUFFER);
ProcInfo.resize(Length / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION));
rc = pGetLogicalProcessorInformation(&ProcInfo[0], &Length);
assert(rc != FALSE);
- (void)rc; // Silence unused variable warning in Borland C++ 5.81
+ (void)rc; // Silence unused variable warning
}
typedef std::vector<SYSTEM_LOGICAL_PROCESSOR_INFORMATION>::iterator
@@ -4432,13 +4423,13 @@ void SystemInformationImplementation::CPUCountWindows()
}
/** Return the number of logical CPUs on the system */
-unsigned int SystemInformationImplementation::GetNumberOfLogicalCPU()
+unsigned int SystemInformationImplementation::GetNumberOfLogicalCPU() const
{
return this->NumberOfLogicalCPU;
}
/** Return the number of physical CPUs on the system */
-unsigned int SystemInformationImplementation::GetNumberOfPhysicalCPU()
+unsigned int SystemInformationImplementation::GetNumberOfPhysicalCPU() const
{
return this->NumberOfPhysicalCPU;
}
@@ -4638,7 +4629,7 @@ std::string SystemInformationImplementation::ExtractValueFromSysCtl(
size_t pos = this->SysCtlBuffer.find(word);
if (pos != std::string::npos) {
pos = this->SysCtlBuffer.find(": ", pos);
- size_t pos2 = this->SysCtlBuffer.find("\n", pos);
+ size_t pos2 = this->SysCtlBuffer.find('\n', pos);
if (pos != std::string::npos && pos2 != std::string::npos) {
return this->SysCtlBuffer.substr(pos + 2, pos2 - pos - 2);
}
@@ -4733,14 +4724,15 @@ std::string SystemInformationImplementation::ParseValueFromKStat(
}
pos = command.find(' ', pos + 1);
}
- args_string.push_back(command.substr(start + 1, command.size() - start - 1));
+ command.erase(0, start + 1);
+ args_string.push_back(command);
std::vector<const char*> args;
args.reserve(3 + args_string.size());
args.push_back("kstat");
args.push_back("-p");
- for (size_t i = 0; i < args_string.size(); ++i) {
- args.push_back(args_string[i].c_str());
+ for (auto& i : args_string) {
+ args.push_back(i.c_str());
}
args.push_back(nullptr);
@@ -4922,7 +4914,9 @@ bool SystemInformationImplementation::QueryQNXMemory()
while (buffer[pos] == ' ')
pos++;
- this->TotalPhysicalMemory = atoi(buffer.substr(pos, pos2 - pos).c_str());
+ buffer.erase(0, pos);
+ buffer.resize(pos2);
+ this->TotalPhysicalMemory = atoi(buffer.c_str());
return true;
#endif
return false;
@@ -5447,19 +5441,19 @@ void SystemInformationImplementation::TrimNewline(std::string& output)
{
// remove \r
std::string::size_type pos = 0;
- while ((pos = output.find("\r", pos)) != std::string::npos) {
+ while ((pos = output.find('\r', pos)) != std::string::npos) {
output.erase(pos);
}
// remove \n
pos = 0;
- while ((pos = output.find("\n", pos)) != std::string::npos) {
+ while ((pos = output.find('\n', pos)) != std::string::npos) {
output.erase(pos);
}
}
/** Return true if the machine is 64 bits */
-bool SystemInformationImplementation::Is64Bits()
+bool SystemInformationImplementation::Is64Bits() const
{
return this->OSIs64Bit;
}
diff --git a/Source/kwsys/SystemInformation.hxx.in b/Source/kwsys/SystemInformation.hxx.in
index fc42e9dc7..c8efd51d0 100644
--- a/Source/kwsys/SystemInformation.hxx.in
+++ b/Source/kwsys/SystemInformation.hxx.in
@@ -15,13 +15,6 @@ class SystemInformationImplementation;
class @KWSYS_NAMESPACE@_EXPORT SystemInformation
{
-#if @KWSYS_USE_LONG_LONG@
- typedef long long LongLong;
-#elif @KWSYS_USE___INT64@
- typedef __int64 LongLong;
-#else
-# error "No Long Long"
-#endif
friend class SystemInformationImplementation;
SystemInformationImplementation* Implementation;
@@ -104,7 +97,7 @@ public:
bool DoesCPUSupportCPUID();
// Retrieve id of the current running process
- LongLong GetProcessId();
+ long long GetProcessId();
// Retrieve memory information in MiB.
size_t GetTotalVirtualMemory();
@@ -120,7 +113,7 @@ public:
// Retrieve amount of physical memory installed on the system in KiB
// units.
- LongLong GetHostMemoryTotal();
+ long long GetHostMemoryTotal();
// Get total system RAM in units of KiB available colectivley to all
// processes in a process group. An example of a process group
@@ -128,7 +121,7 @@ public:
// parallel. The amount of memory reported may differ from the host
// total if a host wide resource limit is applied. Such reource limits
// are reported to us via an application specified environment variable.
- LongLong GetHostMemoryAvailable(const char* hostLimitEnvVarName = nullptr);
+ long long GetHostMemoryAvailable(const char* hostLimitEnvVarName = nullptr);
// Get total system RAM in units of KiB available to this process.
// This may differ from the host available if a per-process resource
@@ -136,14 +129,14 @@ public:
// system via rlimit API. Resource limits that are not imposed via
// rlimit API may be reported to us via an application specified
// environment variable.
- LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName = nullptr,
- const char* procLimitEnvVarName = nullptr);
+ long long GetProcMemoryAvailable(const char* hostLimitEnvVarName = nullptr,
+ const char* procLimitEnvVarName = nullptr);
// Get the system RAM used by all processes on the host, in units of KiB.
- LongLong GetHostMemoryUsed();
+ long long GetHostMemoryUsed();
// Get system RAM used by this process id in units of KiB.
- LongLong GetProcMemoryUsed();
+ long long GetProcMemoryUsed();
// Return the load average of the machine or -0.0 if it cannot
// be determined.
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index d27081b8c..25705ea28 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -6,9 +6,7 @@
# define _XOPEN_SOURCE_EXTENDED
#endif
-#if defined(_WIN32) && \
- (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || \
- defined(__MINGW32__))
+#if defined(_WIN32) && (defined(_MSC_VER) || defined(__MINGW32__))
# define KWSYS_WINDOWS_DIRS
#else
# if defined(__SUNPRO_CC)
@@ -24,6 +22,7 @@
#include KWSYS_HEADER(Encoding.h)
#include KWSYS_HEADER(Encoding.hxx)
+#include <algorithm>
#include <fstream>
#include <iostream>
#include <set>
@@ -49,27 +48,27 @@
# pragma set woff 1375 /* base class destructor not virtual */
#endif
-#include <ctype.h>
-#include <errno.h>
+#include <cctype>
+#include <cerrno>
#ifdef __QNX__
# include <malloc.h> /* for malloc/free on QNX */
#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
#if defined(_WIN32) && !defined(_MSC_VER) && defined(__GNUC__)
# include <strings.h> /* for strcasecmp */
#endif
#ifdef _MSC_VER
-# define umask _umask // Note this is still umask on Borland
+# define umask _umask
#endif
// support for realpath call
#ifndef _WIN32
-# include <limits.h>
+# include <climits>
# include <pwd.h>
# include <sys/ioctl.h>
# include <sys/time.h>
@@ -80,7 +79,7 @@
# include <sys/param.h>
# include <termios.h>
# endif
-# include <signal.h> /* sigprocmask */
+# include <csignal> /* sigprocmask */
#endif
#ifdef __linux
@@ -123,9 +122,9 @@ extern char** environ;
#define VTK_URL_PROTOCOL_REGEX "([a-zA-Z0-9]*)://(.*)"
#define VTK_URL_REGEX \
- "([a-zA-Z0-9]*)://(([A-Za-z0-9]+)(:([^:@]+))?@)?([^:@/]+)(:([0-9]+))?/" \
+ "([a-zA-Z0-9]*)://(([A-Za-z0-9]+)(:([^:@]+))?@)?([^:@/]*)(:([0-9]+))?/" \
"(.+)?"
-
+#define VTK_URL_BYTE_REGEX "%[0-9a-fA-F][0-9a-fA-F]"
#ifdef _MSC_VER
# include <sys/utime.h>
#else
@@ -153,9 +152,7 @@ public:
}
#endif
-#if defined(_WIN32) && \
- (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || \
- defined(__MINGW32__))
+#if defined(_WIN32) && (defined(_MSC_VER) || defined(__MINGW32__))
# include <direct.h>
# include <io.h>
# define _unlink unlink
@@ -169,13 +166,6 @@ public:
#else
# define KWSYS_SYSTEMTOOLS_MAXPATH 16384
#endif
-#if defined(__WATCOMC__)
-# include <direct.h>
-# define _mkdir mkdir
-# define _rmdir rmdir
-# define _getcwd getcwd
-# define _chdir chdir
-#endif
#if defined(__BEOS__) && !defined(__ZETA__)
# include <be/kernel/OS.h>
@@ -221,11 +211,17 @@ static time_t windows_filetime_to_posix_time(const FILETIME& ft)
#ifdef KWSYS_WINDOWS_DIRS
# include <wctype.h>
+# ifdef _MSC_VER
+typedef KWSYS_NAMESPACE::SystemTools::mode_t mode_t;
+# endif
-inline int Mkdir(const std::string& dir)
+inline int Mkdir(const std::string& dir, const mode_t* mode)
{
- return _wmkdir(
- KWSYS_NAMESPACE::Encoding::ToWindowsExtendedPath(dir).c_str());
+ int ret =
+ _wmkdir(KWSYS_NAMESPACE::Encoding::ToWindowsExtendedPath(dir).c_str());
+ if (ret == 0 && mode)
+ KWSYS_NAMESPACE::SystemTools::SetPermissions(dir, *mode);
+ return ret;
}
inline int Rmdir(const std::string& dir)
{
@@ -252,11 +248,7 @@ inline const char* Getcwd(char* buf, unsigned int len)
}
inline int Chdir(const std::string& dir)
{
-# if defined(__BORLANDC__)
- return chdir(dir.c_str());
-# else
return _wchdir(KWSYS_NAMESPACE::Encoding::ToWide(dir).c_str());
-# endif
}
inline void Realpath(const std::string& path, std::string& resolved_path,
std::string* errorMessage = 0)
@@ -295,9 +287,9 @@ inline void Realpath(const std::string& path, std::string& resolved_path,
# include <fcntl.h>
# include <unistd.h>
-inline int Mkdir(const std::string& dir)
+inline int Mkdir(const std::string& dir, const mode_t* mode)
{
- return mkdir(dir.c_str(), 00777);
+ return mkdir(dir.c_str(), mode ? *mode : 00777);
}
inline int Rmdir(const std::string& dir)
{
@@ -350,7 +342,7 @@ extern int putenv(char* __string) __THROW;
namespace KWSYS_NAMESPACE {
-double SystemTools::GetTime(void)
+double SystemTools::GetTime()
{
#if defined(_WIN32) && !defined(__CYGWIN__)
FILETIME ft;
@@ -368,7 +360,7 @@ double SystemTools::GetTime(void)
#if defined(_WIN32)
typedef wchar_t envchar;
#else
-typedef char envchar;
+using envchar = char;
#endif
/* Order by environment key only (VAR from VAR=VALUE). */
@@ -421,7 +413,7 @@ public:
const envchar* Release(const envchar* env)
{
const envchar* old = nullptr;
- iterator i = this->find(env);
+ auto i = this->find(env);
if (i != this->end()) {
old = *i;
this->erase(i);
@@ -452,7 +444,7 @@ struct SystemToolsPathCaseCmp
class SystemToolsStatic
{
public:
- typedef std::map<std::string, std::string> StringMap;
+ using StringMap = std::map<std::string, std::string>;
#if KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP
/**
* Path translation table from dir to refdir
@@ -488,10 +480,13 @@ public:
*/
static std::string FindName(
const std::string& name,
- const std::vector<std::string>& path = std::vector<std::string>(),
+ const std::vector<std::string>& userPaths = std::vector<std::string>(),
bool no_system_path = false);
};
+// Do NOT initialize. Default initialization to zero is necessary.
+static SystemToolsStatic* SystemToolsStatics;
+
#ifdef _WIN32
std::string SystemToolsStatic::GetCasePathName(std::string const& pathIn)
{
@@ -566,7 +561,7 @@ std::string SystemToolsStatic::GetActualCaseForPathCached(std::string const& p)
{
// Check to see if actual case has already been called
// for this path, and the result is stored in the PathCaseMap
- auto& pcm = SystemTools::Statics->PathCaseMap;
+ auto& pcm = SystemToolsStatics->PathCaseMap;
{
auto itr = pcm.find(p);
if (itr != pcm.end()) {
@@ -613,8 +608,7 @@ void SystemTools::GetPath(std::vector<std::string>& path, const char* env)
done = true;
}
}
- for (std::vector<std::string>::iterator i = path.begin() + old_size;
- i != path.end(); ++i) {
+ for (auto i = path.begin() + old_size; i != path.end(); ++i) {
SystemTools::ConvertToUnixSlashes(*i);
}
}
@@ -624,7 +618,7 @@ const char* SystemToolsStatic::GetEnvBuffered(const char* key)
{
std::string env;
if (SystemTools::GetEnv(key, env)) {
- std::string& menv = SystemTools::Statics->EnvMap[key];
+ std::string& menv = SystemToolsStatics->EnvMap[key];
if (menv != env) {
menv = std::move(env);
}
@@ -884,8 +878,12 @@ const char* SystemTools::GetExecutableExtension()
FILE* SystemTools::Fopen(const std::string& file, const char* mode)
{
#ifdef _WIN32
+ // Remove any 'e', which is supported on UNIX, but not Windows.
+ std::wstring trimmedMode = Encoding::ToWide(mode);
+ trimmedMode.erase(std::remove(trimmedMode.begin(), trimmedMode.end(), L'e'),
+ trimmedMode.end());
return _wfopen(Encoding::ToWindowsExtendedPath(file).c_str(),
- Encoding::ToWide(mode).c_str());
+ trimmedMode.c_str());
#else
return fopen(file.c_str(), mode);
#endif
@@ -913,29 +911,22 @@ bool SystemTools::MakeDirectory(const std::string& path, const mode_t* mode)
std::string::size_type pos = 0;
std::string topdir;
while ((pos = dir.find('/', pos)) != std::string::npos) {
- topdir = dir.substr(0, pos);
+ // all underlying functions use C strings, so temporarily
+ // end the string here
+ dir[pos] = '\0';
- if (Mkdir(topdir) == 0 && mode != nullptr) {
- SystemTools::SetPermissions(topdir, *mode);
- }
+ Mkdir(dir, mode);
+ dir[pos] = '/';
++pos;
}
topdir = dir;
- if (Mkdir(topdir) != 0) {
- // There is a bug in the Borland Run time library which makes MKDIR
- // return EACCES when it should return EEXISTS
+ if (Mkdir(topdir, mode) != 0) {
// if it is some other error besides directory exists
// then return false
- if ((errno != EEXIST)
-#ifdef __BORLANDC__
- && (errno != EACCES)
-#endif
- ) {
+ if (errno != EEXIST) {
return false;
}
- } else if (mode != nullptr) {
- SystemTools::SetPermissions(topdir, *mode);
}
return true;
@@ -1011,38 +1002,40 @@ void SystemToolsStatic::ReplaceString(std::string& source, const char* replace,
# define KWSYS_ST_KEY_WOW64_64KEY 0x0100
# endif
-static bool SystemToolsParseRegistryKey(const std::string& key,
- HKEY& primaryKey, std::string& second,
- std::string& valuename)
+static bool hasPrefix(const std::string& s, const char* pattern,
+ std::string::size_type spos)
{
- std::string primary = key;
+ size_t plen = strlen(pattern);
+ if (spos != plen)
+ return false;
+ return s.compare(0, plen, pattern) == 0;
+}
- size_t start = primary.find('\\');
+static bool SystemToolsParseRegistryKey(const std::string& key,
+ HKEY& primaryKey, std::wstring& second,
+ std::string* valuename)
+{
+ size_t start = key.find('\\');
if (start == std::string::npos) {
return false;
}
- size_t valuenamepos = primary.find(';');
- if (valuenamepos != std::string::npos) {
- valuename = primary.substr(valuenamepos + 1);
+ size_t valuenamepos = key.find(';');
+ if (valuenamepos != std::string::npos && valuename) {
+ *valuename = key.substr(valuenamepos + 1);
}
- second = primary.substr(start + 1, valuenamepos - start - 1);
- primary = primary.substr(0, start);
+ second = Encoding::ToWide(key.substr(start + 1, valuenamepos - start - 1));
- if (primary == "HKEY_CURRENT_USER") {
+ if (hasPrefix(key, "HKEY_CURRENT_USER", start)) {
primaryKey = HKEY_CURRENT_USER;
- }
- if (primary == "HKEY_CURRENT_CONFIG") {
+ } else if (hasPrefix(key, "HKEY_CURRENT_CONFIG", start)) {
primaryKey = HKEY_CURRENT_CONFIG;
- }
- if (primary == "HKEY_CLASSES_ROOT") {
+ } else if (hasPrefix(key, "HKEY_CLASSES_ROOT", start)) {
primaryKey = HKEY_CLASSES_ROOT;
- }
- if (primary == "HKEY_LOCAL_MACHINE") {
+ } else if (hasPrefix(key, "HKEY_LOCAL_MACHINE", start)) {
primaryKey = HKEY_LOCAL_MACHINE;
- }
- if (primary == "HKEY_USERS") {
+ } else if (hasPrefix(key, "HKEY_USERS", start)) {
primaryKey = HKEY_USERS;
}
@@ -1074,14 +1067,13 @@ bool SystemTools::GetRegistrySubKeys(const std::string& key,
KeyWOW64 view)
{
HKEY primaryKey = HKEY_CURRENT_USER;
- std::string second;
- std::string valuename;
- if (!SystemToolsParseRegistryKey(key, primaryKey, second, valuename)) {
+ std::wstring second;
+ if (!SystemToolsParseRegistryKey(key, primaryKey, second, nullptr)) {
return false;
}
HKEY hKey;
- if (RegOpenKeyExW(primaryKey, Encoding::ToWide(second).c_str(), 0,
+ if (RegOpenKeyExW(primaryKey, second.c_str(), 0,
SystemToolsMakeRegistryMode(KEY_READ, view),
&hKey) != ERROR_SUCCESS) {
return false;
@@ -1121,14 +1113,14 @@ bool SystemTools::ReadRegistryValue(const std::string& key, std::string& value,
{
bool valueset = false;
HKEY primaryKey = HKEY_CURRENT_USER;
- std::string second;
+ std::wstring second;
std::string valuename;
- if (!SystemToolsParseRegistryKey(key, primaryKey, second, valuename)) {
+ if (!SystemToolsParseRegistryKey(key, primaryKey, second, &valuename)) {
return false;
}
HKEY hKey;
- if (RegOpenKeyExW(primaryKey, Encoding::ToWide(second).c_str(), 0,
+ if (RegOpenKeyExW(primaryKey, second.c_str(), 0,
SystemToolsMakeRegistryMode(KEY_READ, view),
&hKey) != ERROR_SUCCESS) {
return false;
@@ -1175,16 +1167,16 @@ bool SystemTools::WriteRegistryValue(const std::string& key,
const std::string& value, KeyWOW64 view)
{
HKEY primaryKey = HKEY_CURRENT_USER;
- std::string second;
+ std::wstring second;
std::string valuename;
- if (!SystemToolsParseRegistryKey(key, primaryKey, second, valuename)) {
+ if (!SystemToolsParseRegistryKey(key, primaryKey, second, &valuename)) {
return false;
}
HKEY hKey;
DWORD dwDummy;
wchar_t lpClass[] = L"";
- if (RegCreateKeyExW(primaryKey, Encoding::ToWide(second).c_str(), 0, lpClass,
+ if (RegCreateKeyExW(primaryKey, second.c_str(), 0, lpClass,
REG_OPTION_NON_VOLATILE,
SystemToolsMakeRegistryMode(KEY_WRITE, view), nullptr,
&hKey, &dwDummy) != ERROR_SUCCESS) {
@@ -1219,14 +1211,14 @@ bool SystemTools::WriteRegistryValue(const std::string&, const std::string&,
bool SystemTools::DeleteRegistryValue(const std::string& key, KeyWOW64 view)
{
HKEY primaryKey = HKEY_CURRENT_USER;
- std::string second;
+ std::wstring second;
std::string valuename;
- if (!SystemToolsParseRegistryKey(key, primaryKey, second, valuename)) {
+ if (!SystemToolsParseRegistryKey(key, primaryKey, second, &valuename)) {
return false;
}
HKEY hKey;
- if (RegOpenKeyExW(primaryKey, Encoding::ToWide(second).c_str(), 0,
+ if (RegOpenKeyExW(primaryKey, second.c_str(), 0,
SystemToolsMakeRegistryMode(KEY_WRITE, view),
&hKey) != ERROR_SUCCESS) {
return false;
@@ -1435,11 +1427,7 @@ int SystemTools::Stat(const std::string& path, SystemTools::Stat_t* buf)
// long paths, but _wstat64 rejects paths with '?' in them, thinking
// they are wildcards.
std::wstring const& wpath = Encoding::ToWide(path);
-# if defined(__BORLANDC__)
- return _wstati64(wpath.c_str(), buf);
-# else
return _wstat64(wpath.c_str(), buf);
-# endif
#else
return stat(path.c_str(), buf);
#endif
@@ -1448,15 +1436,15 @@ int SystemTools::Stat(const std::string& path, SystemTools::Stat_t* buf)
#ifdef __CYGWIN__
bool SystemTools::PathCygwinToWin32(const char* path, char* win32_path)
{
- auto itr = SystemTools::Statics->Cyg2Win32Map.find(path);
- if (itr != SystemTools::Statics->Cyg2Win32Map.end()) {
+ auto itr = SystemToolsStatics->Cyg2Win32Map.find(path);
+ if (itr != SystemToolsStatics->Cyg2Win32Map.end()) {
strncpy(win32_path, itr->second.c_str(), MAX_PATH);
} else {
if (cygwin_conv_path(CCP_POSIX_TO_WIN_A, path, win32_path, MAX_PATH) !=
0) {
win32_path[0] = 0;
}
- SystemTools::Statics->Cyg2Win32Map.insert(
+ SystemToolsStatics->Cyg2Win32Map.insert(
SystemToolsStatic::StringMap::value_type(path, win32_path));
}
return win32_path[0] != 0;
@@ -1858,7 +1846,7 @@ char* SystemTools::DuplicateString(const char* str)
// Return a cropped string
std::string SystemTools::CropString(const std::string& s, size_t max_len)
{
- if (!s.size() || max_len == 0 || max_len >= s.size()) {
+ if (s.empty() || max_len == 0 || max_len >= s.size()) {
return s;
}
@@ -1867,7 +1855,7 @@ std::string SystemTools::CropString(const std::string& s, size_t max_len)
size_t middle = max_len / 2;
- n += s.substr(0, middle);
+ n.assign(s, 0, middle);
n += s.substr(s.size() - (max_len - middle));
if (max_len > 2) {
@@ -1893,10 +1881,10 @@ std::vector<std::string> SystemTools::SplitString(const std::string& p,
}
if (isPath && path[0] == '/') {
path.erase(path.begin());
- paths.push_back("/");
+ paths.emplace_back("/");
}
std::string::size_type pos1 = 0;
- std::string::size_type pos2 = path.find(sep, pos1 + 1);
+ std::string::size_type pos2 = path.find(sep, pos1);
while (pos2 != std::string::npos) {
paths.push_back(path.substr(pos1, pos2 - pos1));
pos1 = pos2 + 1;
@@ -2065,8 +2053,10 @@ void SystemTools::ConvertToUnixSlashes(std::string& path)
#ifdef HAVE_GETPWNAM
else if (pathCString[0] == '~') {
std::string::size_type idx = path.find_first_of("/\0");
- std::string user = path.substr(1, idx - 1);
- passwd* pw = getpwnam(user.c_str());
+ char oldch = path[idx];
+ path[idx] = '\0';
+ passwd* pw = getpwnam(path.c_str() + 1);
+ path[idx] = oldch;
if (pw) {
path.replace(0, idx, pw->pw_dir);
}
@@ -2103,7 +2093,7 @@ std::string SystemTools::ConvertToUnixOutputPath(const std::string& path)
ret.erase(pos, 1);
}
// escape spaces and () in the path
- if (ret.find_first_of(" ") != std::string::npos) {
+ if (ret.find_first_of(' ') != std::string::npos) {
std::string result;
char lastch = 1;
for (const char* ch = ret.c_str(); *ch != '\0'; ++ch) {
@@ -2501,8 +2491,8 @@ bool SystemTools::CopyADirectory(const std::string& source,
return false;
}
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) {
- if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") &&
- strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..")) {
+ if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") != 0 &&
+ strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..") != 0) {
std::string fullPath = source;
fullPath += "/";
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
@@ -2664,8 +2654,8 @@ bool SystemTools::RemoveADirectory(const std::string& source)
dir.Load(source);
size_t fileNum;
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) {
- if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") &&
- strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..")) {
+ if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") != 0 &&
+ strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..") != 0) {
std::string fullPath = source;
fullPath += "/";
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
@@ -2797,7 +2787,7 @@ std::string SystemTools::FindProgram(const std::string& name,
for (std::string const& ext : extensions) {
tryPath = name;
tryPath += ext;
- if (SystemTools::FileExists(tryPath, true)) {
+ if (SystemTools::FileIsExecutable(tryPath)) {
return SystemTools::CollapseFullPath(tryPath);
}
}
@@ -2805,7 +2795,7 @@ std::string SystemTools::FindProgram(const std::string& name,
#endif
// now try just the name
- if (SystemTools::FileExists(name, true)) {
+ if (SystemTools::FileIsExecutable(name)) {
return SystemTools::CollapseFullPath(name);
}
// now construct the path
@@ -2835,7 +2825,7 @@ std::string SystemTools::FindProgram(const std::string& name,
tryPath = p;
tryPath += name;
tryPath += ext;
- if (SystemTools::FileExists(tryPath, true)) {
+ if (SystemTools::FileIsExecutable(tryPath)) {
return SystemTools::CollapseFullPath(tryPath);
}
}
@@ -2843,7 +2833,7 @@ std::string SystemTools::FindProgram(const std::string& name,
// now try it without them
tryPath = p;
tryPath += name;
- if (SystemTools::FileExists(tryPath, true)) {
+ if (SystemTools::FileIsExecutable(tryPath)) {
return SystemTools::CollapseFullPath(tryPath);
}
}
@@ -2998,6 +2988,15 @@ bool SystemTools::FileIsDirectory(const std::string& inName)
}
}
+bool SystemTools::FileIsExecutable(const std::string& name)
+{
+#if defined(_WIN32)
+ return SystemTools::FileExists(name, true);
+#else
+ return !FileIsDirectory(name) && TestFileAccess(name, TEST_FILE_EXECUTE);
+#endif
+}
+
bool SystemTools::FileIsSymlink(const std::string& name)
{
#if defined(_WIN32)
@@ -3107,16 +3106,14 @@ int SystemTools::ChangeDirectory(const std::string& dir)
return Chdir(dir);
}
-std::string SystemTools::GetCurrentWorkingDirectory(bool collapse)
+std::string SystemTools::GetCurrentWorkingDirectory()
{
char buf[2048];
const char* cwd = Getcwd(buf, 2048);
std::string path;
if (cwd) {
path = cwd;
- }
- if (collapse) {
- return SystemTools::CollapseFullPath(path);
+ SystemTools::ConvertToUnixSlashes(path);
}
return path;
}
@@ -3132,17 +3129,17 @@ bool SystemTools::SplitProgramPath(const std::string& in_name,
std::string& dir, std::string& file, bool)
{
dir = in_name;
- file = "";
+ file.clear();
SystemTools::ConvertToUnixSlashes(dir);
if (!SystemTools::FileIsDirectory(dir)) {
- std::string::size_type slashPos = dir.rfind("/");
+ std::string::size_type slashPos = dir.rfind('/');
if (slashPos != std::string::npos) {
file = dir.substr(slashPos + 1);
- dir = dir.substr(0, slashPos);
+ dir.resize(slashPos);
} else {
file = dir;
- dir = "";
+ dir.clear();
}
}
if (!(dir.empty()) && !SystemTools::FileIsDirectory(dir)) {
@@ -3164,7 +3161,7 @@ bool SystemTools::FindProgramPath(const char* argv0, std::string& pathOut,
failures.push_back(self);
SystemTools::ConvertToUnixSlashes(self);
self = SystemTools::FindProgram(self);
- if (!SystemTools::FileExists(self)) {
+ if (!SystemTools::FileIsExecutable(self)) {
if (buildDir) {
std::string intdir = ".";
#ifdef CMAKE_INTDIR
@@ -3179,14 +3176,14 @@ bool SystemTools::FindProgramPath(const char* argv0, std::string& pathOut,
}
}
if (installPrefix) {
- if (!SystemTools::FileExists(self)) {
+ if (!SystemTools::FileIsExecutable(self)) {
failures.push_back(self);
self = installPrefix;
self += "/bin/";
self += exeName;
}
}
- if (!SystemTools::FileExists(self)) {
+ if (!SystemTools::FileIsExecutable(self)) {
failures.push_back(self);
std::ostringstream msg;
msg << "Can not find the command line program ";
@@ -3208,11 +3205,6 @@ bool SystemTools::FindProgramPath(const char* argv0, std::string& pathOut,
return true;
}
-std::string SystemTools::CollapseFullPath(const std::string& in_relative)
-{
- return SystemTools::CollapseFullPath(in_relative, nullptr);
-}
-
#if KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP
void SystemTools::AddTranslationPath(const std::string& a,
const std::string& b)
@@ -3237,7 +3229,7 @@ void SystemTools::AddTranslationPath(const std::string& a,
path_b += '/';
}
if (!(path_a == path_b)) {
- SystemTools::Statics->TranslationMap.insert(
+ SystemToolsStatics->TranslationMap.insert(
SystemToolsStatic::StringMap::value_type(std::move(path_a),
std::move(path_b)));
}
@@ -3267,9 +3259,9 @@ void SystemTools::CheckTranslationPath(std::string& path)
// In case a file was specified we still have to go through this:
// Now convert any path found in the table back to the one desired:
- for (auto const& pair : SystemTools::Statics->TranslationMap) {
+ for (auto const& pair : SystemToolsStatics->TranslationMap) {
// We need to check of the path is a substring of the other path
- if (path.find(pair.first) == 0) {
+ if (path.compare(0, pair.first.size(), pair.first) == 0) {
path = path.replace(0, pair.first.size(), pair.second);
}
}
@@ -3302,25 +3294,10 @@ static void SystemToolsAppendComponents(
}
}
-std::string SystemTools::CollapseFullPath(const std::string& in_path,
- const char* in_base)
-{
- // Use the current working directory as a base path.
- char buf[2048];
- const char* res_in_base = in_base;
- if (!res_in_base) {
- if (const char* cwd = Getcwd(buf, 2048)) {
- res_in_base = cwd;
- } else {
- res_in_base = "";
- }
- }
+namespace {
- return SystemTools::CollapseFullPath(in_path, std::string(res_in_base));
-}
-
-std::string SystemTools::CollapseFullPath(const std::string& in_path,
- const std::string& in_base)
+std::string CollapseFullPathImpl(std::string const& in_path,
+ std::string const* in_base)
{
// Collect the output path components.
std::vector<std::string> out_components;
@@ -3333,8 +3310,15 @@ std::string SystemTools::CollapseFullPath(const std::string& in_path,
// If the input path is relative, start with a base path.
if (path_components[0].empty()) {
std::vector<std::string> base_components;
- // Use the given base path.
- SystemTools::SplitPath(in_base, base_components);
+
+ if (in_base) {
+ // Use the given base path.
+ SystemTools::SplitPath(*in_base, base_components);
+ } else {
+ // Use the current working directory as a base path.
+ std::string cwd = SystemTools::GetCurrentWorkingDirectory();
+ SystemTools::SplitPath(cwd, base_components);
+ }
// Append base path components to the output path.
out_components.push_back(base_components[0]);
@@ -3367,12 +3351,34 @@ std::string SystemTools::CollapseFullPath(const std::string& in_path,
SystemTools::CheckTranslationPath(newPath);
#endif
#ifdef _WIN32
- newPath = SystemTools::Statics->GetActualCaseForPathCached(newPath);
+ newPath = SystemToolsStatics->GetActualCaseForPathCached(newPath);
SystemTools::ConvertToUnixSlashes(newPath);
#endif
// Return the reconstructed path.
return newPath;
}
+}
+
+std::string SystemTools::CollapseFullPath(std::string const& in_path)
+{
+ return CollapseFullPathImpl(in_path, nullptr);
+}
+
+std::string SystemTools::CollapseFullPath(std::string const& in_path,
+ const char* in_base)
+{
+ if (!in_base) {
+ return CollapseFullPathImpl(in_path, nullptr);
+ }
+ std::string tmp_base = in_base;
+ return CollapseFullPathImpl(in_path, &tmp_base);
+}
+
+std::string SystemTools::CollapseFullPath(std::string const& in_path,
+ std::string const& in_base)
+{
+ return CollapseFullPathImpl(in_path, &in_base);
+}
// compute the relative path from here to there
std::string SystemTools::RelativePath(const std::string& local,
@@ -3541,7 +3547,7 @@ void SystemTools::SplitPath(const std::string& p,
// Expand home directory references if requested.
if (expand_home_dir && !root.empty() && root[0] == '~') {
std::string homedir;
- root = root.substr(0, root.size() - 1);
+ root.resize(root.size() - 1);
if (root.size() == 1) {
#if defined(_WIN32) && !defined(__CYGWIN__)
if (!SystemTools::GetEnv("USERPROFILE", homedir))
@@ -3571,14 +3577,14 @@ void SystemTools::SplitPath(const std::string& p,
for (; *last; ++last) {
if (*last == '/' || *last == '\\') {
// End of a component. Save it.
- components.push_back(std::string(first, last));
+ components.emplace_back(first, last);
first = last + 1;
}
}
// Save the last component unless there were no components.
if (last != c) {
- components.push_back(std::string(first, last));
+ components.emplace_back(first, last);
}
}
@@ -3594,7 +3600,7 @@ std::string SystemTools::JoinPath(
// Construct result in a single string.
std::string result;
size_t len = 0;
- for (std::vector<std::string>::const_iterator i = first; i != last; ++i) {
+ for (auto i = first; i != last; ++i) {
len += 1 + i->size();
}
result.reserve(len);
@@ -3685,19 +3691,20 @@ std::string SystemTools::GetFilenamePath(const std::string& filename)
std::string fn = filename;
SystemTools::ConvertToUnixSlashes(fn);
- std::string::size_type slash_pos = fn.rfind("/");
- if (slash_pos != std::string::npos) {
- std::string ret = fn.substr(0, slash_pos);
- if (ret.size() == 2 && ret[1] == ':') {
- return ret + '/';
- }
- if (ret.empty()) {
- return "/";
- }
- return ret;
- } else {
+ std::string::size_type slash_pos = fn.rfind('/');
+ if (slash_pos == 0) {
+ return "/";
+ }
+ if (slash_pos == 2 && fn[1] == ':') {
+ // keep the / after a drive letter
+ fn.resize(3);
+ return fn;
+ }
+ if (slash_pos == std::string::npos) {
return "";
}
+ fn.resize(slash_pos);
+ return fn;
}
/**
@@ -3727,7 +3734,8 @@ std::string SystemTools::GetFilenameExtension(const std::string& filename)
std::string name = SystemTools::GetFilenameName(filename);
std::string::size_type dot_pos = name.find('.');
if (dot_pos != std::string::npos) {
- return name.substr(dot_pos);
+ name.erase(0, dot_pos);
+ return name;
} else {
return "";
}
@@ -3742,7 +3750,8 @@ std::string SystemTools::GetFilenameLastExtension(const std::string& filename)
std::string name = SystemTools::GetFilenameName(filename);
std::string::size_type dot_pos = name.rfind('.');
if (dot_pos != std::string::npos) {
- return name.substr(dot_pos);
+ name.erase(0, dot_pos);
+ return name;
} else {
return "";
}
@@ -3758,10 +3767,9 @@ std::string SystemTools::GetFilenameWithoutExtension(
std::string name = SystemTools::GetFilenameName(filename);
std::string::size_type dot_pos = name.find('.');
if (dot_pos != std::string::npos) {
- return name.substr(0, dot_pos);
- } else {
- return name;
+ name.resize(dot_pos);
}
+ return name;
}
/**
@@ -3775,10 +3783,9 @@ std::string SystemTools::GetFilenameWithoutLastExtension(
std::string name = SystemTools::GetFilenameName(filename);
std::string::size_type dot_pos = name.rfind('.');
if (dot_pos != std::string::npos) {
- return name.substr(0, dot_pos);
- } else {
- return name;
+ name.resize(dot_pos);
}
+ return name;
}
bool SystemTools::FileHasSignature(const char* filename, const char* signature,
@@ -3828,7 +3835,7 @@ SystemTools::FileTypeEnum SystemTools::DetectFileType(const char* filename,
// Allocate buffer and read bytes
- unsigned char* buffer = new unsigned char[length];
+ auto* buffer = new unsigned char[length];
size_t read_length = fread(buffer, 1, length, fp);
fclose(fp);
if (read_length == 0) {
@@ -4000,7 +4007,8 @@ bool SystemTools::GetShortPath(const std::string& path, std::string& shortPath)
// if the path passed in has quotes around it, first remove the quotes
if (!path.empty() && path[0] == '"' && path.back() == '"') {
- tempPath = path.substr(1, path.length() - 2);
+ tempPath.resize(path.length() - 1);
+ tempPath.erase(0, 1);
}
std::wstring wtempPath = Encoding::ToWide(tempPath);
@@ -4219,8 +4227,8 @@ bool SystemTools::IsSubDirectory(const std::string& cSubdir,
if (subdir[expectedSlashPosition] != '/') {
return false;
}
- std::string s = subdir.substr(0, dir.size());
- return SystemTools::ComparePath(s, dir);
+ subdir.resize(dir.size());
+ return SystemTools::ComparePath(subdir, dir);
}
void SystemTools::Delay(unsigned int msec)
@@ -4516,7 +4524,7 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
bool SystemTools::ParseURLProtocol(const std::string& URL,
std::string& protocol,
- std::string& dataglom)
+ std::string& dataglom, bool decode)
{
// match 0 entire url
// match 1 protocol
@@ -4529,13 +4537,17 @@ bool SystemTools::ParseURLProtocol(const std::string& URL,
protocol = urlRe.match(1);
dataglom = urlRe.match(2);
+ if (decode) {
+ dataglom = DecodeURL(dataglom);
+ }
+
return true;
}
bool SystemTools::ParseURL(const std::string& URL, std::string& protocol,
std::string& username, std::string& password,
std::string& hostname, std::string& dataport,
- std::string& database)
+ std::string& database, bool decode)
{
kwsys::RegularExpression urlRe(VTK_URL_REGEX);
if (!urlRe.find(URL))
@@ -4559,13 +4571,37 @@ bool SystemTools::ParseURL(const std::string& URL, std::string& protocol,
dataport = urlRe.match(8);
database = urlRe.match(9);
+ if (decode) {
+ username = DecodeURL(username);
+ password = DecodeURL(password);
+ hostname = DecodeURL(hostname);
+ dataport = DecodeURL(dataport);
+ database = DecodeURL(database);
+ }
+
return true;
}
-// These must NOT be initialized. Default initialization to zero is
-// necessary.
+// ----------------------------------------------------------------------
+std::string SystemTools::DecodeURL(const std::string& url)
+{
+ kwsys::RegularExpression urlByteRe(VTK_URL_BYTE_REGEX);
+ std::string ret;
+ for (size_t i = 0; i < url.length(); i++) {
+ if (urlByteRe.find(url.substr(i, 3))) {
+ char bytes[] = { url[i + 1], url[i + 2], '\0' };
+ ret += static_cast<char>(strtoul(bytes, nullptr, 16));
+ i += 2;
+ } else {
+ ret += url[i];
+ }
+ }
+ return ret;
+}
+
+// ----------------------------------------------------------------------
+// Do NOT initialize. Default initialization to zero is necessary.
static unsigned int SystemToolsManagerCount;
-SystemToolsStatic* SystemTools::Statics;
// SystemToolsManager manages the SystemTools singleton.
// SystemToolsManager should be included in any translation unit
@@ -4608,7 +4644,7 @@ void SystemTools::ClassInitialize()
#endif
// Create statics singleton instance
- SystemTools::Statics = new SystemToolsStatic;
+ SystemToolsStatics = new SystemToolsStatic;
#if KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP
// Add some special translation paths for unix. These are not added
@@ -4658,7 +4694,7 @@ void SystemTools::ClassInitialize()
void SystemTools::ClassFinalize()
{
- delete SystemTools::Statics;
+ delete SystemToolsStatics;
}
} // namespace KWSYS_NAMESPACE
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index c4ab9d4f3..5dbb726a0 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -67,7 +67,7 @@ static SystemToolsManager SystemToolsManagerInstance;
// combined using the | operator.
typedef int TestFilePermissions;
#if defined(_WIN32) && !defined(__CYGWIN__)
-// On Windows (VC and Borland), no system header defines these constants...
+// On Windows (VC), no system header defines these constants...
static const TestFilePermissions TEST_FILE_OK = 0;
static const TestFilePermissions TEST_FILE_READ = 4;
static const TestFilePermissions TEST_FILE_WRITE = 2;
@@ -317,11 +317,7 @@ public:
* Cross platform wrapper for stat struct
*/
#if defined(_WIN32) && !defined(__CYGWIN__)
-# if defined(__BORLANDC__)
- typedef struct stati64 Stat_t;
-# else
typedef struct _stat64 Stat_t;
-# endif
#else
typedef struct stat Stat_t;
#endif
@@ -411,11 +407,11 @@ public:
* (which defaults to the current working directory). The full path
* is returned.
*/
- static std::string CollapseFullPath(const std::string& in_relative);
- static std::string CollapseFullPath(const std::string& in_relative,
+ static std::string CollapseFullPath(std::string const& in_path);
+ static std::string CollapseFullPath(std::string const& in_path,
const char* in_base);
- static std::string CollapseFullPath(const std::string& in_relative,
- const std::string& in_base);
+ static std::string CollapseFullPath(std::string const& in_path,
+ std::string const& in_base);
/**
* Get the real path for a given path, removing all symlinks. In
@@ -549,12 +545,13 @@ public:
*/
/**
- * Open a file considering unicode.
+ * Open a file considering unicode. On Windows, if 'e' is present in
+ * mode it is first discarded.
*/
static FILE* Fopen(const std::string& file, const char* mode);
/**
- * Visual C++ does not define mode_t (note that Borland does, however).
+ * Visual C++ does not define mode_t.
*/
#if defined(_MSC_VER)
typedef unsigned short mode_t;
@@ -677,6 +674,11 @@ public:
static bool FileIsDirectory(const std::string& name);
/**
+ * Return true if the file is an executable
+ */
+ static bool FileIsExecutable(const std::string& name);
+
+ /**
* Return true if the file is a symlink
*/
static bool FileIsSymlink(const std::string& name);
@@ -869,7 +871,7 @@ public:
/**
* Get current working directory CWD
*/
- static std::string GetCurrentWorkingDirectory(bool collapse = true);
+ static std::string GetCurrentWorkingDirectory();
/**
* Change directory to the directory specified
@@ -935,22 +937,32 @@ public:
* Parse a character string :
* protocol://dataglom
* and fill protocol as appropriate.
+ * decode the dataglom using DecodeURL if set to true.
* Return false if the URL does not have the required form, true otherwise.
*/
static bool ParseURLProtocol(const std::string& URL, std::string& protocol,
- std::string& dataglom);
+ std::string& dataglom, bool decode = false);
/**
* Parse a string (a URL without protocol prefix) with the form:
* protocol://[[username[':'password]'@']hostname[':'dataport]]'/'[datapath]
* and fill protocol, username, password, hostname, dataport, and datapath
* when values are found.
+ * decode all string except the protocol using DecodeUrl if set to true.
* Return true if the string matches the format; false otherwise.
*/
static bool ParseURL(const std::string& URL, std::string& protocol,
std::string& username, std::string& password,
std::string& hostname, std::string& dataport,
- std::string& datapath);
+ std::string& datapath, bool decode = false);
+
+ /**
+ * Decode the percent-encoded string from an URL or an URI
+ * into their correct char values.
+ * Does not perform any other sort of validation.
+ * Return the decoded string
+ */
+ static std::string DecodeURL(const std::string& url);
private:
/**
@@ -971,7 +983,6 @@ private:
return &SystemToolsManagerInstance;
}
- static SystemToolsStatic* Statics;
friend class SystemToolsStatic;
friend class SystemToolsManager;
};
diff --git a/Source/kwsys/hash_fun.hxx.in b/Source/kwsys/hash_fun.hxx.in
deleted file mode 100644
index 8626c2aa2..000000000
--- a/Source/kwsys/hash_fun.hxx.in
+++ /dev/null
@@ -1,166 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
-/*
- * Copyright (c) 1996
- * Silicon Graphics Computer Systems, Inc.
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Silicon Graphics makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- *
- * Copyright (c) 1994
- * Hewlett-Packard Company
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Hewlett-Packard Company makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-#ifndef @KWSYS_NAMESPACE@_hash_fun_hxx
-#define @KWSYS_NAMESPACE@_hash_fun_hxx
-
-#include <@KWSYS_NAMESPACE@/Configure.hxx>
-
-#include <stddef.h> // size_t
-#include <string>
-
-namespace @KWSYS_NAMESPACE@ {
-
-template <class _Key>
-struct hash
-{
-};
-
-inline size_t _stl_hash_string(const char* __s)
-{
- unsigned long __h = 0;
- for (; *__s; ++__s)
- __h = 5 * __h + *__s;
-
- return size_t(__h);
-}
-
-template <>
-struct hash<char*>
-{
- size_t operator()(const char* __s) const { return _stl_hash_string(__s); }
-};
-
-template <>
-struct hash<const char*>
-{
- size_t operator()(const char* __s) const { return _stl_hash_string(__s); }
-};
-
-template <>
-struct hash<std::string>
-{
- size_t operator()(const std::string& __s) const
- {
- return _stl_hash_string(__s.c_str());
- }
-};
-
-#if !defined(__BORLANDC__)
-template <>
-struct hash<const std::string>
-{
- size_t operator()(const std::string& __s) const
- {
- return _stl_hash_string(__s.c_str());
- }
-};
-#endif
-
-template <>
-struct hash<char>
-{
- size_t operator()(char __x) const { return __x; }
-};
-
-template <>
-struct hash<unsigned char>
-{
- size_t operator()(unsigned char __x) const { return __x; }
-};
-
-template <>
-struct hash<signed char>
-{
- size_t operator()(unsigned char __x) const { return __x; }
-};
-
-template <>
-struct hash<short>
-{
- size_t operator()(short __x) const { return __x; }
-};
-
-template <>
-struct hash<unsigned short>
-{
- size_t operator()(unsigned short __x) const { return __x; }
-};
-
-template <>
-struct hash<int>
-{
- size_t operator()(int __x) const { return __x; }
-};
-
-template <>
-struct hash<unsigned int>
-{
- size_t operator()(unsigned int __x) const { return __x; }
-};
-
-template <>
-struct hash<long>
-{
- size_t operator()(long __x) const { return __x; }
-};
-
-template <>
-struct hash<unsigned long>
-{
- size_t operator()(unsigned long __x) const { return __x; }
-};
-
-// use long long or __int64
-#if @KWSYS_USE_LONG_LONG@
-template <>
-struct hash<long long>
-{
- size_t operator()(long long __x) const { return __x; }
-};
-
-template <>
-struct hash<unsigned long long>
-{
- size_t operator()(unsigned long long __x) const { return __x; }
-};
-#elif @KWSYS_USE___INT64@
-template <>
-struct hash<__int64>
-{
- size_t operator()(__int64 __x) const { return __x; }
-};
-template <>
-struct hash<unsigned __int64>
-{
- size_t operator()(unsigned __int64 __x) const { return __x; }
-};
-#endif // use long long or __int64
-
-} // namespace @KWSYS_NAMESPACE@
-
-#endif
diff --git a/Source/kwsys/hash_map.hxx.in b/Source/kwsys/hash_map.hxx.in
deleted file mode 100644
index 5f04e9c16..000000000
--- a/Source/kwsys/hash_map.hxx.in
+++ /dev/null
@@ -1,423 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
-/*
- * Copyright (c) 1996
- * Silicon Graphics Computer Systems, Inc.
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Silicon Graphics makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- *
- * Copyright (c) 1994
- * Hewlett-Packard Company
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Hewlett-Packard Company makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-#ifndef @KWSYS_NAMESPACE@_hash_map_hxx
-#define @KWSYS_NAMESPACE@_hash_map_hxx
-
-#include <@KWSYS_NAMESPACE@/hashtable.hxx>
-
-#include <@KWSYS_NAMESPACE@/hash_fun.hxx>
-
-#include <functional> // equal_to
-
-#if defined(_MSC_VER)
-# pragma warning(push)
-# pragma warning(disable : 4284)
-# pragma warning(disable : 4786)
-#endif
-
-#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
-# pragma set woff 1174
-# pragma set woff 1375
-#endif
-
-namespace @KWSYS_NAMESPACE@ {
-
-// select1st is an extension: it is not part of the standard.
-template <class T1, class T2>
-struct hash_select1st
-{
- const T1& operator()(const std::pair<T1, T2>& __x) const
- {
- return __x.first;
- }
-};
-
-// Forward declaration of equality operator; needed for friend declaration.
-
-template <class _Key, class _Tp, class _HashFcn = hash<_Key>,
- class _EqualKey = std::equal_to<_Key>,
- class _Alloc = std::allocator<char> >
-class hash_map;
-
-template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
-bool operator==(const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&,
- const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&);
-
-template <class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
-class hash_map
-{
-private:
- typedef hashtable<std::pair<const _Key, _Tp>, _Key, _HashFcn,
- hash_select1st<const _Key, _Tp>, _EqualKey, _Alloc>
- _Ht;
- _Ht _M_ht;
-
-public:
- typedef typename _Ht::key_type key_type;
- typedef _Tp data_type;
- typedef _Tp mapped_type;
- typedef typename _Ht::value_type value_type;
- typedef typename _Ht::hasher hasher;
- typedef typename _Ht::key_equal key_equal;
-
- typedef typename _Ht::size_type size_type;
- typedef typename _Ht::difference_type difference_type;
- typedef typename _Ht::pointer pointer;
- typedef typename _Ht::const_pointer const_pointer;
- typedef typename _Ht::reference reference;
- typedef typename _Ht::const_reference const_reference;
-
- typedef typename _Ht::iterator iterator;
- typedef typename _Ht::const_iterator const_iterator;
-
- typedef typename _Ht::allocator_type allocator_type;
-
- hasher hash_funct() const { return _M_ht.hash_funct(); }
- key_equal key_eq() const { return _M_ht.key_eq(); }
- allocator_type get_allocator() const { return _M_ht.get_allocator(); }
-
-public:
- hash_map()
- : _M_ht(100, hasher(), key_equal(), allocator_type())
- {
- }
- explicit hash_map(size_type __n)
- : _M_ht(__n, hasher(), key_equal(), allocator_type())
- {
- }
- hash_map(size_type __n, const hasher& __hf)
- : _M_ht(__n, __hf, key_equal(), allocator_type())
- {
- }
- hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
- const allocator_type& __a = allocator_type())
- : _M_ht(__n, __hf, __eql, __a)
- {
- }
-
- template <class _InputIterator>
- hash_map(_InputIterator __f, _InputIterator __l)
- : _M_ht(100, hasher(), key_equal(), allocator_type())
- {
- _M_ht.insert_unique(__f, __l);
- }
- template <class _InputIterator>
- hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
- : _M_ht(__n, hasher(), key_equal(), allocator_type())
- {
- _M_ht.insert_unique(__f, __l);
- }
- template <class _InputIterator>
- hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
- const hasher& __hf)
- : _M_ht(__n, __hf, key_equal(), allocator_type())
- {
- _M_ht.insert_unique(__f, __l);
- }
- template <class _InputIterator>
- hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
- const hasher& __hf, const key_equal& __eql,
- const allocator_type& __a = allocator_type())
- : _M_ht(__n, __hf, __eql, __a)
- {
- _M_ht.insert_unique(__f, __l);
- }
-
-public:
- size_type size() const { return _M_ht.size(); }
- size_type max_size() const { return _M_ht.max_size(); }
- bool empty() const { return _M_ht.empty(); }
- void swap(hash_map& __hs) { _M_ht.swap(__hs._M_ht); }
-
- friend bool operator==<>(const hash_map&, const hash_map&);
-
- iterator begin() { return _M_ht.begin(); }
- iterator end() { return _M_ht.end(); }
- const_iterator begin() const { return _M_ht.begin(); }
- const_iterator end() const { return _M_ht.end(); }
-
-public:
- std::pair<iterator, bool> insert(const value_type& __obj)
- {
- return _M_ht.insert_unique(__obj);
- }
- template <class _InputIterator>
- void insert(_InputIterator __f, _InputIterator __l)
- {
- _M_ht.insert_unique(__f, __l);
- }
- std::pair<iterator, bool> insert_noresize(const value_type& __obj)
- {
- return _M_ht.insert_unique_noresize(__obj);
- }
-
- iterator find(const key_type& __key) { return _M_ht.find(__key); }
- const_iterator find(const key_type& __key) const
- {
- return _M_ht.find(__key);
- }
-
- _Tp& operator[](const key_type& __key)
- {
- return _M_ht.find_or_insert(value_type(__key, _Tp())).second;
- }
-
- size_type count(const key_type& __key) const { return _M_ht.count(__key); }
-
- std::pair<iterator, iterator> equal_range(const key_type& __key)
- {
- return _M_ht.equal_range(__key);
- }
- std::pair<const_iterator, const_iterator> equal_range(
- const key_type& __key) const
- {
- return _M_ht.equal_range(__key);
- }
-
- size_type erase(const key_type& __key) { return _M_ht.erase(__key); }
- void erase(iterator __it) { _M_ht.erase(__it); }
- void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
- void clear() { _M_ht.clear(); }
-
- void resize(size_type __hint) { _M_ht.resize(__hint); }
- size_type bucket_count() const { return _M_ht.bucket_count(); }
- size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
- size_type elems_in_bucket(size_type __n) const
- {
- return _M_ht.elems_in_bucket(__n);
- }
-};
-
-template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
-bool operator==(const hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm1,
- const hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm2)
-{
- return __hm1._M_ht == __hm2._M_ht;
-}
-
-template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
-inline bool operator!=(
- const hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm1,
- const hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm2)
-{
- return !(__hm1 == __hm2);
-}
-
-template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
-inline void swap(hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm1,
- hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm2)
-{
- __hm1.swap(__hm2);
-}
-
-// Forward declaration of equality operator; needed for friend declaration.
-
-template <class _Key, class _Tp, class _HashFcn = hash<_Key>,
- class _EqualKey = std::equal_to<_Key>,
- class _Alloc = std::allocator<char> >
-class hash_multimap;
-
-template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
-bool operator==(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
- const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2);
-
-template <class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
-class hash_multimap
-{
-private:
- typedef hashtable<std::pair<const _Key, _Tp>, _Key, _HashFcn,
- hash_select1st<const _Key, _Tp>, _EqualKey, _Alloc>
- _Ht;
- _Ht _M_ht;
-
-public:
- typedef typename _Ht::key_type key_type;
- typedef _Tp data_type;
- typedef _Tp mapped_type;
- typedef typename _Ht::value_type value_type;
- typedef typename _Ht::hasher hasher;
- typedef typename _Ht::key_equal key_equal;
-
- typedef typename _Ht::size_type size_type;
- typedef typename _Ht::difference_type difference_type;
- typedef typename _Ht::pointer pointer;
- typedef typename _Ht::const_pointer const_pointer;
- typedef typename _Ht::reference reference;
- typedef typename _Ht::const_reference const_reference;
-
- typedef typename _Ht::iterator iterator;
- typedef typename _Ht::const_iterator const_iterator;
-
- typedef typename _Ht::allocator_type allocator_type;
-
- hasher hash_funct() const { return _M_ht.hash_funct(); }
- key_equal key_eq() const { return _M_ht.key_eq(); }
- allocator_type get_allocator() const { return _M_ht.get_allocator(); }
-
-public:
- hash_multimap()
- : _M_ht(100, hasher(), key_equal(), allocator_type())
- {
- }
- explicit hash_multimap(size_type __n)
- : _M_ht(__n, hasher(), key_equal(), allocator_type())
- {
- }
- hash_multimap(size_type __n, const hasher& __hf)
- : _M_ht(__n, __hf, key_equal(), allocator_type())
- {
- }
- hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
- const allocator_type& __a = allocator_type())
- : _M_ht(__n, __hf, __eql, __a)
- {
- }
-
- template <class _InputIterator>
- hash_multimap(_InputIterator __f, _InputIterator __l)
- : _M_ht(100, hasher(), key_equal(), allocator_type())
- {
- _M_ht.insert_equal(__f, __l);
- }
- template <class _InputIterator>
- hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
- : _M_ht(__n, hasher(), key_equal(), allocator_type())
- {
- _M_ht.insert_equal(__f, __l);
- }
- template <class _InputIterator>
- hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
- const hasher& __hf)
- : _M_ht(__n, __hf, key_equal(), allocator_type())
- {
- _M_ht.insert_equal(__f, __l);
- }
- template <class _InputIterator>
- hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
- const hasher& __hf, const key_equal& __eql,
- const allocator_type& __a = allocator_type())
- : _M_ht(__n, __hf, __eql, __a)
- {
- _M_ht.insert_equal(__f, __l);
- }
-
-public:
- size_type size() const { return _M_ht.size(); }
- size_type max_size() const { return _M_ht.max_size(); }
- bool empty() const { return _M_ht.empty(); }
- void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); }
-
- friend bool operator==<>(const hash_multimap&, const hash_multimap&);
-
- iterator begin() { return _M_ht.begin(); }
- iterator end() { return _M_ht.end(); }
- const_iterator begin() const { return _M_ht.begin(); }
- const_iterator end() const { return _M_ht.end(); }
-
-public:
- iterator insert(const value_type& __obj)
- {
- return _M_ht.insert_equal(__obj);
- }
- template <class _InputIterator>
- void insert(_InputIterator __f, _InputIterator __l)
- {
- _M_ht.insert_equal(__f, __l);
- }
- iterator insert_noresize(const value_type& __obj)
- {
- return _M_ht.insert_equal_noresize(__obj);
- }
-
- iterator find(const key_type& __key) { return _M_ht.find(__key); }
- const_iterator find(const key_type& __key) const
- {
- return _M_ht.find(__key);
- }
-
- size_type count(const key_type& __key) const { return _M_ht.count(__key); }
-
- std::pair<iterator, iterator> equal_range(const key_type& __key)
- {
- return _M_ht.equal_range(__key);
- }
- std::pair<const_iterator, const_iterator> equal_range(
- const key_type& __key) const
- {
- return _M_ht.equal_range(__key);
- }
-
- size_type erase(const key_type& __key) { return _M_ht.erase(__key); }
- void erase(iterator __it) { _M_ht.erase(__it); }
- void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
- void clear() { _M_ht.clear(); }
-
-public:
- void resize(size_type __hint) { _M_ht.resize(__hint); }
- size_type bucket_count() const { return _M_ht.bucket_count(); }
- size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
- size_type elems_in_bucket(size_type __n) const
- {
- return _M_ht.elems_in_bucket(__n);
- }
-};
-
-template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
-bool operator==(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
- const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
-{
- return __hm1._M_ht == __hm2._M_ht;
-}
-
-template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
-inline bool operator!=(
- const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
- const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
-{
- return !(__hm1 == __hm2);
-}
-
-template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
-inline void swap(hash_multimap<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm1,
- hash_multimap<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm2)
-{
- __hm1.swap(__hm2);
-}
-
-} // namespace @KWSYS_NAMESPACE@
-
-#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
-# pragma reset woff 1174
-# pragma reset woff 1375
-#endif
-
-#if defined(_MSC_VER)
-# pragma warning(pop)
-#endif
-
-#endif
diff --git a/Source/kwsys/hash_set.hxx.in b/Source/kwsys/hash_set.hxx.in
deleted file mode 100644
index f4a37eebd..000000000
--- a/Source/kwsys/hash_set.hxx.in
+++ /dev/null
@@ -1,392 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
-/*
- * Copyright (c) 1996
- * Silicon Graphics Computer Systems, Inc.
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Silicon Graphics makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- *
- * Copyright (c) 1994
- * Hewlett-Packard Company
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Hewlett-Packard Company makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-#ifndef @KWSYS_NAMESPACE@_hash_set_hxx
-#define @KWSYS_NAMESPACE@_hash_set_hxx
-
-#include <@KWSYS_NAMESPACE@/hashtable.hxx>
-
-#include <@KWSYS_NAMESPACE@/hash_fun.hxx>
-
-#include <functional> // equal_to
-
-#if defined(_MSC_VER)
-# pragma warning(push)
-# pragma warning(disable : 4284)
-# pragma warning(disable : 4786)
-#endif
-
-#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
-# pragma set woff 1174
-# pragma set woff 1375
-#endif
-
-namespace @KWSYS_NAMESPACE@ {
-
-// identity is an extension: it is not part of the standard.
-template <class _Tp>
-struct _Identity
-{
- const _Tp& operator()(const _Tp& __x) const { return __x; }
-};
-
-// Forward declaration of equality operator; needed for friend declaration.
-
-template <class _Value, class _HashFcn = hash<_Value>,
- class _EqualKey = std::equal_to<_Value>,
- class _Alloc = std::allocator<char> >
-class hash_set;
-
-template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
-bool operator==(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
- const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2);
-
-template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
-class hash_set
-{
-private:
- typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, _EqualKey,
- _Alloc>
- _Ht;
- _Ht _M_ht;
-
-public:
- typedef typename _Ht::key_type key_type;
- typedef typename _Ht::value_type value_type;
- typedef typename _Ht::hasher hasher;
- typedef typename _Ht::key_equal key_equal;
-
- typedef typename _Ht::size_type size_type;
- typedef typename _Ht::difference_type difference_type;
- typedef typename _Ht::const_pointer pointer;
- typedef typename _Ht::const_pointer const_pointer;
- typedef typename _Ht::const_reference reference;
- typedef typename _Ht::const_reference const_reference;
-
- typedef typename _Ht::const_iterator iterator;
- typedef typename _Ht::const_iterator const_iterator;
-
- typedef typename _Ht::allocator_type allocator_type;
-
- hasher hash_funct() const { return _M_ht.hash_funct(); }
- key_equal key_eq() const { return _M_ht.key_eq(); }
- allocator_type get_allocator() const { return _M_ht.get_allocator(); }
-
-public:
- hash_set()
- : _M_ht(100, hasher(), key_equal(), allocator_type())
- {
- }
- explicit hash_set(size_type __n)
- : _M_ht(__n, hasher(), key_equal(), allocator_type())
- {
- }
- hash_set(size_type __n, const hasher& __hf)
- : _M_ht(__n, __hf, key_equal(), allocator_type())
- {
- }
- hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
- const allocator_type& __a = allocator_type())
- : _M_ht(__n, __hf, __eql, __a)
- {
- }
-
- template <class _InputIterator>
- hash_set(_InputIterator __f, _InputIterator __l)
- : _M_ht(100, hasher(), key_equal(), allocator_type())
- {
- _M_ht.insert_unique(__f, __l);
- }
- template <class _InputIterator>
- hash_set(_InputIterator __f, _InputIterator __l, size_type __n)
- : _M_ht(__n, hasher(), key_equal(), allocator_type())
- {
- _M_ht.insert_unique(__f, __l);
- }
- template <class _InputIterator>
- hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
- const hasher& __hf)
- : _M_ht(__n, __hf, key_equal(), allocator_type())
- {
- _M_ht.insert_unique(__f, __l);
- }
- template <class _InputIterator>
- hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
- const hasher& __hf, const key_equal& __eql,
- const allocator_type& __a = allocator_type())
- : _M_ht(__n, __hf, __eql, __a)
- {
- _M_ht.insert_unique(__f, __l);
- }
-
-public:
- size_type size() const { return _M_ht.size(); }
- size_type max_size() const { return _M_ht.max_size(); }
- bool empty() const { return _M_ht.empty(); }
- void swap(hash_set& __hs) { _M_ht.swap(__hs._M_ht); }
-
- friend bool operator==<>(const hash_set&, const hash_set&);
-
- iterator begin() const { return _M_ht.begin(); }
- iterator end() const { return _M_ht.end(); }
-
-public:
- std::pair<iterator, bool> insert(const value_type& __obj)
- {
- typedef typename _Ht::iterator _Ht_iterator;
- std::pair<_Ht_iterator, bool> __p = _M_ht.insert_unique(__obj);
- return std::pair<iterator, bool>(__p.first, __p.second);
- }
- template <class _InputIterator>
- void insert(_InputIterator __f, _InputIterator __l)
- {
- _M_ht.insert_unique(__f, __l);
- }
- std::pair<iterator, bool> insert_noresize(const value_type& __obj)
- {
- typedef typename _Ht::iterator _Ht_iterator;
- std::pair<_Ht_iterator, bool> __p = _M_ht.insert_unique_noresize(__obj);
- return std::pair<iterator, bool>(__p.first, __p.second);
- }
-
- iterator find(const key_type& __key) const { return _M_ht.find(__key); }
-
- size_type count(const key_type& __key) const { return _M_ht.count(__key); }
-
- std::pair<iterator, iterator> equal_range(const key_type& __key) const
- {
- return _M_ht.equal_range(__key);
- }
-
- size_type erase(const key_type& __key) { return _M_ht.erase(__key); }
- void erase(iterator __it) { _M_ht.erase(__it); }
- void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
- void clear() { _M_ht.clear(); }
-
-public:
- void resize(size_type __hint) { _M_ht.resize(__hint); }
- size_type bucket_count() const { return _M_ht.bucket_count(); }
- size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
- size_type elems_in_bucket(size_type __n) const
- {
- return _M_ht.elems_in_bucket(__n);
- }
-};
-
-template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
-bool operator==(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
- const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2)
-{
- return __hs1._M_ht == __hs2._M_ht;
-}
-
-template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
-inline bool operator!=(
- const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
- const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2)
-{
- return !(__hs1 == __hs2);
-}
-
-template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
-inline void swap(hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
- hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
-{
- __hs1.swap(__hs2);
-}
-
-template <class _Value, class _HashFcn = hash<_Value>,
- class _EqualKey = std::equal_to<_Value>,
- class _Alloc = std::allocator<char> >
-class hash_multiset;
-
-template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
-bool operator==(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
- const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2);
-
-template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
-class hash_multiset
-{
-private:
- typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, _EqualKey,
- _Alloc>
- _Ht;
- _Ht _M_ht;
-
-public:
- typedef typename _Ht::key_type key_type;
- typedef typename _Ht::value_type value_type;
- typedef typename _Ht::hasher hasher;
- typedef typename _Ht::key_equal key_equal;
-
- typedef typename _Ht::size_type size_type;
- typedef typename _Ht::difference_type difference_type;
- typedef typename _Ht::const_pointer pointer;
- typedef typename _Ht::const_pointer const_pointer;
- typedef typename _Ht::const_reference reference;
- typedef typename _Ht::const_reference const_reference;
-
- typedef typename _Ht::const_iterator iterator;
- typedef typename _Ht::const_iterator const_iterator;
-
- typedef typename _Ht::allocator_type allocator_type;
-
- hasher hash_funct() const { return _M_ht.hash_funct(); }
- key_equal key_eq() const { return _M_ht.key_eq(); }
- allocator_type get_allocator() const { return _M_ht.get_allocator(); }
-
-public:
- hash_multiset()
- : _M_ht(100, hasher(), key_equal(), allocator_type())
- {
- }
- explicit hash_multiset(size_type __n)
- : _M_ht(__n, hasher(), key_equal(), allocator_type())
- {
- }
- hash_multiset(size_type __n, const hasher& __hf)
- : _M_ht(__n, __hf, key_equal(), allocator_type())
- {
- }
- hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql,
- const allocator_type& __a = allocator_type())
- : _M_ht(__n, __hf, __eql, __a)
- {
- }
-
- template <class _InputIterator>
- hash_multiset(_InputIterator __f, _InputIterator __l)
- : _M_ht(100, hasher(), key_equal(), allocator_type())
- {
- _M_ht.insert_equal(__f, __l);
- }
- template <class _InputIterator>
- hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n)
- : _M_ht(__n, hasher(), key_equal(), allocator_type())
- {
- _M_ht.insert_equal(__f, __l);
- }
- template <class _InputIterator>
- hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
- const hasher& __hf)
- : _M_ht(__n, __hf, key_equal(), allocator_type())
- {
- _M_ht.insert_equal(__f, __l);
- }
- template <class _InputIterator>
- hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
- const hasher& __hf, const key_equal& __eql,
- const allocator_type& __a = allocator_type())
- : _M_ht(__n, __hf, __eql, __a)
- {
- _M_ht.insert_equal(__f, __l);
- }
-
-public:
- size_type size() const { return _M_ht.size(); }
- size_type max_size() const { return _M_ht.max_size(); }
- bool empty() const { return _M_ht.empty(); }
- void swap(hash_multiset& hs) { _M_ht.swap(hs._M_ht); }
-
- friend bool operator==<>(const hash_multiset&, const hash_multiset&);
-
- iterator begin() const { return _M_ht.begin(); }
- iterator end() const { return _M_ht.end(); }
-
-public:
- iterator insert(const value_type& __obj)
- {
- return _M_ht.insert_equal(__obj);
- }
- template <class _InputIterator>
- void insert(_InputIterator __f, _InputIterator __l)
- {
- _M_ht.insert_equal(__f, __l);
- }
- iterator insert_noresize(const value_type& __obj)
- {
- return _M_ht.insert_equal_noresize(__obj);
- }
-
- iterator find(const key_type& __key) const { return _M_ht.find(__key); }
-
- size_type count(const key_type& __key) const { return _M_ht.count(__key); }
-
- std::pair<iterator, iterator> equal_range(const key_type& __key) const
- {
- return _M_ht.equal_range(__key);
- }
-
- size_type erase(const key_type& __key) { return _M_ht.erase(__key); }
- void erase(iterator __it) { _M_ht.erase(__it); }
- void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
- void clear() { _M_ht.clear(); }
-
-public:
- void resize(size_type __hint) { _M_ht.resize(__hint); }
- size_type bucket_count() const { return _M_ht.bucket_count(); }
- size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
- size_type elems_in_bucket(size_type __n) const
- {
- return _M_ht.elems_in_bucket(__n);
- }
-};
-
-template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
-bool operator==(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
- const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
-{
- return __hs1._M_ht == __hs2._M_ht;
-}
-
-template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
-inline bool operator!=(
- const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
- const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
-{
- return !(__hs1 == __hs2);
-}
-
-template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
-inline void swap(hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
- hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
-{
- __hs1.swap(__hs2);
-}
-
-} // namespace @KWSYS_NAMESPACE@
-
-#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
-# pragma reset woff 1174
-# pragma reset woff 1375
-#endif
-
-#if defined(_MSC_VER)
-# pragma warning(pop)
-#endif
-
-#endif
diff --git a/Source/kwsys/hashtable.hxx.in b/Source/kwsys/hashtable.hxx.in
deleted file mode 100644
index 8c4b0025f..000000000
--- a/Source/kwsys/hashtable.hxx.in
+++ /dev/null
@@ -1,995 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
-/*
- * Copyright (c) 1996
- * Silicon Graphics Computer Systems, Inc.
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Silicon Graphics makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- *
- * Copyright (c) 1994
- * Hewlett-Packard Company
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Hewlett-Packard Company makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-#ifdef __BORLANDC__
-# pragma warn - 8027 /* 'for' not inlined. */
-# pragma warn - 8026 /* 'exception' not inlined. */
-#endif
-
-#ifndef @KWSYS_NAMESPACE@_hashtable_hxx
-# define @KWSYS_NAMESPACE@_hashtable_hxx
-
-# include <@KWSYS_NAMESPACE@/Configure.hxx>
-
-# include <algorithm> // lower_bound
-# include <iterator> // iterator_traits
-# include <memory> // allocator
-# include <stddef.h> // size_t
-# include <utility> // pair
-# include <vector> // vector
-
-# if defined(_MSC_VER)
-# pragma warning(push)
-# pragma warning(disable : 4284)
-# pragma warning(disable : 4786)
-# pragma warning(disable : 4512) /* no assignment operator for class */
-# endif
-# if defined(__sgi) && !defined(__GNUC__)
-# pragma set woff 3970 /* pointer to int conversion */ 3321 3968
-# endif
-
-// In C++11, clang will warn about using dynamic exception specifications
-// as they are deprecated. But as this class is trying to faithfully
-// mimic unordered_set and unordered_map, we want to keep the 'throw()'
-// decorations below. So we suppress the warning.
-# if defined(__clang__) && defined(__has_warning)
-# if __has_warning("-Wdeprecated")
-# pragma clang diagnostic push
-# pragma clang diagnostic ignored "-Wdeprecated"
-# endif
-# endif
-
-namespace @KWSYS_NAMESPACE@ {
-
-template <class _Val>
-struct _Hashtable_node
-{
- _Hashtable_node* _M_next;
- _Val _M_val;
- void public_method_to_quiet_warning_about_all_methods_private();
-
-private:
- void operator=(_Hashtable_node<_Val> const&) = delete;
-};
-
-template <class _Val, class _Key, class _HashFcn, class _ExtractKey,
- class _EqualKey, class _Alloc = std::allocator<char> >
-class hashtable;
-
-template <class _Val, class _Key, class _HashFcn, class _ExtractKey,
- class _EqualKey, class _Alloc>
-struct _Hashtable_iterator;
-
-template <class _Val, class _Key, class _HashFcn, class _ExtractKey,
- class _EqualKey, class _Alloc>
-struct _Hashtable_const_iterator;
-
-template <class _Val, class _Key, class _HashFcn, class _ExtractKey,
- class _EqualKey, class _Alloc>
-struct _Hashtable_iterator
-{
- typedef hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>
- _Hashtable;
- typedef _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey,
- _Alloc>
- iterator;
- typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey,
- _EqualKey, _Alloc>
- const_iterator;
- typedef _Hashtable_node<_Val> _Node;
-
- typedef std::forward_iterator_tag iterator_category;
- typedef _Val value_type;
- typedef ptrdiff_t difference_type;
- typedef size_t size_type;
- typedef _Val& reference;
- typedef _Val* pointer;
-
- _Node* _M_cur;
- _Hashtable* _M_ht;
-
- _Hashtable_iterator(_Node* __n, _Hashtable* __tab)
- : _M_cur(__n)
- , _M_ht(__tab)
- {
- }
- _Hashtable_iterator() {}
- reference operator*() const { return _M_cur->_M_val; }
- pointer operator->() const { return &(operator*()); }
- iterator& operator++();
- iterator operator++(int);
- bool operator==(const iterator& __it) const { return _M_cur == __it._M_cur; }
- bool operator!=(const iterator& __it) const { return _M_cur != __it._M_cur; }
-};
-
-template <class _Val, class _Key, class _HashFcn, class _ExtractKey,
- class _EqualKey, class _Alloc>
-struct _Hashtable_const_iterator
-{
- typedef hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>
- _Hashtable;
- typedef _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey,
- _Alloc>
- iterator;
- typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey,
- _EqualKey, _Alloc>
- const_iterator;
- typedef _Hashtable_node<_Val> _Node;
-
- typedef std::forward_iterator_tag iterator_category;
- typedef _Val value_type;
- typedef ptrdiff_t difference_type;
- typedef size_t size_type;
- typedef const _Val& reference;
- typedef const _Val* pointer;
-
- const _Node* _M_cur;
- const _Hashtable* _M_ht;
-
- _Hashtable_const_iterator(const _Node* __n, const _Hashtable* __tab)
- : _M_cur(__n)
- , _M_ht(__tab)
- {
- }
- _Hashtable_const_iterator() {}
- _Hashtable_const_iterator(const iterator& __it)
- : _M_cur(__it._M_cur)
- , _M_ht(__it._M_ht)
- {
- }
- reference operator*() const { return _M_cur->_M_val; }
- pointer operator->() const { return &(operator*()); }
- const_iterator& operator++();
- const_iterator operator++(int);
- bool operator==(const const_iterator& __it) const
- {
- return _M_cur == __it._M_cur;
- }
- bool operator!=(const const_iterator& __it) const
- {
- return _M_cur != __it._M_cur;
- }
-};
-
-// Note: assumes long is at least 32 bits.
-enum
-{
- _stl_num_primes = 31
-};
-
-// create a function with a static local to that function that returns
-// the static
-static inline const unsigned long* get_stl_prime_list()
-{
-
- static const unsigned long _stl_prime_list[_stl_num_primes] = {
- 5ul, 11ul, 23ul, 53ul, 97ul,
- 193ul, 389ul, 769ul, 1543ul, 3079ul,
- 6151ul, 12289ul, 24593ul, 49157ul, 98317ul,
- 196613ul, 393241ul, 786433ul, 1572869ul, 3145739ul,
- 6291469ul, 12582917ul, 25165843ul, 50331653ul, 100663319ul,
- 201326611ul, 402653189ul, 805306457ul, 1610612741ul, 3221225473ul,
- 4294967291ul
- };
-
- return &_stl_prime_list[0];
-}
-
-static inline size_t _stl_next_prime(size_t __n)
-{
- const unsigned long* __first = get_stl_prime_list();
- const unsigned long* __last = get_stl_prime_list() + (int)_stl_num_primes;
- const unsigned long* pos = std::lower_bound(__first, __last, __n);
- return pos == __last ? *(__last - 1) : *pos;
-}
-
-// Forward declaration of operator==.
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-class hashtable;
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-bool operator==(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1,
- const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2);
-
-// Hashtables handle allocators a bit differently than other containers
-// do. If we're using standard-conforming allocators, then a hashtable
-// unconditionally has a member variable to hold its allocator, even if
-// it so happens that all instances of the allocator type are identical.
-// This is because, for hashtables, this extra storage is negligible.
-// Additionally, a base class wouldn't serve any other purposes; it
-// wouldn't, for example, simplify the exception-handling code.
-
-template <class _Val, class _Key, class _HashFcn, class _ExtractKey,
- class _EqualKey, class _Alloc>
-class hashtable
-{
-public:
- typedef _Key key_type;
- typedef _Val value_type;
- typedef _HashFcn hasher;
- typedef _EqualKey key_equal;
-
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
- typedef value_type& reference;
- typedef const value_type& const_reference;
-
- hasher hash_funct() const { return _M_hash; }
- key_equal key_eq() const { return _M_equals; }
-
-private:
- typedef _Hashtable_node<_Val> _Node;
-
-public:
- typedef typename _Alloc::template rebind<_Val>::other allocator_type;
- allocator_type get_allocator() const { return _M_node_allocator; }
-
-private:
- typedef
- typename _Alloc::template rebind<_Node>::other _M_node_allocator_type;
- typedef
- typename _Alloc::template rebind<_Node*>::other _M_node_ptr_allocator_type;
- typedef std::vector<_Node*, _M_node_ptr_allocator_type> _M_buckets_type;
-
-private:
- _M_node_allocator_type _M_node_allocator;
- hasher _M_hash;
- key_equal _M_equals;
- _ExtractKey _M_get_key;
- _M_buckets_type _M_buckets;
- size_type _M_num_elements;
-
- _Node* _M_get_node() { return _M_node_allocator.allocate(1); }
- void _M_put_node(_Node* __p) { _M_node_allocator.deallocate(__p, 1); }
-
-public:
- typedef _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey,
- _Alloc>
- iterator;
- typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey,
- _EqualKey, _Alloc>
- const_iterator;
-
- friend struct _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey,
- _EqualKey, _Alloc>;
- friend struct _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey,
- _EqualKey, _Alloc>;
-
-public:
- hashtable(size_type __n, const _HashFcn& __hf, const _EqualKey& __eql,
- const _ExtractKey& __ext,
- const allocator_type& __a = allocator_type())
- : _M_node_allocator(__a)
- , _M_hash(__hf)
- , _M_equals(__eql)
- , _M_get_key(__ext)
- , _M_buckets(__a)
- , _M_num_elements(0)
- {
- _M_initialize_buckets(__n);
- }
-
- hashtable(size_type __n, const _HashFcn& __hf, const _EqualKey& __eql,
- const allocator_type& __a = allocator_type())
- : _M_node_allocator(__a)
- , _M_hash(__hf)
- , _M_equals(__eql)
- , _M_get_key(_ExtractKey())
- , _M_buckets(__a)
- , _M_num_elements(0)
- {
- _M_initialize_buckets(__n);
- }
-
- hashtable(const hashtable& __ht)
- : _M_node_allocator(__ht.get_allocator())
- , _M_hash(__ht._M_hash)
- , _M_equals(__ht._M_equals)
- , _M_get_key(__ht._M_get_key)
- , _M_buckets(__ht.get_allocator())
- , _M_num_elements(0)
- {
- _M_copy_from(__ht);
- }
-
- hashtable& operator=(const hashtable& __ht)
- {
- if (&__ht != this) {
- clear();
- _M_hash = __ht._M_hash;
- _M_equals = __ht._M_equals;
- _M_get_key = __ht._M_get_key;
- _M_copy_from(__ht);
- }
- return *this;
- }
-
- ~hashtable() { clear(); }
-
- size_type size() const { return _M_num_elements; }
- size_type max_size() const { return size_type(-1); }
- bool empty() const { return size() == 0; }
-
- void swap(hashtable& __ht)
- {
- std::swap(_M_hash, __ht._M_hash);
- std::swap(_M_equals, __ht._M_equals);
- std::swap(_M_get_key, __ht._M_get_key);
- _M_buckets.swap(__ht._M_buckets);
- std::swap(_M_num_elements, __ht._M_num_elements);
- }
-
- iterator begin()
- {
- for (size_type __n = 0; __n < _M_buckets.size(); ++__n)
- if (_M_buckets[__n])
- return iterator(_M_buckets[__n], this);
- return end();
- }
-
- iterator end() { return iterator(nullptr, this); }
-
- const_iterator begin() const
- {
- for (size_type __n = 0; __n < _M_buckets.size(); ++__n)
- if (_M_buckets[__n])
- return const_iterator(_M_buckets[__n], this);
- return end();
- }
-
- const_iterator end() const { return const_iterator(nullptr, this); }
-
- friend bool operator==<>(const hashtable&, const hashtable&);
-
-public:
- size_type bucket_count() const { return _M_buckets.size(); }
-
- size_type max_bucket_count() const
- {
- return get_stl_prime_list()[(int)_stl_num_primes - 1];
- }
-
- size_type elems_in_bucket(size_type __bucket) const
- {
- size_type __result = 0;
- for (_Node* __cur = _M_buckets[__bucket]; __cur; __cur = __cur->_M_next)
- __result += 1;
- return __result;
- }
-
- std::pair<iterator, bool> insert_unique(const value_type& __obj)
- {
- resize(_M_num_elements + 1);
- return insert_unique_noresize(__obj);
- }
-
- iterator insert_equal(const value_type& __obj)
- {
- resize(_M_num_elements + 1);
- return insert_equal_noresize(__obj);
- }
-
- std::pair<iterator, bool> insert_unique_noresize(const value_type& __obj);
- iterator insert_equal_noresize(const value_type& __obj);
-
- template <class _InputIterator>
- void insert_unique(_InputIterator __f, _InputIterator __l)
- {
- insert_unique(
- __f, __l,
- typename std::iterator_traits<_InputIterator>::iterator_category());
- }
-
- template <class _InputIterator>
- void insert_equal(_InputIterator __f, _InputIterator __l)
- {
- insert_equal(
- __f, __l,
- typename std::iterator_traits<_InputIterator>::iterator_category());
- }
-
- template <class _InputIterator>
- void insert_unique(_InputIterator __f, _InputIterator __l,
- std::input_iterator_tag)
- {
- for (; __f != __l; ++__f)
- insert_unique(*__f);
- }
-
- template <class _InputIterator>
- void insert_equal(_InputIterator __f, _InputIterator __l,
- std::input_iterator_tag)
- {
- for (; __f != __l; ++__f)
- insert_equal(*__f);
- }
-
- template <class _ForwardIterator>
- void insert_unique(_ForwardIterator __f, _ForwardIterator __l,
- std::forward_iterator_tag)
- {
- size_type __n = 0;
- std::distance(__f, __l, __n);
- resize(_M_num_elements + __n);
- for (; __n > 0; --__n, ++__f)
- insert_unique_noresize(*__f);
- }
-
- template <class _ForwardIterator>
- void insert_equal(_ForwardIterator __f, _ForwardIterator __l,
- std::forward_iterator_tag)
- {
- size_type __n = 0;
- std::distance(__f, __l, __n);
- resize(_M_num_elements + __n);
- for (; __n > 0; --__n, ++__f)
- insert_equal_noresize(*__f);
- }
-
- reference find_or_insert(const value_type& __obj);
-
- iterator find(const key_type& __key)
- {
- size_type __n = _M_bkt_num_key(__key);
- _Node* __first;
- for (__first = _M_buckets[__n];
- __first && !_M_equals(_M_get_key(__first->_M_val), __key);
- __first = __first->_M_next) {
- }
- return iterator(__first, this);
- }
-
- const_iterator find(const key_type& __key) const
- {
- size_type __n = _M_bkt_num_key(__key);
- const _Node* __first;
- for (__first = _M_buckets[__n];
- __first && !_M_equals(_M_get_key(__first->_M_val), __key);
- __first = __first->_M_next) {
- }
- return const_iterator(__first, this);
- }
-
- size_type count(const key_type& __key) const
- {
- const size_type __n = _M_bkt_num_key(__key);
- size_type __result = 0;
-
- for (const _Node* __cur = _M_buckets[__n]; __cur; __cur = __cur->_M_next)
- if (_M_equals(_M_get_key(__cur->_M_val), __key))
- ++__result;
- return __result;
- }
-
- std::pair<iterator, iterator> equal_range(const key_type& __key);
-
- std::pair<const_iterator, const_iterator> equal_range(
- const key_type& __key) const;
-
- size_type erase(const key_type& __key);
- void erase(const iterator& __it);
- void erase(iterator __first, iterator __last);
-
- void erase(const const_iterator& __it);
- void erase(const_iterator __first, const_iterator __last);
-
- void resize(size_type __num_elements_hint);
- void clear();
-
-private:
- size_type _M_next_size(size_type __n) const { return _stl_next_prime(__n); }
-
- void _M_initialize_buckets(size_type __n)
- {
- const size_type __n_buckets = _M_next_size(__n);
- _M_buckets.reserve(__n_buckets);
- _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*)nullptr);
- _M_num_elements = 0;
- }
-
- size_type _M_bkt_num_key(const key_type& __key) const
- {
- return _M_bkt_num_key(__key, _M_buckets.size());
- }
-
- size_type _M_bkt_num(const value_type& __obj) const
- {
- return _M_bkt_num_key(_M_get_key(__obj));
- }
-
- size_type _M_bkt_num_key(const key_type& __key, size_t __n) const
- {
- return _M_hash(__key) % __n;
- }
-
- size_type _M_bkt_num(const value_type& __obj, size_t __n) const
- {
- return _M_bkt_num_key(_M_get_key(__obj), __n);
- }
-
- void construct(_Val* p, const _Val& v) { new (p) _Val(v); }
- void destroy(_Val* p)
- {
- (void)p;
- p->~_Val();
- }
-
- _Node* _M_new_node(const value_type& __obj)
- {
- _Node* __n = _M_get_node();
- __n->_M_next = nullptr;
- try {
- construct(&__n->_M_val, __obj);
- return __n;
- } catch (...) {
- _M_put_node(__n);
- throw;
- }
- }
-
- void _M_delete_node(_Node* __n)
- {
- destroy(&__n->_M_val);
- _M_put_node(__n);
- }
-
- void _M_erase_bucket(const size_type __n, _Node* __first, _Node* __last);
- void _M_erase_bucket(const size_type __n, _Node* __last);
-
- void _M_copy_from(const hashtable& __ht);
-};
-
-template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
- class _All>
-_Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>&
-_Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>::operator++()
-{
- const _Node* __old = _M_cur;
- _M_cur = _M_cur->_M_next;
- if (!_M_cur) {
- size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val);
- while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size())
- _M_cur = _M_ht->_M_buckets[__bucket];
- }
- return *this;
-}
-
-template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
- class _All>
-inline _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>
-_Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>::operator++(int)
-{
- iterator __tmp = *this;
- ++*this;
- return __tmp;
-}
-
-template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
- class _All>
-_Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>&
-_Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>::operator++()
-{
- const _Node* __old = _M_cur;
- _M_cur = _M_cur->_M_next;
- if (!_M_cur) {
- size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val);
- while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size())
- _M_cur = _M_ht->_M_buckets[__bucket];
- }
- return *this;
-}
-
-template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
- class _All>
-inline _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>
-_Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>::operator++(int)
-{
- const_iterator __tmp = *this;
- ++*this;
- return __tmp;
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-bool operator==(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1,
- const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2)
-{
- typedef typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_Node _Node;
- if (__ht1._M_buckets.size() != __ht2._M_buckets.size())
- return false;
- for (int __n = 0; __n < __ht1._M_buckets.size(); ++__n) {
- _Node* __cur1 = __ht1._M_buckets[__n];
- _Node* __cur2 = __ht2._M_buckets[__n];
- for (; __cur1 && __cur2 && __cur1->_M_val == __cur2->_M_val;
- __cur1 = __cur1->_M_next, __cur2 = __cur2->_M_next) {
- }
- if (__cur1 || __cur2)
- return false;
- }
- return true;
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-inline bool operator!=(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1,
- const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2)
-{
- return !(__ht1 == __ht2);
-}
-
-template <class _Val, class _Key, class _HF, class _Extract, class _EqKey,
- class _All>
-inline void swap(hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht1,
- hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht2)
-{
- __ht1.swap(__ht2);
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-std::pair<typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator, bool>
-hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::insert_unique_noresize(
- const value_type& __obj)
-{
- const size_type __n = _M_bkt_num(__obj);
- _Node* __first = _M_buckets[__n];
-
- for (_Node* __cur = __first; __cur; __cur = __cur->_M_next)
- if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj)))
- return std::pair<iterator, bool>(iterator(__cur, this), false);
-
- _Node* __tmp = _M_new_node(__obj);
- __tmp->_M_next = __first;
- _M_buckets[__n] = __tmp;
- ++_M_num_elements;
- return std::pair<iterator, bool>(iterator(__tmp, this), true);
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator
-hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::insert_equal_noresize(
- const value_type& __obj)
-{
- const size_type __n = _M_bkt_num(__obj);
- _Node* __first = _M_buckets[__n];
-
- for (_Node* __cur = __first; __cur; __cur = __cur->_M_next)
- if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) {
- _Node* __tmp = _M_new_node(__obj);
- __tmp->_M_next = __cur->_M_next;
- __cur->_M_next = __tmp;
- ++_M_num_elements;
- return iterator(__tmp, this);
- }
-
- _Node* __tmp = _M_new_node(__obj);
- __tmp->_M_next = __first;
- _M_buckets[__n] = __tmp;
- ++_M_num_elements;
- return iterator(__tmp, this);
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::reference
-hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::find_or_insert(
- const value_type& __obj)
-{
- resize(_M_num_elements + 1);
-
- size_type __n = _M_bkt_num(__obj);
- _Node* __first = _M_buckets[__n];
-
- for (_Node* __cur = __first; __cur; __cur = __cur->_M_next)
- if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj)))
- return __cur->_M_val;
-
- _Node* __tmp = _M_new_node(__obj);
- __tmp->_M_next = __first;
- _M_buckets[__n] = __tmp;
- ++_M_num_elements;
- return __tmp->_M_val;
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-std::pair<typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator,
- typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator>
-hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::equal_range(const key_type& __key)
-{
- typedef std::pair<iterator, iterator> _Pii;
- const size_type __n = _M_bkt_num_key(__key);
-
- for (_Node* __first = _M_buckets[__n]; __first; __first = __first->_M_next)
- if (_M_equals(_M_get_key(__first->_M_val), __key)) {
- for (_Node* __cur = __first->_M_next; __cur; __cur = __cur->_M_next)
- if (!_M_equals(_M_get_key(__cur->_M_val), __key))
- return _Pii(iterator(__first, this), iterator(__cur, this));
- for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m)
- if (_M_buckets[__m])
- return _Pii(iterator(__first, this),
- iterator(_M_buckets[__m], this));
- return _Pii(iterator(__first, this), end());
- }
- return _Pii(end(), end());
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-std::pair<typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::const_iterator,
- typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::const_iterator>
-hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::equal_range(
- const key_type& __key) const
-{
- typedef std::pair<const_iterator, const_iterator> _Pii;
- const size_type __n = _M_bkt_num_key(__key);
-
- for (const _Node* __first = _M_buckets[__n]; __first;
- __first = __first->_M_next) {
- if (_M_equals(_M_get_key(__first->_M_val), __key)) {
- for (const _Node* __cur = __first->_M_next; __cur;
- __cur = __cur->_M_next)
- if (!_M_equals(_M_get_key(__cur->_M_val), __key))
- return _Pii(const_iterator(__first, this),
- const_iterator(__cur, this));
- for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m)
- if (_M_buckets[__m])
- return _Pii(const_iterator(__first, this),
- const_iterator(_M_buckets[__m], this));
- return _Pii(const_iterator(__first, this), end());
- }
- }
- return _Pii(end(), end());
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::size_type
-hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::erase(const key_type& __key)
-{
- const size_type __n = _M_bkt_num_key(__key);
- _Node* __first = _M_buckets[__n];
- size_type __erased = 0;
-
- if (__first) {
- _Node* __cur = __first;
- _Node* __next = __cur->_M_next;
- while (__next) {
- if (_M_equals(_M_get_key(__next->_M_val), __key)) {
- __cur->_M_next = __next->_M_next;
- _M_delete_node(__next);
- __next = __cur->_M_next;
- ++__erased;
- --_M_num_elements;
- } else {
- __cur = __next;
- __next = __cur->_M_next;
- }
- }
- if (_M_equals(_M_get_key(__first->_M_val), __key)) {
- _M_buckets[__n] = __first->_M_next;
- _M_delete_node(__first);
- ++__erased;
- --_M_num_elements;
- }
- }
- return __erased;
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::erase(const iterator& __it)
-{
- _Node* __p = __it._M_cur;
- if (__p) {
- const size_type __n = _M_bkt_num(__p->_M_val);
- _Node* __cur = _M_buckets[__n];
-
- if (__cur == __p) {
- _M_buckets[__n] = __cur->_M_next;
- _M_delete_node(__cur);
- --_M_num_elements;
- } else {
- _Node* __next = __cur->_M_next;
- while (__next) {
- if (__next == __p) {
- __cur->_M_next = __next->_M_next;
- _M_delete_node(__next);
- --_M_num_elements;
- break;
- } else {
- __cur = __next;
- __next = __cur->_M_next;
- }
- }
- }
- }
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::erase(iterator __first,
- iterator __last)
-{
- size_type __f_bucket =
- __first._M_cur ? _M_bkt_num(__first._M_cur->_M_val) : _M_buckets.size();
- size_type __l_bucket =
- __last._M_cur ? _M_bkt_num(__last._M_cur->_M_val) : _M_buckets.size();
-
- if (__first._M_cur == __last._M_cur)
- return;
- else if (__f_bucket == __l_bucket)
- _M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur);
- else {
- _M_erase_bucket(__f_bucket, __first._M_cur, nullptr);
- for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n)
- _M_erase_bucket(__n, nullptr);
- if (__l_bucket != _M_buckets.size())
- _M_erase_bucket(__l_bucket, __last._M_cur);
- }
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-inline void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::erase(
- const_iterator __first, const_iterator __last)
-{
- erase(iterator(const_cast<_Node*>(__first._M_cur),
- const_cast<hashtable*>(__first._M_ht)),
- iterator(const_cast<_Node*>(__last._M_cur),
- const_cast<hashtable*>(__last._M_ht)));
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-inline void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::erase(
- const const_iterator& __it)
-{
- erase(iterator(const_cast<_Node*>(__it._M_cur),
- const_cast<hashtable*>(__it._M_ht)));
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::resize(
- size_type __num_elements_hint)
-{
- const size_type __old_n = _M_buckets.size();
- if (__num_elements_hint > __old_n) {
- const size_type __n = _M_next_size(__num_elements_hint);
- if (__n > __old_n) {
- _M_buckets_type __tmp(__n, (_Node*)(nullptr),
- _M_buckets.get_allocator());
- try {
- for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) {
- _Node* __first = _M_buckets[__bucket];
- while (__first) {
- size_type __new_bucket = _M_bkt_num(__first->_M_val, __n);
- _M_buckets[__bucket] = __first->_M_next;
- __first->_M_next = __tmp[__new_bucket];
- __tmp[__new_bucket] = __first;
- __first = _M_buckets[__bucket];
- }
- }
- _M_buckets.swap(__tmp);
- } catch (...) {
- for (size_type __bucket = 0; __bucket < __tmp.size(); ++__bucket) {
- while (__tmp[__bucket]) {
- _Node* __next = __tmp[__bucket]->_M_next;
- _M_delete_node(__tmp[__bucket]);
- __tmp[__bucket] = __next;
- }
- }
- throw;
- }
- }
- }
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_M_erase_bucket(
- const size_type __n, _Node* __first, _Node* __last)
-{
- _Node* __cur = _M_buckets[__n];
- if (__cur == __first)
- _M_erase_bucket(__n, __last);
- else {
- _Node* __next;
- for (__next = __cur->_M_next; __next != __first;
- __cur = __next, __next = __cur->_M_next)
- ;
- while (__next != __last) {
- __cur->_M_next = __next->_M_next;
- _M_delete_node(__next);
- __next = __cur->_M_next;
- --_M_num_elements;
- }
- }
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_M_erase_bucket(
- const size_type __n, _Node* __last)
-{
- _Node* __cur = _M_buckets[__n];
- while (__cur != __last) {
- _Node* __next = __cur->_M_next;
- _M_delete_node(__cur);
- __cur = __next;
- _M_buckets[__n] = __cur;
- --_M_num_elements;
- }
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::clear()
-{
- for (size_type __i = 0; __i < _M_buckets.size(); ++__i) {
- _Node* __cur = _M_buckets[__i];
- while (__cur != nullptr) {
- _Node* __next = __cur->_M_next;
- _M_delete_node(__cur);
- __cur = __next;
- }
- _M_buckets[__i] = nullptr;
- }
- _M_num_elements = 0;
-}
-
-template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_M_copy_from(
- const hashtable& __ht)
-{
- _M_buckets.clear();
- _M_buckets.reserve(__ht._M_buckets.size());
- _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*)nullptr);
- try {
- for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) {
- const _Node* __cur = __ht._M_buckets[__i];
- if (__cur) {
- _Node* __copy = _M_new_node(__cur->_M_val);
- _M_buckets[__i] = __copy;
-
- for (_Node* __next = __cur->_M_next; __next;
- __cur = __next, __next = __cur->_M_next) {
- __copy->_M_next = _M_new_node(__next->_M_val);
- __copy = __copy->_M_next;
- }
- }
- }
- _M_num_elements = __ht._M_num_elements;
- } catch (...) {
- clear();
- throw;
- }
-}
-
-} // namespace @KWSYS_NAMESPACE@
-
-// Undo warning suppression.
-# if defined(__clang__) && defined(__has_warning)
-# if __has_warning("-Wdeprecated")
-# pragma clang diagnostic pop
-# endif
-# endif
-
-# if defined(_MSC_VER)
-# pragma warning(pop)
-# endif
-
-#endif
diff --git a/Source/kwsys/kwsysPlatformTests.cmake b/Source/kwsys/kwsysPlatformTests.cmake
index 28d3f68e2..89be4b885 100644
--- a/Source/kwsys/kwsysPlatformTests.cmake
+++ b/Source/kwsys/kwsysPlatformTests.cmake
@@ -1,185 +1,185 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing#kwsys for details.
-SET(KWSYS_PLATFORM_TEST_FILE_C kwsysPlatformTestsC.c)
-SET(KWSYS_PLATFORM_TEST_FILE_CXX kwsysPlatformTestsCXX.cxx)
+set(KWSYS_PLATFORM_TEST_FILE_C kwsysPlatformTestsC.c)
+set(KWSYS_PLATFORM_TEST_FILE_CXX kwsysPlatformTestsCXX.cxx)
-MACRO(KWSYS_PLATFORM_TEST lang var description invert)
- IF(NOT DEFINED ${var}_COMPILED)
- MESSAGE(STATUS "${description}")
+macro(KWSYS_PLATFORM_TEST lang var description invert)
+ if(NOT DEFINED ${var}_COMPILED)
+ message(STATUS "${description}")
set(maybe_cxx_standard "")
if(CMAKE_VERSION VERSION_LESS 3.8 AND CMAKE_CXX_STANDARD)
set(maybe_cxx_standard "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
endif()
- TRY_COMPILE(${var}_COMPILED
+ try_compile(${var}_COMPILED
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS}
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=${KWSYS_PLATFORM_TEST_LINK_LIBRARIES}"
${maybe_cxx_standard}
OUTPUT_VARIABLE OUTPUT)
- IF(${var}_COMPILED)
- FILE(APPEND
+ if(${var}_COMPILED)
+ file(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"${description} compiled with the following output:\n${OUTPUT}\n\n")
- ELSE()
- FILE(APPEND
+ else()
+ file(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"${description} failed to compile with the following output:\n${OUTPUT}\n\n")
- ENDIF()
- IF(${invert} MATCHES INVERT)
- IF(${var}_COMPILED)
- MESSAGE(STATUS "${description} - no")
- ELSE()
- MESSAGE(STATUS "${description} - yes")
- ENDIF()
- ELSE()
- IF(${var}_COMPILED)
- MESSAGE(STATUS "${description} - yes")
- ELSE()
- MESSAGE(STATUS "${description} - no")
- ENDIF()
- ENDIF()
- ENDIF()
- IF(${invert} MATCHES INVERT)
- IF(${var}_COMPILED)
- SET(${var} 0)
- ELSE()
- SET(${var} 1)
- ENDIF()
- ELSE()
- IF(${var}_COMPILED)
- SET(${var} 1)
- ELSE()
- SET(${var} 0)
- ENDIF()
- ENDIF()
-ENDMACRO()
+ endif()
+ if(${invert} MATCHES INVERT)
+ if(${var}_COMPILED)
+ message(STATUS "${description} - no")
+ else()
+ message(STATUS "${description} - yes")
+ endif()
+ else()
+ if(${var}_COMPILED)
+ message(STATUS "${description} - yes")
+ else()
+ message(STATUS "${description} - no")
+ endif()
+ endif()
+ endif()
+ if(${invert} MATCHES INVERT)
+ if(${var}_COMPILED)
+ set(${var} 0)
+ else()
+ set(${var} 1)
+ endif()
+ else()
+ if(${var}_COMPILED)
+ set(${var} 1)
+ else()
+ set(${var} 0)
+ endif()
+ endif()
+endmacro()
-MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert)
- IF(NOT DEFINED ${var})
- MESSAGE(STATUS "${description}")
- TRY_RUN(${var} ${var}_COMPILED
+macro(KWSYS_PLATFORM_TEST_RUN lang var description invert)
+ if(NOT DEFINED ${var})
+ message(STATUS "${description}")
+ try_run(${var} ${var}_COMPILED
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS}
OUTPUT_VARIABLE OUTPUT)
# Note that ${var} will be a 0 return value on success.
- IF(${var}_COMPILED)
- IF(${var})
- FILE(APPEND
+ if(${var}_COMPILED)
+ if(${var})
+ file(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"${description} compiled but failed to run with the following output:\n${OUTPUT}\n\n")
- ELSE()
- FILE(APPEND
+ else()
+ file(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"${description} compiled and ran with the following output:\n${OUTPUT}\n\n")
- ENDIF()
- ELSE()
- FILE(APPEND
+ endif()
+ else()
+ file(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"${description} failed to compile with the following output:\n${OUTPUT}\n\n")
- SET(${var} -1 CACHE INTERNAL "${description} failed to compile.")
- ENDIF()
+ set(${var} -1 CACHE INTERNAL "${description} failed to compile.")
+ endif()
- IF(${invert} MATCHES INVERT)
- IF(${var}_COMPILED)
- IF(${var})
- MESSAGE(STATUS "${description} - yes")
- ELSE()
- MESSAGE(STATUS "${description} - no")
- ENDIF()
- ELSE()
- MESSAGE(STATUS "${description} - failed to compile")
- ENDIF()
- ELSE()
- IF(${var}_COMPILED)
- IF(${var})
- MESSAGE(STATUS "${description} - no")
- ELSE()
- MESSAGE(STATUS "${description} - yes")
- ENDIF()
- ELSE()
- MESSAGE(STATUS "${description} - failed to compile")
- ENDIF()
- ENDIF()
- ENDIF()
+ if(${invert} MATCHES INVERT)
+ if(${var}_COMPILED)
+ if(${var})
+ message(STATUS "${description} - yes")
+ else()
+ message(STATUS "${description} - no")
+ endif()
+ else()
+ message(STATUS "${description} - failed to compile")
+ endif()
+ else()
+ if(${var}_COMPILED)
+ if(${var})
+ message(STATUS "${description} - no")
+ else()
+ message(STATUS "${description} - yes")
+ endif()
+ else()
+ message(STATUS "${description} - failed to compile")
+ endif()
+ endif()
+ endif()
- IF(${invert} MATCHES INVERT)
- IF(${var}_COMPILED)
- IF(${var})
- SET(${var} 1)
- ELSE()
- SET(${var} 0)
- ENDIF()
- ELSE()
- SET(${var} 1)
- ENDIF()
- ELSE()
- IF(${var}_COMPILED)
- IF(${var})
- SET(${var} 0)
- ELSE()
- SET(${var} 1)
- ENDIF()
- ELSE()
- SET(${var} 0)
- ENDIF()
- ENDIF()
-ENDMACRO()
+ if(${invert} MATCHES INVERT)
+ if(${var}_COMPILED)
+ if(${var})
+ set(${var} 1)
+ else()
+ set(${var} 0)
+ endif()
+ else()
+ set(${var} 1)
+ endif()
+ else()
+ if(${var}_COMPILED)
+ if(${var})
+ set(${var} 0)
+ else()
+ set(${var} 1)
+ endif()
+ else()
+ set(${var} 0)
+ endif()
+ endif()
+endmacro()
-MACRO(KWSYS_PLATFORM_C_TEST var description invert)
- SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
- SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
+macro(KWSYS_PLATFORM_C_TEST var description invert)
+ set(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
+ set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
KWSYS_PLATFORM_TEST(C "${var}" "${description}" "${invert}")
- SET(KWSYS_PLATFORM_TEST_DEFINES)
- SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
-ENDMACRO()
+ set(KWSYS_PLATFORM_TEST_DEFINES)
+ set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
+endmacro()
-MACRO(KWSYS_PLATFORM_C_TEST_RUN var description invert)
- SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
- SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
+macro(KWSYS_PLATFORM_C_TEST_RUN var description invert)
+ set(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
+ set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
KWSYS_PLATFORM_TEST_RUN(C "${var}" "${description}" "${invert}")
- SET(KWSYS_PLATFORM_TEST_DEFINES)
- SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
-ENDMACRO()
+ set(KWSYS_PLATFORM_TEST_DEFINES)
+ set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
+endmacro()
-MACRO(KWSYS_PLATFORM_CXX_TEST var description invert)
- SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
- SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
- SET(KWSYS_PLATFORM_TEST_LINK_LIBRARIES ${KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES})
+macro(KWSYS_PLATFORM_CXX_TEST var description invert)
+ set(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
+ set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
+ set(KWSYS_PLATFORM_TEST_LINK_LIBRARIES ${KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES})
KWSYS_PLATFORM_TEST(CXX "${var}" "${description}" "${invert}")
- SET(KWSYS_PLATFORM_TEST_DEFINES)
- SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
- SET(KWSYS_PLATFORM_TEST_LINK_LIBRARIES)
-ENDMACRO()
+ set(KWSYS_PLATFORM_TEST_DEFINES)
+ set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
+ set(KWSYS_PLATFORM_TEST_LINK_LIBRARIES)
+endmacro()
-MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert)
- SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
- SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
+macro(KWSYS_PLATFORM_CXX_TEST_RUN var description invert)
+ set(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
+ set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
KWSYS_PLATFORM_TEST_RUN(CXX "${var}" "${description}" "${invert}")
- SET(KWSYS_PLATFORM_TEST_DEFINES)
- SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
-ENDMACRO()
+ set(KWSYS_PLATFORM_TEST_DEFINES)
+ set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
+endmacro()
#-----------------------------------------------------------------------------
# KWSYS_PLATFORM_INFO_TEST(lang var description)
#
# Compile test named by ${var} and store INFO strings extracted from binary.
-MACRO(KWSYS_PLATFORM_INFO_TEST lang var description)
+macro(KWSYS_PLATFORM_INFO_TEST lang var description)
# We can implement this macro on CMake 2.6 and above.
- IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
- SET(${var} "")
- ELSE()
+ if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
+ set(${var} "")
+ else()
# Choose a location for the result binary.
- SET(KWSYS_PLATFORM_INFO_FILE
+ set(KWSYS_PLATFORM_INFO_FILE
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${var}.bin)
# Compile the test binary.
- IF(NOT EXISTS ${KWSYS_PLATFORM_INFO_FILE})
- MESSAGE(STATUS "${description}")
- TRY_COMPILE(${var}_COMPILED
+ if(NOT EXISTS ${KWSYS_PLATFORM_INFO_FILE})
+ message(STATUS "${description}")
+ try_compile(${var}_COMPILED
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
COMPILE_DEFINITIONS -DTEST_${var}
@@ -188,29 +188,29 @@ MACRO(KWSYS_PLATFORM_INFO_TEST lang var description)
OUTPUT_VARIABLE OUTPUT
COPY_FILE ${KWSYS_PLATFORM_INFO_FILE}
)
- IF(${var}_COMPILED)
- FILE(APPEND
+ if(${var}_COMPILED)
+ file(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"${description} compiled with the following output:\n${OUTPUT}\n\n")
- ELSE()
- FILE(APPEND
+ else()
+ file(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"${description} failed to compile with the following output:\n${OUTPUT}\n\n")
- ENDIF()
- IF(${var}_COMPILED)
- MESSAGE(STATUS "${description} - compiled")
- ELSE()
- MESSAGE(STATUS "${description} - failed")
- ENDIF()
- ENDIF()
+ endif()
+ if(${var}_COMPILED)
+ message(STATUS "${description} - compiled")
+ else()
+ message(STATUS "${description} - failed")
+ endif()
+ endif()
# Parse info strings out of the compiled binary.
- IF(${var}_COMPILED)
- FILE(STRINGS ${KWSYS_PLATFORM_INFO_FILE} ${var} REGEX "INFO:[A-Za-z0-9]+\\[[^]]*\\]")
- ELSE()
- SET(${var} "")
- ENDIF()
+ if(${var}_COMPILED)
+ file(STRINGS ${KWSYS_PLATFORM_INFO_FILE} ${var} REGEX "INFO:[A-Za-z0-9]+\\[[^]]*\\]")
+ else()
+ set(${var} "")
+ endif()
- SET(KWSYS_PLATFORM_INFO_FILE)
- ENDIF()
-ENDMACRO()
+ set(KWSYS_PLATFORM_INFO_FILE)
+ endif()
+endmacro()
diff --git a/Source/kwsys/kwsysPlatformTestsC.c b/Source/kwsys/kwsysPlatformTestsC.c
index b0cf7ad3b..d44f7eb9c 100644
--- a/Source/kwsys/kwsysPlatformTestsC.c
+++ b/Source/kwsys/kwsysPlatformTestsC.c
@@ -69,40 +69,3 @@ int KWSYS_PLATFORM_TEST_C_MAIN()
return clock_gettime(CLOCK_MONOTONIC, &ts);
}
#endif
-
-#ifdef TEST_KWSYS_C_TYPE_MACROS
-char* info_macros =
-# if defined(__SIZEOF_SHORT__)
- "INFO:macro[__SIZEOF_SHORT__]\n"
-# endif
-# if defined(__SIZEOF_INT__)
- "INFO:macro[__SIZEOF_INT__]\n"
-# endif
-# if defined(__SIZEOF_LONG__)
- "INFO:macro[__SIZEOF_LONG__]\n"
-# endif
-# if defined(__SIZEOF_LONG_LONG__)
- "INFO:macro[__SIZEOF_LONG_LONG__]\n"
-# endif
-# if defined(__SHORT_MAX__)
- "INFO:macro[__SHORT_MAX__]\n"
-# endif
-# if defined(__INT_MAX__)
- "INFO:macro[__INT_MAX__]\n"
-# endif
-# if defined(__LONG_MAX__)
- "INFO:macro[__LONG_MAX__]\n"
-# endif
-# if defined(__LONG_LONG_MAX__)
- "INFO:macro[__LONG_LONG_MAX__]\n"
-# endif
- "";
-
-int KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv)
-{
- int require = 0;
- require += info_macros[argc];
- (void)argv;
- return require;
-}
-#endif
diff --git a/Source/kwsys/kwsysPlatformTestsCXX.cxx b/Source/kwsys/kwsysPlatformTestsCXX.cxx
index cfd5666f3..0bfa20ee1 100644
--- a/Source/kwsys/kwsysPlatformTestsCXX.cxx
+++ b/Source/kwsys/kwsysPlatformTestsCXX.cxx
@@ -1,36 +1,5 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
-#ifdef TEST_KWSYS_CXX_HAS_CSTDIO
-# include <cstdio>
-int main()
-{
- return 0;
-}
-#endif
-
-#ifdef TEST_KWSYS_CXX_HAS_LONG_LONG
-long long f(long long n)
-{
- return n;
-}
-int main()
-{
- long long n = 0;
- return static_cast<int>(f(n));
-}
-#endif
-
-#ifdef TEST_KWSYS_CXX_HAS___INT64
-__int64 f(__int64 n)
-{
- return n;
-}
-int main()
-{
- __int64 n = 0;
- return static_cast<int>(f(n));
-}
-#endif
#ifdef TEST_KWSYS_CXX_STAT_HAS_ST_MTIM
# include <sys/types.h>
@@ -60,82 +29,6 @@ int main()
}
#endif
-#ifdef TEST_KWSYS_CXX_SAME_LONG_AND___INT64
-void function(long**)
-{
-}
-int main()
-{
- __int64** p = 0;
- function(p);
- return 0;
-}
-#endif
-
-#ifdef TEST_KWSYS_CXX_SAME_LONG_LONG_AND___INT64
-void function(long long**)
-{
-}
-int main()
-{
- __int64** p = 0;
- function(p);
- return 0;
-}
-#endif
-
-#ifdef TEST_KWSYS_IOS_HAS_ISTREAM_LONG_LONG
-# include <iostream>
-int test_istream(std::istream& is, long long& x)
-{
- return (is >> x) ? 1 : 0;
-}
-int main()
-{
- long long x = 0;
- return test_istream(std::cin, x);
-}
-#endif
-
-#ifdef TEST_KWSYS_IOS_HAS_OSTREAM_LONG_LONG
-# include <iostream>
-int test_ostream(std::ostream& os, long long x)
-{
- return (os << x) ? 1 : 0;
-}
-int main()
-{
- long long x = 0;
- return test_ostream(std::cout, x);
-}
-#endif
-
-#ifdef TEST_KWSYS_IOS_HAS_ISTREAM___INT64
-# include <iostream>
-int test_istream(std::istream& is, __int64& x)
-{
- return (is >> x) ? 1 : 0;
-}
-int main()
-{
- __int64 x = 0;
- return test_istream(std::cin, x);
-}
-#endif
-
-#ifdef TEST_KWSYS_IOS_HAS_OSTREAM___INT64
-# include <iostream>
-int test_ostream(std::ostream& os, __int64 x)
-{
- return (os << x) ? 1 : 0;
-}
-int main()
-{
- __int64 x = 0;
- return test_ostream(std::cout, x);
-}
-#endif
-
#ifdef TEST_KWSYS_CXX_HAS_SETENV
# include <stdlib.h>
int main()
@@ -184,33 +77,6 @@ int main()
}
#endif
-#ifdef TEST_KWSYS_CXX_HAS_ATOLL
-# include <stdlib.h>
-int main()
-{
- const char* str = "1024";
- return static_cast<int>(atoll(str));
-}
-#endif
-
-#ifdef TEST_KWSYS_CXX_HAS_ATOL
-# include <stdlib.h>
-int main()
-{
- const char* str = "1024";
- return static_cast<int>(atol(str));
-}
-#endif
-
-#ifdef TEST_KWSYS_CXX_HAS__ATOI64
-# include <stdlib.h>
-int main()
-{
- const char* str = "1024";
- return static_cast<int>(_atoi64(str));
-}
-#endif
-
#ifdef TEST_KWSYS_CXX_HAS_UTIMES
# include <sys/time.h>
int main()
@@ -288,33 +154,6 @@ int main()
}
#endif
-#ifdef TEST_KWSYS_CXX_HAS_BORLAND_ASM
-int main()
-{
- int a = 1;
- __asm {
- xor EBX, EBX;
- mov a, EBX;
- }
-
- return a;
-}
-#endif
-
-#ifdef TEST_KWSYS_CXX_HAS_BORLAND_ASM_CPUID
-int main()
-{
- int a = 0;
- __asm {
- xor EAX, EAX;
- cpuid;
- mov a, EAX;
- }
-
- return a;
-}
-#endif
-
#ifdef TEST_KWSYS_STL_HAS_WSTRING
# include <string>
void f(std::wstring*)
diff --git a/Source/kwsys/testCommandLineArguments.cxx b/Source/kwsys/testCommandLineArguments.cxx
index 1778a9ba8..078675159 100644
--- a/Source/kwsys/testCommandLineArguments.cxx
+++ b/Source/kwsys/testCommandLineArguments.cxx
@@ -12,8 +12,8 @@
#include <iostream>
#include <vector>
-#include <stddef.h> /* size_t */
-#include <string.h> /* strcmp */
+#include <cstddef> /* size_t */
+#include <cstring> /* strcmp */
static void* random_ptr = reinterpret_cast<void*>(0x123);
@@ -98,7 +98,7 @@ int testCommandLineArguments(int argc, char* argv[])
std::vector<std::string> stl_strings_argument;
std::string valid_stl_strings[] = { "ken", "brad", "bill", "andy" };
- typedef kwsys::CommandLineArguments argT;
+ using argT = kwsys::CommandLineArguments;
arg.AddArgument("--some-int-variable", argT::SPACE_ARGUMENT,
&some_int_variable, "Set some random int variable");
diff --git a/Source/kwsys/testCommandLineArguments1.cxx b/Source/kwsys/testCommandLineArguments1.cxx
index 64561b1e3..2f6b73578 100644
--- a/Source/kwsys/testCommandLineArguments1.cxx
+++ b/Source/kwsys/testCommandLineArguments1.cxx
@@ -12,8 +12,8 @@
#include <iostream>
#include <vector>
-#include <assert.h> /* assert */
-#include <string.h> /* strcmp */
+#include <cassert> /* assert */
+#include <cstring> /* strcmp */
int testCommandLineArguments1(int argc, char* argv[])
{
@@ -25,7 +25,7 @@ int testCommandLineArguments1(int argc, char* argv[])
std::string p;
int res = 0;
- typedef kwsys::CommandLineArguments argT;
+ using argT = kwsys::CommandLineArguments;
arg.AddArgument("-n", argT::SPACE_ARGUMENT, &n, "Argument N");
arg.AddArgument("-m", argT::EQUAL_ARGUMENT, &m, "Argument M");
arg.AddBooleanArgument("-p", &p, "Argument P");
@@ -51,9 +51,7 @@ int testCommandLineArguments1(int argc, char* argv[])
std::cout << "Value of N: " << n << std::endl;
std::cout << "Value of M: " << m << std::endl;
std::cout << "Value of P: " << p << std::endl;
- if (m) {
- delete[] m;
- }
+ delete[] m;
char** newArgv = nullptr;
int newArgc = 0;
diff --git a/Source/kwsys/testDirectory.cxx b/Source/kwsys/testDirectory.cxx
index b1ab0c872..eb3ca3254 100644
--- a/Source/kwsys/testDirectory.cxx
+++ b/Source/kwsys/testDirectory.cxx
@@ -57,7 +57,11 @@ int _doLongPathTest()
Directory testdir;
// Set res to failure if the directory doesn't load
- res += !testdir.Load(testdirpath);
+ std::string errorMessage = "";
+ res += !testdir.Load(testdirpath, &errorMessage);
+ if (errorMessage != "") {
+ std::cerr << "Failed to list directory: " << errorMessage << std::endl;
+ }
// Increment res failure if the directory appears empty
res += testdir.GetNumberOfFiles() == 0;
// Increment res failures if the path has changed from
@@ -73,6 +77,34 @@ int _doLongPathTest()
return res;
}
+int _nonExistentDirectoryTest()
+{
+ using namespace kwsys;
+ int res = 0;
+ std::string testdirpath(TEST_SYSTEMTOOLS_BINARY_DIR
+ "/directory_testing/doesnt_exist/");
+ std::string errorMessage;
+ Directory testdir;
+
+ errorMessage = "foo";
+ // Increment res failure if directory lists
+ res += testdir.Load(testdirpath, &errorMessage);
+#if !defined(_WIN32) || defined(__CYGWIN__)
+ // Increment res failure if errorMessage is unmodified
+ res += (errorMessage == "foo");
+#endif
+
+ errorMessage = "foo";
+ // Increment res failure if directory has files
+ res += (testdir.GetNumberOfFilesInDirectory(testdirpath, &errorMessage) > 0);
+#if !defined(_WIN32) || defined(__CYGWIN__)
+ // Increment res failure if errorMessage is unmodified
+ res += (errorMessage == "foo");
+#endif
+
+ return res;
+}
+
int _copyDirectoryTest()
{
using namespace kwsys;
@@ -106,5 +138,6 @@ int _copyDirectoryTest()
int testDirectory(int, char* [])
{
- return _doLongPathTest() + _copyDirectoryTest();
+ return _doLongPathTest() + _nonExistentDirectoryTest() +
+ _copyDirectoryTest();
}
diff --git a/Source/kwsys/testDynamicLoader.cxx b/Source/kwsys/testDynamicLoader.cxx
index 2421ac0e1..703ad4dcd 100644
--- a/Source/kwsys/testDynamicLoader.cxx
+++ b/Source/kwsys/testDynamicLoader.cxx
@@ -25,7 +25,7 @@ static std::string GetLibName(const char* lname, const char* subdir = nullptr)
{
// Construct proper name of lib
std::string slname;
- slname = EXECUTABLE_OUTPUT_PATH;
+ slname = RUNTIME_OUTPUT_DIRECTORY;
if (subdir) {
slname += "/";
slname += subdir;
diff --git a/Source/kwsys/testDynload.c b/Source/kwsys/testDynload.c
index c49f747df..33a431e9d 100644
--- a/Source/kwsys/testDynload.c
+++ b/Source/kwsys/testDynload.c
@@ -8,6 +8,6 @@
DL_EXPORT int TestDynamicLoaderData = 0;
-DL_EXPORT void TestDynamicLoaderSymbolPointer()
+DL_EXPORT void TestDynamicLoaderSymbolPointer(void)
{
}
diff --git a/Source/kwsys/testEncoding.cxx b/Source/kwsys/testEncoding.cxx
index 988697bff..ee93e8d8d 100644
--- a/Source/kwsys/testEncoding.cxx
+++ b/Source/kwsys/testEncoding.cxx
@@ -10,10 +10,10 @@
#include KWSYS_HEADER(Encoding.h)
#include <algorithm>
+#include <clocale>
+#include <cstdlib>
+#include <cstring>
#include <iostream>
-#include <locale.h>
-#include <stdlib.h>
-#include <string.h>
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
@@ -59,7 +59,7 @@ static int testHelloWorldEncoding()
std::string str2 = kwsys::Encoding::ToNarrow(wstr);
wchar_t* c_wstr = kwsysEncoding_DupToWide(str.c_str());
char* c_str2 = kwsysEncoding_DupToNarrow(c_wstr);
- if (!wstr.empty() && (str != str2 || strcmp(c_str2, str.c_str()))) {
+ if (!wstr.empty() && (str != str2 || strcmp(c_str2, str.c_str()) != 0)) {
std::cout << "converted string was different: " << str2 << std::endl;
std::cout << "converted string was different: " << c_str2 << std::endl;
ret++;
@@ -85,7 +85,7 @@ static int testRobustEncoding()
std::wstring wstr = kwsys::Encoding::ToWide(cstr);
wstr = kwsys::Encoding::ToWide(nullptr);
- if (wstr != L"") {
+ if (!wstr.empty()) {
const wchar_t* wcstr = wstr.c_str();
std::cout << "ToWide(NULL) returned";
for (size_t i = 0; i < wstr.size(); i++) {
@@ -95,7 +95,7 @@ static int testRobustEncoding()
ret++;
}
wstr = kwsys::Encoding::ToWide("");
- if (wstr != L"") {
+ if (!wstr.empty()) {
const wchar_t* wcstr = wstr.c_str();
std::cout << "ToWide(\"\") returned";
for (size_t i = 0; i < wstr.size(); i++) {
@@ -113,13 +113,13 @@ static int testRobustEncoding()
#endif
std::string str = kwsys::Encoding::ToNarrow(nullptr);
- if (str != "") {
+ if (!str.empty()) {
std::cout << "ToNarrow(NULL) returned " << str << std::endl;
ret++;
}
str = kwsys::Encoding::ToNarrow(L"");
- if (wstr != L"") {
+ if (!wstr.empty()) {
std::cout << "ToNarrow(\"\") returned " << str << std::endl;
ret++;
}
@@ -140,14 +140,13 @@ static int testWithNulls()
strings.push_back(std::string("k") + '\0' + '\0');
strings.push_back(std::string("\0\0\0\0", 4) + "lmn" +
std::string("\0\0\0\0", 4));
- for (std::vector<std::string>::iterator it = strings.begin();
- it != strings.end(); ++it) {
- std::wstring wstr = kwsys::Encoding::ToWide(*it);
+ for (auto& string : strings) {
+ std::wstring wstr = kwsys::Encoding::ToWide(string);
std::string str = kwsys::Encoding::ToNarrow(wstr);
- std::string s(*it);
+ std::string s(string);
std::replace(s.begin(), s.end(), '\0', ' ');
- std::cout << "'" << s << "' (" << it->size() << ")" << std::endl;
- if (str != *it) {
+ std::cout << "'" << s << "' (" << string.size() << ")" << std::endl;
+ if (str != string) {
std::replace(str.begin(), str.end(), '\0', ' ');
std::cout << "string with null was different: '" << str << "' ("
<< str.size() << ")" << std::endl;
diff --git a/Source/kwsys/testFStream.cxx b/Source/kwsys/testFStream.cxx
index 5009e9887..afba9530e 100644
--- a/Source/kwsys/testFStream.cxx
+++ b/Source/kwsys/testFStream.cxx
@@ -7,10 +7,7 @@
#endif
#include KWSYS_HEADER(FStream.hxx)
-#include <string.h>
-#ifdef __BORLANDC__
-# include <mem.h> /* memcmp */
-#endif
+#include <cstring>
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
diff --git a/Source/kwsys/testHashSTL.cxx b/Source/kwsys/testHashSTL.cxx
deleted file mode 100644
index 4ed2f899d..000000000
--- a/Source/kwsys/testHashSTL.cxx
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
-#include "kwsysPrivate.h"
-#include KWSYS_HEADER(hash_map.hxx)
-#include KWSYS_HEADER(hash_set.hxx)
-
-// Work-around CMake dependency scanning limitation. This must
-// duplicate the above list of headers.
-#if 0
-# include "hash_map.hxx.in"
-# include "hash_set.hxx.in"
-#endif
-
-#include <iostream>
-
-#if defined(_MSC_VER)
-# pragma warning(disable : 4786)
-#endif
-
-#if defined(__sgi) && !defined(__GNUC__)
-# pragma set woff 1468 /* inline function cannot be explicitly instantiated \
- */
-#endif
-
-template class kwsys::hash_map<const char*, int>;
-template class kwsys::hash_set<int>;
-
-static bool test_hash_map()
-{
- typedef kwsys::hash_map<const char*, int> mtype;
- mtype m;
- const char* keys[] = { "hello", "world" };
- m[keys[0]] = 1;
- m.insert(mtype::value_type(keys[1], 2));
- int sum = 0;
- for (mtype::iterator mi = m.begin(); mi != m.end(); ++mi) {
- std::cout << "Found entry [" << mi->first << "," << mi->second << "]"
- << std::endl;
- sum += mi->second;
- }
- return sum == 3;
-}
-
-static bool test_hash_set()
-{
- typedef kwsys::hash_set<int> stype;
- stype s;
- s.insert(1);
- s.insert(2);
- int sum = 0;
- for (stype::iterator si = s.begin(); si != s.end(); ++si) {
- std::cout << "Found entry [" << *si << "]" << std::endl;
- sum += *si;
- }
- return sum == 3;
-}
-
-int testHashSTL(int, char* [])
-{
- bool result = true;
- result = test_hash_map() && result;
- result = test_hash_set() && result;
- return result ? 0 : 1;
-}
diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c
index 39aaa23ba..0c658f566 100644
--- a/Source/kwsys/testProcess.c
+++ b/Source/kwsys/testProcess.c
@@ -24,10 +24,6 @@
# include <unistd.h>
#endif
-#if defined(__BORLANDC__)
-# pragma warn - 8060 /* possibly incorrect assignment */
-#endif
-
/* Platform-specific sleep functions. */
#if defined(__BEOS__) && !defined(__ZETA__)
@@ -631,7 +627,8 @@ int main(int argc, const char* argv[])
}
fprintf(stderr, "Invalid test number %d.\n", n);
return 1;
- } else if (n >= 1 && n <= 10) {
+ }
+ if (n >= 1 && n <= 10) {
/* This is the parent process for a requested test number. */
int states[10] = {
kwsysProcess_State_Exited, kwsysProcess_State_Exited,
@@ -709,7 +706,8 @@ int main(int argc, const char* argv[])
free(argv0);
#endif
return r;
- } else if (argc > 2 && strcmp(argv[1], "0") == 0) {
+ }
+ if (argc > 2 && strcmp(argv[1], "0") == 0) {
/* This is the special debugging test to run a given command
line. */
const char** cmd = argv + 2;
@@ -720,9 +718,8 @@ int main(int argc, const char* argv[])
int r =
runChild(cmd, state, exception, value, 0, 1, 0, timeout, 0, 1, 0, 0, 0);
return r;
- } else {
- /* Improper usage. */
- fprintf(stdout, "Usage: %s <test number>\n", argv[0]);
- return 1;
}
+ /* Improper usage. */
+ fprintf(stdout, "Usage: %s <test number>\n", argv[0]);
+ return 1;
}
diff --git a/Source/kwsys/testSystemInformation.cxx b/Source/kwsys/testSystemInformation.cxx
index 154517eae..4f0c522e4 100644
--- a/Source/kwsys/testSystemInformation.cxx
+++ b/Source/kwsys/testSystemInformation.cxx
@@ -11,29 +11,13 @@
#include <iostream>
-#if defined(KWSYS_USE_LONG_LONG)
-# if defined(KWSYS_IOS_HAS_OSTREAM_LONG_LONG)
-# define iostreamLongLong(x) (x)
-# else
-# define iostreamLongLong(x) ((long)x)
-# endif
-#elif defined(KWSYS_USE___INT64)
-# if defined(KWSYS_IOS_HAS_OSTREAM___INT64)
-# define iostreamLongLong(x) (x)
-# else
-# define iostreamLongLong(x) ((long)x)
-# endif
-#else
-# error "No Long Long"
-#endif
-
#define printMethod(info, m) std::cout << #m << ": " << info.m() << "\n"
#define printMethod2(info, m, unit) \
std::cout << #m << ": " << info.m() << " " << unit << "\n"
#define printMethod3(info, m, unit) \
- std::cout << #m << ": " << iostreamLongLong(info.m) << " " << unit << "\n"
+ std::cout << #m << ": " << info.m << " " << unit << "\n"
int testSystemInformation(int, char* [])
{
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index 3f6eeb8c1..1d3461443 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -20,18 +20,18 @@
// left on disk.
#include <testSystemTools.h>
+#include <cstdlib> /* free */
+#include <cstring> /* strcmp */
#include <iostream>
#include <sstream>
-#include <stdlib.h> /* free */
-#include <string.h> /* strcmp */
#if defined(_WIN32) && !defined(__CYGWIN__)
-# include <io.h> /* _umask (MSVC) / umask (Borland) */
+# include <io.h> /* _umask (MSVC) */
# ifdef _MSC_VER
-# define umask _umask // Note this is still umask on Borland
+# define umask _umask
# endif
#endif
#include <sys/stat.h> /* umask (POSIX), _S_I* constants (Windows) */
-// Visual C++ does not define mode_t (note that Borland does, however).
+// Visual C++ does not define mode_t.
#if defined(_MSC_VER)
typedef unsigned short mode_t;
#endif
@@ -328,7 +328,14 @@ static bool CheckFileOperations()
}
// While we're at it, check proper TestFileAccess functionality.
- if (kwsys::SystemTools::TestFileAccess(testNewFile,
+ bool do_write_test = true;
+#if defined(__linux__)
+ // If we are running as root on linux ignore this check, as
+ // root can always write to files
+ do_write_test = (getuid() != 0);
+#endif
+ if (do_write_test &&
+ kwsys::SystemTools::TestFileAccess(testNewFile,
kwsys::TEST_FILE_WRITE)) {
std::cerr
<< "TestFileAccess incorrectly indicated that this is a writable file:"
@@ -500,7 +507,7 @@ static bool CheckStringOperations()
char* cres =
kwsys::SystemTools::AppendStrings("Mary Had A", " Little Lamb.");
- if (strcmp(cres, "Mary Had A Little Lamb.")) {
+ if (strcmp(cres, "Mary Had A Little Lamb.") != 0) {
std::cerr << "Problem with AppendStrings "
<< "\"Mary Had A\" \" Little Lamb.\"" << std::endl;
res = false;
@@ -508,7 +515,7 @@ static bool CheckStringOperations()
delete[] cres;
cres = kwsys::SystemTools::AppendStrings("Mary Had", " A ", "Little Lamb.");
- if (strcmp(cres, "Mary Had A Little Lamb.")) {
+ if (strcmp(cres, "Mary Had A Little Lamb.") != 0) {
std::cerr << "Problem with AppendStrings "
<< "\"Mary Had\" \" A \" \"Little Lamb.\"" << std::endl;
res = false;
@@ -522,7 +529,7 @@ static bool CheckStringOperations()
}
cres = kwsys::SystemTools::RemoveChars("Mary Had A Little Lamb.", "aeiou");
- if (strcmp(cres, "Mry Hd A Lttl Lmb.")) {
+ if (strcmp(cres, "Mry Hd A Lttl Lmb.") != 0) {
std::cerr << "Problem with RemoveChars "
<< "\"Mary Had A Little Lamb.\"" << std::endl;
res = false;
@@ -530,7 +537,7 @@ static bool CheckStringOperations()
delete[] cres;
cres = kwsys::SystemTools::RemoveCharsButUpperHex("Mary Had A Little Lamb.");
- if (strcmp(cres, "A")) {
+ if (strcmp(cres, "A") != 0) {
std::cerr << "Problem with RemoveCharsButUpperHex "
<< "\"Mary Had A Little Lamb.\"" << std::endl;
res = false;
@@ -539,7 +546,7 @@ static bool CheckStringOperations()
char* cres2 = strdup("Mary Had A Little Lamb.");
kwsys::SystemTools::ReplaceChars(cres2, "aeiou", 'X');
- if (strcmp(cres2, "MXry HXd A LXttlX LXmb.")) {
+ if (strcmp(cres2, "MXry HXd A LXttlX LXmb.") != 0) {
std::cerr << "Problem with ReplaceChars "
<< "\"Mary Had A Little Lamb.\"" << std::endl;
res = false;
@@ -561,7 +568,7 @@ static bool CheckStringOperations()
}
cres = kwsys::SystemTools::DuplicateString("Mary Had A Little Lamb.");
- if (strcmp(cres, "Mary Had A Little Lamb.")) {
+ if (strcmp(cres, "Mary Had A Little Lamb.") != 0) {
std::cerr << "Problem with DuplicateString "
<< "\"Mary Had A Little Lamb.\"" << std::endl;
res = false;
@@ -721,8 +728,7 @@ static std::string StringVectorToString(const std::vector<std::string>& vec)
{
std::stringstream ss;
ss << "vector(";
- for (std::vector<std::string>::const_iterator i = vec.begin();
- i != vec.end(); ++i) {
+ for (auto i = vec.begin(); i != vec.end(); ++i) {
if (i != vec.begin()) {
ss << ", ";
}
@@ -743,16 +749,16 @@ static bool CheckGetPath()
const char* registryPath = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MyApp; MyKey]";
std::vector<std::string> originalPaths;
- originalPaths.push_back(registryPath);
+ originalPaths.emplace_back(registryPath);
std::vector<std::string> expectedPaths;
- expectedPaths.push_back(registryPath);
+ expectedPaths.emplace_back(registryPath);
#ifdef _WIN32
expectedPaths.push_back("C:/Somewhere/something");
expectedPaths.push_back("D:/Temp");
#else
- expectedPaths.push_back("/Somewhere/something");
- expectedPaths.push_back("/tmp");
+ expectedPaths.emplace_back("/Somewhere/something");
+ expectedPaths.emplace_back("/tmp");
#endif
bool res = true;
@@ -817,7 +823,7 @@ static bool CheckFind()
}
std::vector<std::string> searchPaths;
- searchPaths.push_back(TEST_SYSTEMTOOLS_BINARY_DIR);
+ searchPaths.emplace_back(TEST_SYSTEMTOOLS_BINARY_DIR);
if (kwsys::SystemTools::FindFile(testFindFileName, searchPaths, true)
.empty()) {
std::cerr << "Problem with FindFile without system paths for: "
@@ -1086,6 +1092,70 @@ static bool CheckCopyFileIfDifferent()
return ret;
}
+static bool CheckURLParsing()
+{
+ bool ret = true;
+ std::string url = "http://user:pw@hostname:42/full/url.com";
+
+ std::string protocol, username, password, hostname, dataport, database;
+ kwsys::SystemTools::ParseURL(url, protocol, username, password, hostname,
+ dataport, database);
+ if (protocol != "http" || username != "user" || password != "pw" ||
+ hostname != "hostname" || dataport != "42" ||
+ database != "full/url.com") {
+ std::cerr << "Incorrect URL parsing" << std::endl;
+ ret = false;
+ }
+
+ std::string uri =
+ "file://hostname/path/to/"
+ "a%20file%20with%20str%C3%A0ng%C3%A8%20ch%40r%20and%20s%C2%B5aces";
+ kwsys::SystemTools::ParseURL(uri, protocol, username, password, hostname,
+ dataport, database, true);
+ if (protocol != "file" || hostname != "hostname" ||
+ database != "path/to/a file with stràngè ch@r and sµaces") {
+ std::cerr << "Incorrect URL parsing or decoding" << std::endl;
+ ret = false;
+ }
+ return ret;
+}
+
+static bool CheckSplitString()
+{
+ bool ret = true;
+
+ auto check_split = [](std::string const& input,
+ std::initializer_list<const char*> expected) -> bool {
+ auto const components = kwsys::SystemTools::SplitString(input, '/');
+ if (components.size() != expected.size()) {
+ std::cerr << "Incorrect split count for " << input << ": "
+ << components.size() << std::endl;
+ return false;
+ }
+ size_t i = 0;
+ for (auto& part : expected) {
+ if (components[i] != part) {
+ std::cerr << "Incorrect split component " << i << " for " << input
+ << ": " << components[i] << std::endl;
+ return false;
+ }
+ ++i;
+ }
+ return true;
+ };
+
+ // No separators
+ ret &= check_split("nosep", { "nosep" });
+ // Simple
+ ret &= check_split("first/second", { "first", "second" });
+ // Separator at beginning
+ ret &= check_split("/starts/sep", { "", "starts", "sep" });
+ // Separator at end
+ ret &= check_split("ends/sep/", { "ends", "sep", "" });
+
+ return ret;
+}
+
int testSystemTools(int, char* [])
{
bool res = true;
@@ -1133,5 +1203,9 @@ int testSystemTools(int, char* [])
res &= CheckCopyFileIfDifferent();
+ res &= CheckURLParsing();
+
+ res &= CheckSplitString();
+
return res ? 0 : 1;
}
diff --git a/Source/kwsys/testSystemTools.h.in b/Source/kwsys/testSystemTools.h.in
index 022e36e2f..e4b89a7c1 100644
--- a/Source/kwsys/testSystemTools.h.in
+++ b/Source/kwsys/testSystemTools.h.in
@@ -3,7 +3,7 @@
#ifndef @KWSYS_NAMESPACE@_testSystemtools_h
#define @KWSYS_NAMESPACE@_testSystemtools_h
-#define EXECUTABLE_OUTPUT_PATH "@CMAKE_CURRENT_BINARY_DIR@"
+#define RUNTIME_OUTPUT_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@"
#define TEST_SYSTEMTOOLS_SOURCE_DIR "@TEST_SYSTEMTOOLS_SOURCE_DIR@"
#define TEST_SYSTEMTOOLS_BINARY_DIR "@TEST_SYSTEMTOOLS_BINARY_DIR@"