diff options
Diffstat (limited to 'Source/kwsys')
-rw-r--r-- | Source/kwsys/Base64.c | 24 | ||||
-rw-r--r-- | Source/kwsys/Base64.h.in | 18 | ||||
-rw-r--r-- | Source/kwsys/CMakeLists.txt | 226 | ||||
-rw-r--r-- | Source/kwsys/CONTRIBUTING.rst | 35 | ||||
-rw-r--r-- | Source/kwsys/Directory.cxx | 23 | ||||
-rw-r--r-- | Source/kwsys/Directory.hxx.in | 2 | ||||
-rw-r--r-- | Source/kwsys/DynamicLoader.cxx | 66 | ||||
-rw-r--r-- | Source/kwsys/DynamicLoader.hxx.in | 15 | ||||
-rw-r--r-- | Source/kwsys/EncodingC.c | 4 | ||||
-rw-r--r-- | Source/kwsys/Glob.cxx | 2 | ||||
-rw-r--r-- | Source/kwsys/ProcessUNIX.c | 4 | ||||
-rw-r--r-- | Source/kwsys/README.txt | 2 | ||||
-rw-r--r-- | Source/kwsys/SharedForward.h.in | 16 | ||||
-rw-r--r-- | Source/kwsys/SystemInformation.cxx | 19 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 244 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.hxx.in | 51 | ||||
-rw-r--r-- | Source/kwsys/kwsysPlatformTests.cmake | 88 | ||||
-rw-r--r-- | Source/kwsys/kwsysPlatformTestsCXX.cxx | 4 | ||||
-rw-r--r-- | Source/kwsys/testSystemTools.cxx | 4 |
19 files changed, 517 insertions, 330 deletions
diff --git a/Source/kwsys/Base64.c b/Source/kwsys/Base64.c index d07bdd0..4b8ede2 100644 --- a/Source/kwsys/Base64.c +++ b/Source/kwsys/Base64.c @@ -115,10 +115,10 @@ void kwsysBase64_Encode1(const unsigned char *src, unsigned char *dest) actually knowing how much data to expect (if the input is not a multiple of 3 bytes then the extra padding needed to complete the encode 4 bytes will stop the decoding anyway). */ -unsigned long kwsysBase64_Encode(const unsigned char *input, - unsigned long length, - unsigned char *output, - int mark_end) +size_t kwsysBase64_Encode(const unsigned char *input, + size_t length, + unsigned char *output, + int mark_end) { const unsigned char *ptr = input; const unsigned char *end = input + length; @@ -157,7 +157,7 @@ unsigned long kwsysBase64_Encode(const unsigned char *input, optr += 4; } - return (unsigned long)(optr - output); + return (size_t)(optr - output); } /*--------------------------------------------------------------------------*/ @@ -207,10 +207,10 @@ int kwsysBase64_Decode3(const unsigned char *src, unsigned char *dest) 'length' parameter is ignored. This enables the caller to decode a stream without actually knowing how much decoded data to expect (of course, the buffer must be large enough). */ -unsigned long kwsysBase64_Decode(const unsigned char *input, - unsigned long length, - unsigned char *output, - unsigned long max_input_length) +size_t kwsysBase64_Decode(const unsigned char *input, + size_t length, + unsigned char *output, + size_t max_input_length) { const unsigned char *ptr = input; unsigned char *optr = output; @@ -226,7 +226,7 @@ unsigned long kwsysBase64_Decode(const unsigned char *input, optr += len; if(len < 3) { - return (unsigned long)(optr - output); + return (size_t)(optr - output); } ptr += 4; } @@ -240,7 +240,7 @@ unsigned long kwsysBase64_Decode(const unsigned char *input, optr += len; if(len < 3) { - return (unsigned long)(optr - output); + return (size_t)(optr - output); } ptr += 4; } @@ -275,5 +275,5 @@ unsigned long kwsysBase64_Decode(const unsigned char *input, } } - return (unsigned long)(optr - output); + return (size_t)(optr - output); } diff --git a/Source/kwsys/Base64.h.in b/Source/kwsys/Base64.h.in index 3468007..36ed3cc 100644 --- a/Source/kwsys/Base64.h.in +++ b/Source/kwsys/Base64.h.in @@ -14,6 +14,8 @@ #include <@KWSYS_NAMESPACE@/Configure.h> +#include <stddef.h> /* size_t */ + /* Redefine all public interface symbol names to be in the proper namespace. These macros are used internally to kwsys only, and are not visible to user code. Use kwsysHeaderDump.pl to reproduce @@ -68,10 +70,10 @@ kwsysEXPORT void kwsysBase64_Encode1(const unsigned char *src, * the extra padding needed to complete the encode 4 bytes will stop * the decoding anyway). */ -kwsysEXPORT unsigned long kwsysBase64_Encode(const unsigned char *input, - unsigned long length, - unsigned char *output, - int mark_end); +kwsysEXPORT size_t kwsysBase64_Encode(const unsigned char *input, + size_t length, + unsigned char *output, + int mark_end); /** * Decode 4 bytes into a 3 byte string. Returns the number of bytes @@ -92,10 +94,10 @@ kwsysEXPORT int kwsysBase64_Decode3(const unsigned char *src, * much decoded data to expect (of course, the buffer must be large * enough). */ -kwsysEXPORT unsigned long kwsysBase64_Decode(const unsigned char *input, - unsigned long length, - unsigned char *output, - unsigned long max_input_length); +kwsysEXPORT size_t kwsysBase64_Decode(const unsigned char *input, + size_t length, + unsigned char *output, + size_t max_input_length); #if defined(__cplusplus) } /* extern "C" */ diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 2067690..8069ee2 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -96,7 +96,7 @@ ENDIF() IF(NOT KWSYS_NAMESPACE) SET(KWSYS_NAMESPACE "kwsys") SET(KWSYS_STANDALONE 1) -ENDIF(NOT KWSYS_NAMESPACE) +ENDIF() #----------------------------------------------------------------------------- # The project name is that of the specified namespace. @@ -130,49 +130,49 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(KWSYS_USE_String 1) SET(KWSYS_USE_SystemInformation 1) SET(KWSYS_USE_CPU 1) -ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) +ENDIF() # Enforce component dependencies. IF(KWSYS_USE_SystemTools) SET(KWSYS_USE_Directory 1) SET(KWSYS_USE_FStream 1) SET(KWSYS_USE_Encoding 1) -ENDIF(KWSYS_USE_SystemTools) +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(KWSYS_USE_Glob) +ENDIF() IF(KWSYS_USE_Process) SET(KWSYS_USE_System 1) SET(KWSYS_USE_Encoding 1) -ENDIF(KWSYS_USE_Process) +ENDIF() IF(KWSYS_USE_SystemInformation) SET(KWSYS_USE_Process 1) -ENDIF(KWSYS_USE_SystemInformation) +ENDIF() IF(KWSYS_USE_System) SET(KWSYS_USE_Encoding 1) -ENDIF(KWSYS_USE_System) +ENDIF() IF(KWSYS_USE_Directory) SET(KWSYS_USE_Encoding 1) -ENDIF(KWSYS_USE_Directory) +ENDIF() IF(KWSYS_USE_FStream) SET(KWSYS_USE_Encoding 1) -ENDIF(KWSYS_USE_FStream) +ENDIF() # Setup the large file support default. IF(KWSYS_LFS_DISABLE) SET(KWSYS_LFS_REQUESTED 0) -ELSE(KWSYS_LFS_DISABLE) +ELSE() SET(KWSYS_LFS_REQUESTED 1) -ENDIF(KWSYS_LFS_DISABLE) +ENDIF() # Specify default 8 bit encoding for Windows IF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE) SET(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_ACP) -ENDIF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE) +ENDIF() # Enable testing if building standalone. IF(KWSYS_STANDALONE) @@ -180,8 +180,8 @@ IF(KWSYS_STANDALONE) MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH) IF(BUILD_TESTING) ENABLE_TESTING() - ENDIF(BUILD_TESTING) -ENDIF(KWSYS_STANDALONE) + ENDIF() +ENDIF() # Include helper macros. INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformTests.cmake) @@ -197,15 +197,15 @@ INCLUDE_REGULAR_EXPRESSION("^.*$") IF(NOT KWSYS_INSTALL_INCLUDE_DIR) STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_INCLUDE_DIR "${KWSYS_HEADER_INSTALL_DIR}") -ENDIF(NOT KWSYS_INSTALL_INCLUDE_DIR) +ENDIF() IF(NOT KWSYS_INSTALL_LIB_DIR) STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_LIB_DIR "${KWSYS_LIBRARY_INSTALL_DIR}") -ENDIF(NOT KWSYS_INSTALL_LIB_DIR) +ENDIF() IF(NOT KWSYS_INSTALL_BIN_DIR) STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_BIN_DIR "${KWSYS_LIBRARY_INSTALL_DIR}") -ENDIF(NOT KWSYS_INSTALL_BIN_DIR) +ENDIF() # Setup header install rules. SET(KWSYS_INSTALL_INCLUDE_OPTIONS) @@ -213,7 +213,7 @@ IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) SET(KWSYS_INSTALL_INCLUDE_OPTIONS ${KWSYS_INSTALL_INCLUDE_OPTIONS} COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT} ) -ENDIF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) +ENDIF() # Setup library install rules. SET(KWSYS_INSTALL_LIBRARY_RULE) @@ -230,7 +230,7 @@ IF(KWSYS_INSTALL_LIB_DIR) SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} ) - ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) + ENDIF() # Install the archive to the lib directory. SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} @@ -241,8 +241,8 @@ IF(KWSYS_INSTALL_LIB_DIR) SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT} ) - ENDIF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) -ENDIF(KWSYS_INSTALL_LIB_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} @@ -253,8 +253,8 @@ IF(KWSYS_INSTALL_BIN_DIR) SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} ) - ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) -ENDIF(KWSYS_INSTALL_BIN_DIR) + ENDIF() +ENDIF() # Do not support old KWSYS_*a_INSTALL_DIR variable names. SET(KWSYS_HEADER_INSTALL_DIR) @@ -266,7 +266,7 @@ STRING(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" IF(NOT KWSYS_IN_SOURCE_BUILD) CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsysPrivate.h ${PROJECT_BINARY_DIR}/kwsysPrivate.h COPYONLY IMMEDIATE) -ENDIF(NOT KWSYS_IN_SOURCE_BUILD) +ENDIF() # Select plugin module file name convention. IF(NOT KWSYS_DynamicLoader_PREFIX) @@ -280,7 +280,7 @@ 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(CMAKE_ANSI_CFLAGS) +ENDIF() #----------------------------------------------------------------------------- # Adjust compiler flags for some platforms. @@ -292,11 +292,11 @@ IF(NOT CMAKE_COMPILER_IS_GNUCXX) 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(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL) + ENDIF() IF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no_implicit_include") - ENDIF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE) - ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*") + ENDIF() + ENDIF() IF(CMAKE_SYSTEM MATCHES "HP-UX") SET(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p") IF(CMAKE_CXX_COMPILER_ID MATCHES "HP") @@ -306,8 +306,8 @@ IF(NOT CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98") ENDIF() ENDIF() - ENDIF(CMAKE_SYSTEM MATCHES "HP-UX") -ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) + ENDIF() +ENDIF() #----------------------------------------------------------------------------- # Configure Large File Support. @@ -327,11 +327,11 @@ IF(KWSYS_LFS_REQUESTED) IF(KWSYS_LFS_WORKS) SET(KWSYS_LFS_AVAILABLE 1) - ENDIF(KWSYS_LFS_WORKS) -ELSE(KWSYS_LFS_REQUESTED) + ENDIF() +ELSE() # Large File Support is not requested. SET(KWSYS_LFS_REQUESTED 0) -ENDIF(KWSYS_LFS_REQUESTED) +ENDIF() #----------------------------------------------------------------------------- # Configure the standard library header wrappers based on compiler's @@ -343,34 +343,34 @@ KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAVE_STD IF(KWSYS_IOS_FORCE_OLD) SET(KWSYS_IOS_USE_ANSI 0) -ELSE(KWSYS_IOS_FORCE_OLD) +ELSE() KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_ANSI "Checking whether ANSI stream headers are available" DIRECT) -ENDIF(KWSYS_IOS_FORCE_OLD) +ENDIF() IF(KWSYS_IOS_USE_ANSI) KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAVE_STD "Checking whether ANSI streams are in std namespace" DIRECT) KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_SSTREAM "Checking whether ANSI string stream is available" DIRECT) -ELSE(KWSYS_IOS_USE_ANSI) +ELSE() SET(KWSYS_IOS_HAVE_STD 0) SET(KWSYS_IOS_USE_SSTREAM 0) -ENDIF(KWSYS_IOS_USE_ANSI) +ENDIF() IF(KWSYS_IOS_USE_SSTREAM) SET(KWSYS_IOS_USE_STRSTREAM_H 0) SET(KWSYS_IOS_USE_STRSTREA_H 0) -ELSE(KWSYS_IOS_USE_SSTREAM) +ELSE() KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_STRSTREAM_H "Checking whether strstream.h is available" DIRECT) IF(KWSYS_IOS_USE_STRSTREAM_H) SET(KWSYS_IOS_USE_STRSTREA_H 0) - ELSE(KWSYS_IOS_USE_STRSTREAM_H) + ELSE() KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_STRSTREA_H "Checking whether strstrea.h is available" DIRECT) - ENDIF(KWSYS_IOS_USE_STRSTREAM_H) -ENDIF(KWSYS_IOS_USE_SSTREAM) + ENDIF() +ENDIF() KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_CSTDDEF "Checking whether header cstddef is available" DIRECT) @@ -384,16 +384,16 @@ KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_TRAITS IF(KWSYS_STL_HAS_ITERATOR_TRAITS) SET(KWSYS_STL_HAS_ITERATOR_CATEGORY 0) SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0) -ELSE(KWSYS_STL_HAS_ITERATOR_TRAITS) +ELSE() KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_CATEGORY "Checking whether stl has old iterator_category" DIRECT) IF(KWSYS_STL_HAS_ITERATOR_CATEGORY) SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0) - ELSE(KWSYS_STL_HAS_ITERATOR_CATEGORY) + ELSE() KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS___ITERATOR_CATEGORY "Checking whether stl has internal __iterator_category" DIRECT) - ENDIF(KWSYS_STL_HAS_ITERATOR_CATEGORY) -ENDIF(KWSYS_STL_HAS_ITERATOR_TRAITS) + ENDIF() +ENDIF() KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE "Checking whether stl has standard template allocator" DIRECT) IF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE) @@ -402,25 +402,25 @@ IF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE) "Checking for rebind member of stl allocator" DIRECT) KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT "Checking for non-standard argument to stl allocator<>::max_size" DIRECT) -ELSE(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE) +ELSE() KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE "Checking whether stl has old non-template allocator" DIRECT) SET(KWSYS_STL_HAS_ALLOCATOR_REBIND 0) SET(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT 0) -ENDIF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE) +ENDIF() KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_OBJECTS "Checking whether stl containers support allocator objects." DIRECT) IF(KWSYS_IOS_USE_ANSI AND NOT WATCOM) # ANSI streams always have string operators. SET(KWSYS_STL_STRING_HAVE_OSTREAM 1) SET(KWSYS_STL_STRING_HAVE_ISTREAM 1) -ELSE(KWSYS_IOS_USE_ANSI AND NOT WATCOM) +ELSE() # There may not be string operators for old streams. KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_OSTREAM "Checking whether stl string has ostream operator<<" DIRECT) KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_ISTREAM "Checking whether stl string has istream operator>>" DIRECT) -ENDIF(KWSYS_IOS_USE_ANSI AND NOT WATCOM) +ENDIF() SET(KWSYS_PLATFORM_CXX_TEST_DEFINES -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI} -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD}) @@ -440,7 +440,7 @@ KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP IF(UNIX) KWSYS_PLATFORM_CXX_TEST(KWSYS_STAT_HAS_ST_MTIM "Checking whether struct stat has st_mtim member" DIRECT) -ENDIF(UNIX) +ENDIF() # Check existence and uniqueness of long long and __int64. KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_LONG_LONG @@ -528,20 +528,20 @@ IF(KWSYS_USE_FundamentalType) IF(KWSYS_USE___INT64) KWSYS_PLATFORM_CXX_TEST(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE "Checking whether unsigned __int64 can convert to double" DIRECT) - ELSE(KWSYS_USE___INT64) + ELSE() SET(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE 1) - ENDIF(KWSYS_USE___INT64) + ENDIF() # Check signedness of "char" type. KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_CHAR_IS_SIGNED "Checking whether char is signed" DIRECT) -ENDIF(KWSYS_USE_FundamentalType) +ENDIF() 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(KWSYS_USE_Encoding) +ENDIF() IF(KWSYS_USE_IOStream) # Determine whether iostreams support long long. @@ -567,26 +567,26 @@ IF(KWSYS_USE_IOStream) SET(KWSYS_IOS_HAS_OSTREAM___INT64 0) ENDIF() SET(KWSYS_PLATFORM_CXX_TEST_DEFINES) -ENDIF(KWSYS_USE_IOStream) +ENDIF() IF(KWSYS_NAMESPACE MATCHES "^kwsys$") SET(KWSYS_NAME_IS_KWSYS 1) -ELSE(KWSYS_NAMESPACE MATCHES "^kwsys$") +ELSE() SET(KWSYS_NAME_IS_KWSYS 0) -ENDIF(KWSYS_NAMESPACE MATCHES "^kwsys$") +ENDIF() # Choose default shared/static build if not specified. IF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$") SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS}) -ENDIF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$") +ENDIF() IF(KWSYS_BUILD_SHARED) SET(KWSYS_BUILD_SHARED 1) SET(KWSYS_LIBRARY_TYPE SHARED) -ELSE(KWSYS_BUILD_SHARED) +ELSE() SET(KWSYS_BUILD_SHARED 0) SET(KWSYS_LIBRARY_TYPE STATIC) -ENDIF(KWSYS_BUILD_SHARED) +ENDIF() #----------------------------------------------------------------------------- # Configure some implementation details. @@ -789,7 +789,7 @@ ENDIF() # Choose a directory for the generated headers. IF(NOT KWSYS_HEADER_ROOT) SET(KWSYS_HEADER_ROOT "${PROJECT_BINARY_DIR}") -ENDIF(NOT KWSYS_HEADER_ROOT) +ENDIF() SET(KWSYS_HEADER_DIR "${KWSYS_HEADER_ROOT}/${KWSYS_NAMESPACE}") INCLUDE_DIRECTORIES(${KWSYS_HEADER_ROOT}) @@ -801,13 +801,13 @@ IF(KWSYS_INSTALL_DOC_DIR) SET(KWSYS_INSTALL_LICENSE_OPTIONS ${KWSYS_INSTALL_LICENSE_OPTIONS} COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} ) - ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) + ENDIF() # Install the license under the documentation directory. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt DESTINATION ${KWSYS_INSTALL_DOC_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_LICENSE_OPTIONS}) -ENDIF(KWSYS_INSTALL_DOC_DIR) +ENDIF() #----------------------------------------------------------------------------- # Create STL header wrappers to block warnings in the STL headers and @@ -844,10 +844,10 @@ FOREACH(header INSTALL(FILES ${KWSYS_HEADER_DIR}/stl/${header}.hxx DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl ${KWSYS_INSTALL_INCLUDE_OPTIONS}) - ENDIF(KWSYS_INSTALL_INCLUDE_DIR) - ELSE(KWSYS_STL_HEADER_EXTRA_${header}) + ENDIF() + ELSE() SET(KWSYS_STL_HEADER_EXTRA "") - ENDIF(KWSYS_STL_HEADER_EXTRA_${header}) + ENDIF() CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_stl.hxx.in ${KWSYS_HEADER_DIR}/stl/${header} @ONLY IMMEDIATE) @@ -857,8 +857,8 @@ FOREACH(header INSTALL(FILES ${KWSYS_HEADER_DIR}/stl/${header} DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl ${KWSYS_INSTALL_INCLUDE_OPTIONS}) - ENDIF(KWSYS_INSTALL_INCLUDE_DIR) -ENDFOREACH(header) + ENDIF() +ENDFOREACH() # Provide cstddef header. CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_cstddef.hxx.in @@ -868,7 +868,7 @@ IF(KWSYS_INSTALL_INCLUDE_DIR) INSTALL(FILES ${KWSYS_HEADER_DIR}/cstddef DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_INCLUDE_OPTIONS}) -ENDIF(KWSYS_INSTALL_INCLUDE_DIR) +ENDIF() #----------------------------------------------------------------------------- # Create streams header wrappers to give standard names by which they @@ -884,8 +884,8 @@ FOREACH(header iostream fstream sstream iosfwd) INSTALL(FILES ${KWSYS_HEADER_DIR}/ios/${header} DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/ios ${KWSYS_INSTALL_INCLUDE_OPTIONS}) - ENDIF(KWSYS_INSTALL_INCLUDE_DIR) -ENDFOREACH(header) + ENDIF() +ENDFOREACH() #----------------------------------------------------------------------------- # Build a list of classes and headers we need to implement the @@ -910,9 +910,9 @@ FOREACH(cpp ${cppclasses}) # Load component-specific CMake code. IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake) INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake) - ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake) - ENDIF(KWSYS_USE_${cpp}) -ENDFOREACH(cpp) + ENDIF() + ENDIF() +ENDFOREACH() # Add selected C components. FOREACH(c @@ -925,9 +925,9 @@ FOREACH(c # Load component-specific CMake code. IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake) INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${c}.cmake) - ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake) - ENDIF(KWSYS_USE_${c}) -ENDFOREACH(c) + ENDIF() + ENDIF() +ENDFOREACH() #----------------------------------------------------------------------------- # Build a list of sources for the library based on components that are @@ -940,11 +940,11 @@ IF(KWSYS_USE_Process) IF(NOT UNIX) # Use the Windows implementation. SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessWin32.c) - ELSE(NOT UNIX) + ELSE() # Use the UNIX implementation. SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c) - ENDIF(NOT UNIX) -ENDIF(KWSYS_USE_Process) + ENDIF() +ENDIF() # Add selected C sources. FOREACH(c Base64 Encoding MD5 Terminal System String) @@ -954,8 +954,8 @@ FOREACH(c Base64 Encoding MD5 Terminal System String) ELSE() LIST(APPEND KWSYS_C_SRCS ${c}.c) ENDIF() - ENDIF(KWSYS_USE_${c}) -ENDFOREACH(c) + ENDIF() +ENDFOREACH() # Configure headers of C++ classes and construct the list of sources. FOREACH(c ${KWSYS_CLASSES}) @@ -976,8 +976,8 @@ FOREACH(c ${KWSYS_CLASSES}) INSTALL(FILES ${KWSYS_HEADER_DIR}/${c}.hxx DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_INCLUDE_OPTIONS}) - ENDIF(KWSYS_INSTALL_INCLUDE_DIR) -ENDFOREACH(c) + ENDIF() +ENDFOREACH() # Configure C headers. FOREACH(h ${KWSYS_H_FILES}) @@ -991,8 +991,8 @@ FOREACH(h ${KWSYS_H_FILES}) INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.h DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_INCLUDE_OPTIONS}) - ENDIF(KWSYS_INSTALL_INCLUDE_DIR) -ENDFOREACH(h) + ENDIF() +ENDFOREACH() # Configure other C++ headers. FOREACH(h ${KWSYS_HXX_FILES}) @@ -1006,8 +1006,8 @@ FOREACH(h ${KWSYS_HXX_FILES}) INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.hxx DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_INCLUDE_OPTIONS}) - ENDIF(KWSYS_INSTALL_INCLUDE_DIR) -ENDFOREACH(h) + ENDIF() +ENDFOREACH() #----------------------------------------------------------------------------- # Add the library with the configured name and list of sources. @@ -1018,8 +1018,8 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) IF(KWSYS_USE_DynamicLoader) IF(UNIX) TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS}) - ENDIF(UNIX) - ENDIF(KWSYS_USE_DynamicLoader) + ENDIF() + ENDIF() IF(KWSYS_USE_SystemInformation) IF(WIN32) @@ -1044,13 +1044,13 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES ${KWSYS_PROPERTIES_CXX} ) - ENDIF(KWSYS_PROPERTIES_CXX) + ENDIF() # Create an install target for the library. IF(KWSYS_INSTALL_LIBRARY_RULE) INSTALL(TARGETS ${KWSYS_NAMESPACE} ${KWSYS_INSTALL_LIBRARY_RULE}) - ENDIF(KWSYS_INSTALL_LIBRARY_RULE) -ENDIF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) + ENDIF() +ENDIF() # Add a C-only library if requested. IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS) @@ -1062,20 +1062,20 @@ IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS) SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES ${KWSYS_PROPERTIES_C} ) - ENDIF(KWSYS_PROPERTIES_C) + ENDIF() # Create an install target for the library. IF(KWSYS_INSTALL_LIBRARY_RULE) INSTALL(TARGETS ${KWSYS_NAMESPACE}_c ${KWSYS_INSTALL_LIBRARY_RULE}) - ENDIF(KWSYS_INSTALL_LIBRARY_RULE) -ENDIF(KWSYS_ENABLE_C AND KWSYS_C_SRCS) + 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}") # Disable deprecation warnings for standard C functions. -IF(MSVC OR (WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$")) +IF(MSVC OR (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel")) ADD_DEFINITIONS( -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE @@ -1093,13 +1093,13 @@ IF(KWSYS_USE_String) # Activate code in "String.c". See the comment in the source. SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES COMPILE_FLAGS "-DKWSYS_STRING_C") -ENDIF(KWSYS_USE_String) +ENDIF() IF(KWSYS_USE_Encoding) # Set default 8 bit encoding in "EndcodingC.c". SET_PROPERTY(SOURCE EncodingC.c APPEND PROPERTY COMPILE_DEFINITIONS KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE}) -ENDIF(KWSYS_USE_Encoding) +ENDIF() #----------------------------------------------------------------------------- # Setup testing if not being built as part of another project. @@ -1109,7 +1109,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(EXEC_DIR "${CMAKE_CURRENT_BINARY_DIR}") IF(EXECUTABLE_OUTPUT_PATH) SET(EXEC_DIR "${EXECUTABLE_OUTPUT_PATH}") - ENDIF(EXECUTABLE_OUTPUT_PATH) + ENDIF() # C tests SET(KWSYS_C_TESTS @@ -1129,7 +1129,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) FOREACH(test ${KWSYS_C_TESTS}) 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(test) + ENDFOREACH() # C++ tests IF(NOT WATCOM) @@ -1137,7 +1137,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) testAutoPtr testHashSTL ) - ENDIF(NOT WATCOM) + ENDIF() SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testIOS testSystemTools @@ -1148,22 +1148,22 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testEncoding ) - ENDIF(KWSYS_STL_HAS_WSTRING) + ENDIF() IF(KWSYS_USE_FStream) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testFStream ) - ENDIF(KWSYS_USE_FStream) + ENDIF() IF(KWSYS_USE_SystemInformation) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation) - ENDIF(KWSYS_USE_SystemInformation) + ENDIF() IF(KWSYS_USE_DynamicLoader) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader) # 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_NAMESPACE}) - ENDIF(KWSYS_USE_DynamicLoader) + ENDIF() CREATE_TEST_SOURCELIST( KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx ${KWSYS_CXX_TESTS} @@ -1183,7 +1183,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) 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(CTEST_TEST_KWSYS) + ENDIF() SET(KWSYS_TEST_ARGS_testCommandLineArguments --another-bool-variable @@ -1216,7 +1216,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) FOREACH(test ${KWSYS_CXX_TESTS}) 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(test) + ENDFOREACH() # Process tests. ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestProcess testProcess.c) @@ -1224,15 +1224,15 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestProcess ${KWSYS_NAMESPACE}_c) IF(NOT CYGWIN) SET(KWSYS_TEST_PROCESS_7 7) - ENDIF(NOT CYGWIN) + ENDIF() FOREACH(n 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7}) 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(n) + ENDFOREACH() # Some Apple compilers produce bad optimizations in this source. - IF(APPLE AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|LLVM)$") + IF(APPLE AND CMAKE_C_COMPILER_ID MATCHES "^(GNU|LLVM)$") SET_SOURCE_FILES_PROPERTIES(testProcess.c PROPERTIES COMPILE_FLAGS -O0) ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "XL") # Tell IBM XL not to warn about our test infinite loop @@ -1263,5 +1263,5 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET_TESTS_PROPERTIES(${KWSYS_TEST_BOGUS_FAILURES} PROPERTIES WILL_FAIL ON) ENDIF() - ENDIF(BUILD_TESTING) -ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) + ENDIF() +ENDIF() diff --git a/Source/kwsys/CONTRIBUTING.rst b/Source/kwsys/CONTRIBUTING.rst new file mode 100644 index 0000000..e097b76 --- /dev/null +++ b/Source/kwsys/CONTRIBUTING.rst @@ -0,0 +1,35 @@ +Contributing to KWSys +********************* + +Overview +======== + +KWSys is kept in its own Git repository and shared by several projects +via copies in their source trees. Changes to KWSys should not be made +directly in a host project, except perhaps in maintenance branches. + +Please visit + + http://public.kitware.com/Wiki/KWSys/Git + +to contribute changes directly to KWSys upstream. Once changes are +reviewed, tested, and integrated there then the copies of KWSys within +dependent projects can be updated to get the changes. + +Issues +====== + +KWSys has no independent issue tracker. After encountering an issue +(bug) please try to submit a patch using the above instructions. +Otherwise please report the issue to the tracker for the project that +hosts the copy of KWSys in which the problem was found. + +License +======= + +We do not require any formal copyright assignment or contributor license +agreement. Any contributions intentionally sent upstream are presumed +to be offerred under terms of the OSI-approved BSD 3-clause License. +See `Copyright.txt`_ for details. + +.. _`Copyright.txt`: Copyright.txt diff --git a/Source/kwsys/Directory.cxx b/Source/kwsys/Directory.cxx index 741bcba..04b2866 100644 --- a/Source/kwsys/Directory.cxx +++ b/Source/kwsys/Directory.cxx @@ -203,13 +203,18 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const kwsys_stl::string& na #include <sys/types.h> #include <dirent.h> -/* There is a problem with the Portland compiler, large file -support and glibc/Linux system headers: -http://www.pgroup.com/userforum/viewtopic.php? -p=1992&sid=f16167f51964f1a68fe5041b8eb213b6 -*/ -#if defined(__PGI) && defined(__USE_FILE_OFFSET64) -# define dirent dirent64 +// PGI with glibc has trouble with dirent and large file support: +// http://www.pgroup.com/userforum/viewtopic.php? +// p=1992&sid=f16167f51964f1a68fe5041b8eb213b6 +// Work around the problem by mapping dirent the same way as readdir. +#if defined(__PGI) && defined(__GLIBC__) +# define kwsys_dirent_readdir dirent +# define kwsys_dirent_readdir64 dirent64 +# define kwsys_dirent kwsys_dirent_lookup(readdir) +# define kwsys_dirent_lookup(x) kwsys_dirent_lookup_delay(x) +# define kwsys_dirent_lookup_delay(x) kwsys_dirent_##x +#else +# define kwsys_dirent dirent #endif namespace KWSYS_NAMESPACE @@ -226,7 +231,7 @@ bool Directory::Load(const kwsys_stl::string& name) return 0; } - for (dirent* d = readdir(dir); d; d = readdir(dir) ) + for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir) ) { this->Internal->Files.push_back(d->d_name); } @@ -240,7 +245,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const kwsys_stl::string& na DIR* dir = opendir(name.c_str()); unsigned long count = 0; - for (dirent* d = readdir(dir); d; d = readdir(dir) ) + for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir) ) { count++; } diff --git a/Source/kwsys/Directory.hxx.in b/Source/kwsys/Directory.hxx.in index 0acb191..1bcf90e 100644 --- a/Source/kwsys/Directory.hxx.in +++ b/Source/kwsys/Directory.hxx.in @@ -18,7 +18,6 @@ /* Define these macros temporarily to keep the code readable. */ #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS # define kwsys_stl @KWSYS_NAMESPACE@_stl -# define kwsys_ios @KWSYS_NAMESPACE@_ios #endif namespace @KWSYS_NAMESPACE@ @@ -87,7 +86,6 @@ private: /* Undefine temporary macros. */ #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS # undef kwsys_stl -# undef kwsys_ios #endif #endif diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx index 44cf6af..66c7d57 100644 --- a/Source/kwsys/DynamicLoader.cxx +++ b/Source/kwsys/DynamicLoader.cxx @@ -40,9 +40,9 @@ namespace KWSYS_NAMESPACE { //---------------------------------------------------------------------------- -DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname ) { - return shl_load(libname, BIND_DEFERRED | DYNAMIC_PATH, 0L); + return shl_load(libname.c_str(), BIND_DEFERRED | DYNAMIC_PATH, 0L); } //---------------------------------------------------------------------------- @@ -53,7 +53,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) //---------------------------------------------------------------------------- DynamicLoader::SymbolPointer -DynamicLoader::GetSymbolAddress(DynamicLoader::LibraryHandle lib, const char* sym) +DynamicLoader::GetSymbolAddress(DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym) { void* addr; int status; @@ -62,7 +62,7 @@ DynamicLoader::GetSymbolAddress(DynamicLoader::LibraryHandle lib, const char* sy * TYPE_DATA Look for a symbol in the data segment (for example, variables). * TYPE_UNDEFINED Look for any symbol. */ - status = shl_findsym (&lib, sym, TYPE_UNDEFINED, &addr); + status = shl_findsym (&lib, sym.c_str(), TYPE_UNDEFINED, &addr); void* result = (status < 0) ? (void*)0 : addr; // Hack to cast pointer-to-data to pointer-to-function. @@ -111,18 +111,18 @@ namespace KWSYS_NAMESPACE { //---------------------------------------------------------------------------- -DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname ) { NSObjectFileImageReturnCode rc; NSObjectFileImage image = 0; - rc = NSCreateObjectFileImageFromFile(libname, &image); + rc = NSCreateObjectFileImageFromFile(libname.c_str(), &image); // rc == NSObjectFileImageInappropriateFile when trying to load a dylib file if( rc != NSObjectFileImageSuccess ) { return 0; } - NSModule handle = NSLinkModule(image, libname, + NSModule handle = NSLinkModule(image, libname.c_str(), NSLINKMODULE_OPTION_BINDNOW|NSLINKMODULE_OPTION_RETURN_ON_ERROR); NSDestroyObjectFileImage(image); return handle; @@ -142,14 +142,14 @@ int DynamicLoader::CloseLibrary( DynamicLoader::LibraryHandle lib) //---------------------------------------------------------------------------- DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( - DynamicLoader::LibraryHandle lib, const char* sym) + DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym) { void *result=0; // Need to prepend symbols with '_' on Apple-gcc compilers - size_t len = strlen(sym); + size_t len = sym.size(); char *rsym = new char[len + 1 + 1]; strcpy(rsym, "_"); - strcat(rsym+1, sym); + strcat(rsym+1, sym.c_str()); NSSymbol symbol = NSLookupSymbolInModule(lib, rsym); if(symbol) @@ -183,13 +183,13 @@ namespace KWSYS_NAMESPACE { //---------------------------------------------------------------------------- -DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname) +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname) { DynamicLoader::LibraryHandle lh; - int length = MultiByteToWideChar(CP_UTF8, 0, libname, -1, NULL, 0); + int length = MultiByteToWideChar(CP_UTF8, 0, libname.c_str(), -1, NULL, 0); wchar_t* wchars = new wchar_t[length+1]; wchars[0] = '\0'; - MultiByteToWideChar(CP_UTF8, 0, libname, -1, wchars, length); + MultiByteToWideChar(CP_UTF8, 0, libname.c_str(), -1, wchars, length); lh = LoadLibraryW(wchars); delete [] wchars; return lh; @@ -203,7 +203,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) //---------------------------------------------------------------------------- DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( - DynamicLoader::LibraryHandle lib, const char* sym) + DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym) { // TODO: The calling convention affects the name of the symbol. We // should have a tool to help get the symbol with the desired @@ -230,12 +230,12 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( void *result; #if defined(__BORLANDC__) || defined(__WATCOMC__) // Need to prepend symbols with '_' - size_t len = strlen(sym); + size_t len = sym.size(); char *rsym = new char[len + 1 + 1]; strcpy(rsym, "_"); - strcat(rsym, sym); + strcat(rsym, sym.c_str()); #else - const char *rsym = sym; + const char *rsym = sym.c_str(); #endif result = (void*)GetProcAddress(lib, rsym); #if defined(__BORLANDC__) || defined(__WATCOMC__) @@ -298,11 +298,11 @@ namespace KWSYS_NAMESPACE static image_id last_dynamic_err = B_OK; //---------------------------------------------------------------------------- -DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname ) { // image_id's are integers, errors are negative. Add one just in case we // get a valid image_id of zero (is that even possible?). - image_id rc = load_add_on(libname); + image_id rc = load_add_on(libname.c_str()); if (rc < 0) { last_dynamic_err = rc; @@ -336,7 +336,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) //---------------------------------------------------------------------------- DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( - DynamicLoader::LibraryHandle lib, const char* sym) + DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym) { // Hack to cast pointer-to-data to pointer-to-function. union @@ -356,7 +356,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( // !!! FIXME: BeOS can do function-only lookups...does this ever // !!! FIXME: actually _want_ a data symbol lookup, or was this union // !!! FIXME: a leftover of dlsym()? (s/ANY/TEXT for functions only). - status_t rc = get_image_symbol(lib-1,sym,B_SYMBOL_TYPE_ANY,&result.pvoid); + status_t rc = get_image_symbol(lib-1,sym.c_str(),B_SYMBOL_TYPE_ANY,&result.pvoid); if (rc != B_OK) { last_dynamic_err = rc; @@ -389,7 +389,7 @@ namespace KWSYS_NAMESPACE { //---------------------------------------------------------------------------- -DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname ) { return 0; } @@ -407,7 +407,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) //---------------------------------------------------------------------------- DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( - DynamicLoader::LibraryHandle lib, const char* sym) + DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym) { return 0; } @@ -433,12 +433,12 @@ namespace KWSYS_NAMESPACE { //---------------------------------------------------------------------------- -DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname ) { - char *name = (char *)calloc(1, strlen(libname) + 1); + char *name = (char *)calloc(1, libname.size() + 1); dld_init(program_invocation_name); - strncpy(name, libname, strlen(libname)); - dld_link(libname); + strncpy(name, libname.c_str(), libname.size()); + dld_link(libname.c_str()); return (void *)name; } @@ -452,7 +452,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) //---------------------------------------------------------------------------- DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( - DynamicLoader::LibraryHandle lib, const char* sym) + DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym) { // Hack to cast pointer-to-data to pointer-to-function. union @@ -460,7 +460,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( void* pvoid; DynamicLoader::SymbolPointer psym; } result; - result.pvoid = dld_get_symbol(sym); + result.pvoid = dld_get_symbol(sym.c_str()); return result.psym; } @@ -485,9 +485,9 @@ namespace KWSYS_NAMESPACE { //---------------------------------------------------------------------------- -DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname ) { - return dlopen(libname, RTLD_LAZY); + return dlopen(libname.c_str(), RTLD_LAZY); } //---------------------------------------------------------------------------- @@ -504,7 +504,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) //---------------------------------------------------------------------------- DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( - DynamicLoader::LibraryHandle lib, const char* sym) + DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym) { // Hack to cast pointer-to-data to pointer-to-function. union @@ -512,7 +512,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( void* pvoid; DynamicLoader::SymbolPointer psym; } result; - result.pvoid = dlsym(lib, sym); + result.pvoid = dlsym(lib, sym.c_str()); return result.psym; } diff --git a/Source/kwsys/DynamicLoader.hxx.in b/Source/kwsys/DynamicLoader.hxx.in index 64468ec..75811ab 100644 --- a/Source/kwsys/DynamicLoader.hxx.in +++ b/Source/kwsys/DynamicLoader.hxx.in @@ -13,6 +13,7 @@ #define @KWSYS_NAMESPACE@_DynamicLoader_hxx #include <@KWSYS_NAMESPACE@/Configure.h> +#include <@KWSYS_NAMESPACE@/stl/string> #if defined(__hpux) #include <dl.h> @@ -27,6 +28,11 @@ #include <be/kernel/image.h> #endif +/* Define these macros temporarily to keep the code readable. */ +#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS +# define kwsys_stl @KWSYS_NAMESPACE@_stl +#endif + namespace @KWSYS_NAMESPACE@ { /** \class DynamicLoader @@ -77,14 +83,14 @@ public: /** Load a dynamic library into the current process. * The returned LibraryHandle can be used to access the symbols in the * library. */ - static LibraryHandle OpenLibrary(const char*); + static LibraryHandle OpenLibrary(const kwsys_stl::string&); /** Attempt to detach a dynamic library from the * process. A value of true is returned if it is sucessful. */ static int CloseLibrary(LibraryHandle); /** Find the address of the symbol in the given library. */ - static SymbolPointer GetSymbolAddress(LibraryHandle, const char*); + static SymbolPointer GetSymbolAddress(LibraryHandle, const kwsys_stl::string&); /** Return the default module prefix for the current platform. */ static const char* LibPrefix() { return "@KWSYS_DynamicLoader_PREFIX@"; } @@ -98,4 +104,9 @@ public: } // namespace @KWSYS_NAMESPACE@ +/* Undefine temporary macros. */ +#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS +# undef kwsys_stl +#endif + #endif diff --git a/Source/kwsys/EncodingC.c b/Source/kwsys/EncodingC.c index cda78e2..ba2cec2 100644 --- a/Source/kwsys/EncodingC.c +++ b/Source/kwsys/EncodingC.c @@ -44,7 +44,7 @@ wchar_t* kwsysEncoding_DupToWide(const char* str) size_t length = kwsysEncoding_mbstowcs(NULL, str, 0) + 1; if(length > 0) { - ret = malloc((length)*sizeof(wchar_t)); + ret = (wchar_t*)malloc((length)*sizeof(wchar_t)); ret[0] = 0; kwsysEncoding_mbstowcs(ret, str, length); } @@ -71,7 +71,7 @@ char* kwsysEncoding_DupToNarrow(const wchar_t* str) size_t length = kwsysEncoding_wcstombs(0, str, 0) + 1; if(length > 0) { - ret = malloc(length); + ret = (char*)malloc(length); ret[0] = 0; kwsysEncoding_wcstombs(ret, str, length); } diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx index 0916d2e..5a96aed 100644 --- a/Source/kwsys/Glob.cxx +++ b/Source/kwsys/Glob.cxx @@ -501,7 +501,7 @@ void Glob::AddFile(kwsys_stl::vector<kwsys_stl::string>& files, const kwsys_stl: { if ( !this->Relative.empty() ) { - files.push_back(kwsys::SystemTools::RelativePath(this->Relative.c_str(), file.c_str())); + files.push_back(kwsys::SystemTools::RelativePath(this->Relative, file)); } else { diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index ca9d424..1be6d02 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -547,7 +547,7 @@ int kwsysProcess_SetPipeFile(kwsysProcess* cp, int prPipe, const char* file) } if(file) { - *pfile = malloc(strlen(file)+1); + *pfile = (char*)malloc(strlen(file)+1); if(!*pfile) { return 0; @@ -1468,7 +1468,7 @@ static int kwsysProcessInitialize(kwsysProcess* cp) cp->RealWorkingDirectoryLength = 4096; #endif cp->RealWorkingDirectory = - malloc((size_t)(cp->RealWorkingDirectoryLength)); + (char*)malloc((size_t)(cp->RealWorkingDirectoryLength)); if(!cp->RealWorkingDirectory) { return 0; diff --git a/Source/kwsys/README.txt b/Source/kwsys/README.txt index ba03f8d..b8191f7 100644 --- a/Source/kwsys/README.txt +++ b/Source/kwsys/README.txt @@ -8,3 +8,5 @@ details. You are probably reading this file in the source tree of a surrounding project. In that case, see "../README.kwsys" for details of using KWSys in your project. + +See CONTRIBUTING.rst for instructions to contribute KWSys changes. diff --git a/Source/kwsys/SharedForward.h.in b/Source/kwsys/SharedForward.h.in index c6f345f..f22fa58 100644 --- a/Source/kwsys/SharedForward.h.in +++ b/Source/kwsys/SharedForward.h.in @@ -65,6 +65,15 @@ See the comments below for specific explanations of each macro. */ +/* Disable -Wcast-qual warnings since they are too hard to fix in a + cross-platform way. */ +#if defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wcast-qual") +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wcast-qual" +# endif +#endif + /*--------------------------------------------------------------------------*/ /* Full path to the directory in which this executable is built. Do @@ -917,6 +926,13 @@ static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in) return 1; } +/* Restore warning stack. */ +#if defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wcast-qual") +# pragma clang diagnostic pop +# endif +#endif + #else # error "@KWSYS_NAMESPACE@/SharedForward.h should be included only once." #endif diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index c4aeb47..3d5e728 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -443,7 +443,7 @@ public: }; protected: - // Functions. + // For windows bool RetrieveCPUFeatures(); bool RetrieveCPUIdentity(); bool RetrieveCPUCacheDetails(); @@ -457,6 +457,7 @@ protected: bool RetrieveClassicalCPUIdentity(); bool RetrieveExtendedCPUIdentity(); + // Processor information Manufacturer ChipManufacturer; CPUFeatures Features; ID ChipID; @@ -464,11 +465,11 @@ protected: unsigned int NumberOfLogicalCPU; unsigned int NumberOfPhysicalCPU; - int CPUCount(); + int CPUCount(); // For windows unsigned char LogicalCPUPerPhysicalCPU(); - unsigned char GetAPICId(); + unsigned char GetAPICId(); // For windows bool IsHyperThreadingSupported(); - static LongLong GetCyclesDifference(DELAY_FUNC, unsigned int); + static LongLong GetCyclesDifference(DELAY_FUNC, unsigned int); // For windows // For Linux and Cygwin, /proc/cpuinfo formats are slightly different bool RetreiveInformationFromCpuInfoFile(); @@ -3753,9 +3754,9 @@ bool SystemInformationImplementation::QueryWindowsMemory() } # define MEM_VAL(value) ull##value # endif - tv = ms.MEM_VAL(TotalVirtual); + tv = ms.MEM_VAL(TotalPageFile); tp = ms.MEM_VAL(TotalPhys); - av = ms.MEM_VAL(AvailVirtual); + av = ms.MEM_VAL(AvailPageFile); ap = ms.MEM_VAL(AvailPhys); this->TotalVirtualMemory = tv>>10>>10; this->TotalPhysicalMemory = tp>>10>>10; @@ -5156,7 +5157,7 @@ bool SystemInformationImplementation::QueryOSInformation() } } - sprintf (operatingSystem, "%s (Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); + sprintf (operatingSystem, "%ls (Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); this->OSVersion = operatingSystem; } else @@ -5205,7 +5206,7 @@ bool SystemInformationImplementation::QueryOSInformation() if (osvi.dwMajorVersion <= 4) { // NB: NT 4.0 and earlier. - sprintf (operatingSystem, "version %ld.%ld %s (Build %ld)", + sprintf (operatingSystem, "version %ld.%ld %ls (Build %ld)", osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.szCSDVersion, @@ -5236,7 +5237,7 @@ bool SystemInformationImplementation::QueryOSInformation() else { // Windows 2000 and everything else. - sprintf (operatingSystem,"%s (Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); + sprintf (operatingSystem,"%ls (Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); this->OSVersion = operatingSystem; } break; diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index b1221e3..c2b6097 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -16,6 +16,14 @@ # define _XOPEN_SOURCE_EXTENDED #endif +#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) +# define KWSYS_WINDOWS_DIRS +#else +# if defined(__SUNPRO_CC) +# include <fcntl.h> +# endif +#endif + #include "kwsysPrivate.h" #include KWSYS_HEADER(RegularExpression.hxx) #include KWSYS_HEADER(SystemTools.hxx) @@ -205,8 +213,7 @@ static time_t windows_filetime_to_posix_time(const FILETIME& ft) } #endif -#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) - +#ifdef KWSYS_WINDOWS_DIRS #include <wctype.h> inline int Mkdir(const kwsys_stl::string& dir) @@ -222,7 +229,7 @@ inline int Rmdir(const kwsys_stl::string& dir) inline const char* Getcwd(char* buf, unsigned int len) { std::vector<wchar_t> w_buf(len); - if(const wchar_t* ret = _wgetcwd(&w_buf[0], len)) + if(_wgetcwd(&w_buf[0], len)) { // make sure the drive letter is capital if(wcslen(&w_buf[0]) > 1 && w_buf[1] == L':') @@ -385,6 +392,11 @@ const char* SystemTools::GetEnv(const char* key) return getenv(key); } +const char* SystemTools::GetEnv(const kwsys_stl::string& key) +{ + return SystemTools::GetEnv(key.c_str()); +} + bool SystemTools::GetEnv(const char* key, kwsys_stl::string& result) { const char* v = getenv(key); @@ -399,6 +411,11 @@ bool SystemTools::GetEnv(const char* key, kwsys_stl::string& result) } } +bool SystemTools::GetEnv(const kwsys_stl::string& key, kwsys_stl::string& result) +{ + return SystemTools::GetEnv(key.c_str(), result); +} + //---------------------------------------------------------------------------- #if defined(__CYGWIN__) || defined(__GLIBC__) @@ -410,27 +427,28 @@ bool SystemTools::GetEnv(const char* key, kwsys_stl::string& result) #if KWSYS_CXX_HAS_UNSETENV /* unsetenv("A") removes A from the environment. On older platforms it returns void instead of int. */ -static int kwsysUnPutEnv(const char* env) +static int kwsysUnPutEnv(const kwsys_stl::string& env) { - if(const char* eq = strchr(env, '=')) + size_t pos = env.find('='); + if(pos != env.npos) { - std::string name(env, eq-env); + std::string name = env.substr(0, pos); unsetenv(name.c_str()); } else { - unsetenv(env); + unsetenv(env.c_str()); } return 0; } #elif defined(KWSYS_PUTENV_EMPTY) || defined(KWSYS_PUTENV_NAME) /* putenv("A=") or putenv("A") removes A from the environment. */ -static int kwsysUnPutEnv(const char* env) +static int kwsysUnPutEnv(const kwsys_stl::string& env) { int err = 0; - const char* eq = strchr(env, '='); - size_t const len = eq? (size_t)(eq-env) : strlen(env); + size_t pos = env.find('='); + size_t const len = pos == env.npos ? env.size() : pos; # ifdef KWSYS_PUTENV_EMPTY size_t const sz = len + 2; # else @@ -442,7 +460,7 @@ static int kwsysUnPutEnv(const char* env) { return -1; } - strncpy(buf, env, len); + strncpy(buf, env.c_str(), len); # ifdef KWSYS_PUTENV_EMPTY buf[len] = '='; buf[len+1] = 0; @@ -471,17 +489,17 @@ static int kwsysUnPutEnv(const char* env) #else /* Manipulate the "environ" global directly. */ -static int kwsysUnPutEnv(const char* env) +static int kwsysUnPutEnv(const kwsys_stl::string& env) { - const char* eq = strchr(env, '='); - size_t const len = eq? (size_t)(eq-env) : strlen(env); + size_t pos = env.find('='); + size_t const len = pos == env.npos ? env.size() : pos; int in = 0; int out = 0; while(environ[in]) { if(strlen(environ[in]) > len && environ[in][len] == '=' && - strncmp(env, environ[in], len) == 0) + strncmp(env.c_str(), environ[in], len) == 0) { ++in; } @@ -504,12 +522,13 @@ static int kwsysUnPutEnv(const char* env) /* setenv("A", "B", 1) will set A=B in the environment and makes its own copies of the strings. */ -bool SystemTools::PutEnv(const char* env) +bool SystemTools::PutEnv(const kwsys_stl::string& env) { - if(const char* eq = strchr(env, '=')) + size_t pos = env.find('='); + if(pos != env.npos) { - std::string name(env, eq-env); - return setenv(name.c_str(), eq+1, 1) == 0; + std::string name = env.substr(0, pos); + return setenv(name.c_str(), env.c_str() + pos + 1, 1) == 0; } else { @@ -517,7 +536,7 @@ bool SystemTools::PutEnv(const char* env) } } -bool SystemTools::UnPutEnv(const char* env) +bool SystemTools::UnPutEnv(const kwsys_stl::string& env) { return kwsysUnPutEnv(env) == 0; } @@ -603,14 +622,14 @@ public: static kwsysEnv kwsysEnvInstance; -bool SystemTools::PutEnv(const char* env) +bool SystemTools::PutEnv(const kwsys_stl::string& env) { - return kwsysEnvInstance.Put(env); + return kwsysEnvInstance.Put(env.c_str()); } -bool SystemTools::UnPutEnv(const char* env) +bool SystemTools::UnPutEnv(const kwsys_stl::string& env) { - return kwsysEnvInstance.UnPut(env); + return kwsysEnvInstance.UnPut(env.c_str()); } #endif @@ -689,8 +708,35 @@ bool SystemTools::MakeDirectory(const kwsys_stl::string& path) // replace replace with with as many times as it shows up in source. // write the result into source. void SystemTools::ReplaceString(kwsys_stl::string& source, - const char* replace, - const char* with) + const kwsys_stl::string& replace, + const kwsys_stl::string& with) +{ + // do while hangs if replaceSize is 0 + if (replace.empty()) + { + return; + } + + SystemTools::ReplaceString(source, replace.c_str(), replace.size(), with); +} + +void SystemTools::ReplaceString(kwsys_stl::string& source, + const char* replace, + const char* with) +{ + // do while hangs if replaceSize is 0 + if (!*replace) + { + return; + } + + SystemTools::ReplaceString(source, replace, strlen(replace), with ? with : ""); +} + +void SystemTools::ReplaceString(kwsys_stl::string& source, + const char* replace, + size_t replaceSize, + const kwsys_stl::string& with) { const char *src = source.c_str(); char *searchPos = const_cast<char *>(strstr(src,replace)); @@ -702,12 +748,6 @@ void SystemTools::ReplaceString(kwsys_stl::string& source, } // perform replacements until done - size_t replaceSize = strlen(replace); - // do while hangs if replaceSize is 0 - if(replaceSize == 0) - { - return; - } char *orig = strdup(src); char *currentPos = orig; searchPos = searchPos - src + orig; @@ -739,20 +779,20 @@ void SystemTools::ReplaceString(kwsys_stl::string& source, #endif #if defined(_WIN32) && !defined(__CYGWIN__) -static bool SystemToolsParseRegistryKey(const char* key, +static bool SystemToolsParseRegistryKey(const kwsys_stl::string& key, HKEY& primaryKey, kwsys_stl::string& second, kwsys_stl::string& valuename) { kwsys_stl::string primary = key; - size_t start = primary.find("\\"); + size_t start = primary.find('\\'); if (start == kwsys_stl::string::npos) { return false; } - size_t valuenamepos = primary.find(";"); + size_t valuenamepos = primary.find(';'); if (valuenamepos != kwsys_stl::string::npos) { valuename = primary.substr(valuenamepos+1); @@ -810,7 +850,7 @@ static DWORD SystemToolsMakeRegistryMode(DWORD mode, #if defined(_WIN32) && !defined(__CYGWIN__) bool -SystemTools::GetRegistrySubKeys(const char *key, +SystemTools::GetRegistrySubKeys(const kwsys_stl::string& key, kwsys_stl::vector<kwsys_stl::string>& subkeys, KeyWOW64 view) { @@ -849,7 +889,7 @@ SystemTools::GetRegistrySubKeys(const char *key, return true; } #else -bool SystemTools::GetRegistrySubKeys(const char *, +bool SystemTools::GetRegistrySubKeys(const kwsys_stl::string&, kwsys_stl::vector<kwsys_stl::string>&, KeyWOW64) { @@ -865,7 +905,7 @@ bool SystemTools::GetRegistrySubKeys(const char *, // => will return the data of the "Root" value of the key #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, +bool SystemTools::ReadRegistryValue(const kwsys_stl::string& key, kwsys_stl::string &value, KeyWOW64 view) { bool valueset = false; @@ -922,7 +962,7 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, return valueset; } #else -bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &, +bool SystemTools::ReadRegistryValue(const kwsys_stl::string&, kwsys_stl::string &, KeyWOW64) { return false; @@ -938,7 +978,8 @@ bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &, // => will set the data of the "Root" value of the key #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::WriteRegistryValue(const char *key, const char *value, +bool SystemTools::WriteRegistryValue(const kwsys_stl::string& key, + const kwsys_stl::string& value, KeyWOW64 view) { HKEY primaryKey = HKEY_CURRENT_USER; @@ -978,7 +1019,7 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value, return false; } #else -bool SystemTools::WriteRegistryValue(const char *, const char *, KeyWOW64) +bool SystemTools::WriteRegistryValue(const kwsys_stl::string&, const kwsys_stl::string&, KeyWOW64) { return false; } @@ -992,7 +1033,7 @@ bool SystemTools::WriteRegistryValue(const char *, const char *, KeyWOW64) // => will delete the data of the "Root" value of the key #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) +bool SystemTools::DeleteRegistryValue(const kwsys_stl::string& key, KeyWOW64 view) { HKEY primaryKey = HKEY_CURRENT_USER; kwsys_stl::string second; @@ -1023,7 +1064,7 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) return false; } #else -bool SystemTools::DeleteRegistryValue(const char *, KeyWOW64) +bool SystemTools::DeleteRegistryValue(const kwsys_stl::string&, KeyWOW64) { return false; } @@ -2245,12 +2286,13 @@ bool SystemTools::CopyFileAlways(const kwsys_stl::string& source, const kwsys_st SystemTools::MakeDirectory(destination_dir); // Open files - -#if defined(_WIN32) || defined(__CYGWIN__) - kwsys::ifstream fin(source.c_str(), - kwsys_ios::ios::binary | kwsys_ios::ios::in); +#if defined(_WIN32) + kwsys::ifstream fin(Encoding::ToNarrow( + SystemTools::ConvertToWindowsExtendedPath(source)).c_str(), + kwsys_ios::ios::in | kwsys_ios_binary); #else - kwsys::ifstream fin(source.c_str()); + kwsys::ifstream fin(source.c_str(), + kwsys_ios::ios::in | kwsys_ios_binary); #endif if(!fin) { @@ -2263,12 +2305,13 @@ bool SystemTools::CopyFileAlways(const kwsys_stl::string& source, const kwsys_st // that do not allow file removal can be modified. SystemTools::RemoveFile(real_destination); -#if defined(_WIN32) || defined(__CYGWIN__) - kwsys::ofstream fout(real_destination.c_str(), - kwsys_ios::ios::binary | kwsys_ios::ios::out | kwsys_ios::ios::trunc); +#if defined(_WIN32) + kwsys::ofstream fout(Encoding::ToNarrow( + SystemTools::ConvertToWindowsExtendedPath(real_destination)).c_str(), + kwsys_ios::ios::out | kwsys_ios::ios::trunc | kwsys_ios_binary); #else kwsys::ofstream fout(real_destination.c_str(), - kwsys_ios::ios::out | kwsys_ios::ios::trunc); + kwsys_ios::ios::out | kwsys_ios::ios::trunc | kwsys_ios_binary); #endif if(!fout) { @@ -2379,7 +2422,7 @@ bool SystemTools::CopyADirectory(const kwsys_stl::string& source, const kwsys_st // return size of file; also returns zero if no file exists -unsigned long SystemTools::FileLength(const char* filename) +unsigned long SystemTools::FileLength(const kwsys_stl::string& filename) { unsigned long length = 0; #ifdef _WIN32 @@ -2397,7 +2440,7 @@ unsigned long SystemTools::FileLength(const char* filename) } #else struct stat fs; - if (stat(filename, &fs) == 0) + if (stat(filename.c_str(), &fs) == 0) { length = static_cast<unsigned long>(fs.st_size); } @@ -2663,7 +2706,7 @@ size_t SystemTools::GetMaximumFilePathLength() * found. Otherwise, the empty string is returned. */ kwsys_stl::string SystemTools -::FindName(const char* name, +::FindName(const kwsys_stl::string& name, const kwsys_stl::vector<kwsys_stl::string>& userPaths, bool no_system_path) { @@ -2716,7 +2759,7 @@ kwsys_stl::string SystemTools * found. Otherwise, the empty string is returned. */ kwsys_stl::string SystemTools -::FindFile(const char* name, +::FindFile(const kwsys_stl::string& name, const kwsys_stl::vector<kwsys_stl::string>& userPaths, bool no_system_path) { @@ -2735,7 +2778,7 @@ kwsys_stl::string SystemTools * found. Otherwise, the empty string is returned. */ kwsys_stl::string SystemTools -::FindDirectory(const char* name, +::FindDirectory(const kwsys_stl::string& name, const kwsys_stl::vector<kwsys_stl::string>& userPaths, bool no_system_path) { @@ -3078,29 +3121,29 @@ bool SystemTools::FileIsSymlink(const kwsys_stl::string& name) } #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::CreateSymlink(const char*, const char*) +bool SystemTools::CreateSymlink(const kwsys_stl::string&, const kwsys_stl::string&) { return false; } #else -bool SystemTools::CreateSymlink(const char* origName, const char* newName) +bool SystemTools::CreateSymlink(const kwsys_stl::string& origName, const kwsys_stl::string& newName) { - return symlink(origName, newName) >= 0; + return symlink(origName.c_str(), newName.c_str()) >= 0; } #endif #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::ReadSymlink(const char*, kwsys_stl::string&) +bool SystemTools::ReadSymlink(const kwsys_stl::string&, kwsys_stl::string&) { return false; } #else -bool SystemTools::ReadSymlink(const char* newName, +bool SystemTools::ReadSymlink(const kwsys_stl::string& newName, kwsys_stl::string& origName) { char buf[KWSYS_SYSTEMTOOLS_MAXPATH+1]; int count = - static_cast<int>(readlink(newName, buf, KWSYS_SYSTEMTOOLS_MAXPATH)); + static_cast<int>(readlink(newName.c_str(), buf, KWSYS_SYSTEMTOOLS_MAXPATH)); if(count >= 0) { // Add null-terminator. @@ -3136,14 +3179,14 @@ kwsys_stl::string SystemTools::GetCurrentWorkingDirectory(bool collapse) return path; } -kwsys_stl::string SystemTools::GetProgramPath(const char* in_name) +kwsys_stl::string SystemTools::GetProgramPath(const kwsys_stl::string& in_name) { kwsys_stl::string dir, file; SystemTools::SplitProgramPath(in_name, dir, file); return dir; } -bool SystemTools::SplitProgramPath(const char* in_name, +bool SystemTools::SplitProgramPath(const kwsys_stl::string& in_name, kwsys_stl::string& dir, kwsys_stl::string& file, bool) @@ -3409,7 +3452,62 @@ kwsys_stl::string SystemTools::CollapseFullPath(const kwsys_stl::string& in_path SystemTools::CheckTranslationPath(newPath); #ifdef _WIN32 - newPath = SystemTools::GetActualCaseForPath(newPath.c_str()); + newPath = SystemTools::GetActualCaseForPath(newPath); + SystemTools::ConvertToUnixSlashes(newPath); +#endif + // Return the reconstructed path. + return newPath; +} + +kwsys_stl::string SystemTools::CollapseFullPath(const kwsys_stl::string& in_path, + const kwsys_stl::string& in_base) +{ + // Collect the output path components. + kwsys_stl::vector<kwsys_stl::string> out_components; + + // Split the input path components. + kwsys_stl::vector<kwsys_stl::string> path_components; + SystemTools::SplitPath(in_path, path_components); + + // If the input path is relative, start with a base path. + if(path_components[0].length() == 0) + { + kwsys_stl::vector<kwsys_stl::string> base_components; + // Use the given base path. + SystemTools::SplitPath(in_base, base_components); + + // Append base path components to the output path. + out_components.push_back(base_components[0]); + SystemToolsAppendComponents(out_components, + base_components.begin()+1, + base_components.end()); + } + + // Append input path components to the output path. + SystemToolsAppendComponents(out_components, + path_components.begin(), + path_components.end()); + + // Transform the path back to a string. + kwsys_stl::string newPath = SystemTools::JoinPath(out_components); + + // Update the translation table with this potentially new path. I am not + // sure why this line is here, it seems really questionable, but yet I + // would put good money that if I remove it something will break, basically + // from what I can see it created a mapping from the collapsed path, to be + // replaced by the input path, which almost completely does the opposite of + // this function, the only thing preventing this from happening a lot is + // that if the in_path has a .. in it, then it is not added to the + // translation table. So for most calls this either does nothing due to the + // .. or it adds a translation between identical paths as nothing was + // collapsed, so I am going to try to comment it out, and see what hits the + // fan, hopefully quickly. + // Commented out line below: + //SystemTools::AddTranslationPath(newPath, in_path); + + SystemTools::CheckTranslationPath(newPath); +#ifdef _WIN32 + newPath = SystemTools::GetActualCaseForPath(newPath); SystemTools::ConvertToUnixSlashes(newPath); #endif // Return the reconstructed path. @@ -3569,7 +3667,7 @@ static int GetCasePathName(const kwsys_stl::string & pathIn, //---------------------------------------------------------------------------- -kwsys_stl::string SystemTools::GetActualCaseForPath(const char* p) +kwsys_stl::string SystemTools::GetActualCaseForPath(const kwsys_stl::string& p) { #ifndef _WIN32 return p; @@ -3930,7 +4028,7 @@ kwsys_stl::string SystemTools::GetFilenameName(const kwsys_stl::string& filename kwsys_stl::string SystemTools::GetFilenameExtension(const kwsys_stl::string& filename) { kwsys_stl::string name = SystemTools::GetFilenameName(filename); - kwsys_stl::string::size_type dot_pos = name.find("."); + kwsys_stl::string::size_type dot_pos = name.find('.'); if(dot_pos != kwsys_stl::string::npos) { return name.substr(dot_pos); @@ -3948,7 +4046,7 @@ kwsys_stl::string SystemTools::GetFilenameExtension(const kwsys_stl::string& fil kwsys_stl::string SystemTools::GetFilenameLastExtension(const kwsys_stl::string& filename) { kwsys_stl::string name = SystemTools::GetFilenameName(filename); - kwsys_stl::string::size_type dot_pos = name.rfind("."); + kwsys_stl::string::size_type dot_pos = name.rfind('.'); if(dot_pos != kwsys_stl::string::npos) { return name.substr(dot_pos); @@ -3966,7 +4064,7 @@ kwsys_stl::string SystemTools::GetFilenameLastExtension(const kwsys_stl::string& kwsys_stl::string SystemTools::GetFilenameWithoutExtension(const kwsys_stl::string& filename) { kwsys_stl::string name = SystemTools::GetFilenameName(filename); - kwsys_stl::string::size_type dot_pos = name.find("."); + kwsys_stl::string::size_type dot_pos = name.find('.'); if(dot_pos != kwsys_stl::string::npos) { return name.substr(0, dot_pos); @@ -3987,7 +4085,7 @@ kwsys_stl::string SystemTools::GetFilenameWithoutLastExtension(const kwsys_stl::string& filename) { kwsys_stl::string name = SystemTools::GetFilenameName(filename); - kwsys_stl::string::size_type dot_pos = name.rfind("."); + kwsys_stl::string::size_type dot_pos = name.rfind('.'); if(dot_pos != kwsys_stl::string::npos) { return name.substr(0, dot_pos); @@ -4276,7 +4374,7 @@ bool SystemTools::GetShortPath(const kwsys_stl::string& path, kwsys_stl::string& #endif } -void SystemTools::SplitProgramFromArgs(const char* path, +void SystemTools::SplitProgramFromArgs(const kwsys_stl::string& path, kwsys_stl::string& program, kwsys_stl::string& args) { // see if this is a full path to a program @@ -4352,7 +4450,7 @@ kwsys_stl::string SystemTools::GetCurrentDateTime(const char* format) return kwsys_stl::string(buf); } -kwsys_stl::string SystemTools::MakeCidentifier(const char* s) +kwsys_stl::string SystemTools::MakeCidentifier(const kwsys_stl::string& s) { kwsys_stl::string str(s); if (str.find_first_of("0123456789") == 0) diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index e88bc8f..beb2a7e 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -89,9 +89,9 @@ public: * then an underscore is prepended. Note that this can produce * identifiers that the standard reserves (_[A-Z].* and __.*). */ - static kwsys_stl::string MakeCidentifier(const char* s); + static kwsys_stl::string MakeCidentifier(const kwsys_stl::string& s); - static kwsys_stl::string MakeCindentifier(const char* s) + static kwsys_stl::string MakeCindentifier(const kwsys_stl::string& s) { return MakeCidentifier(s); } @@ -102,6 +102,9 @@ public: static void ReplaceString(kwsys_stl::string& source, const char* replace, const char* with); + static void ReplaceString(kwsys_stl::string& source, + const kwsys_stl::string& replace, + const kwsys_stl::string& with); /** * Return a capitalized string (i.e the first letter is uppercased, @@ -306,7 +309,7 @@ public: /** * Return file length */ - static unsigned long FileLength(const char *filename); + static unsigned long FileLength(const kwsys_stl::string& filename); /** Change the modification time or create a file @@ -335,15 +338,15 @@ public: * does not exist path is returned unchanged. This does nothing * on unix but return path. */ - static kwsys_stl::string GetActualCaseForPath(const char* path); + static kwsys_stl::string GetActualCaseForPath(const kwsys_stl::string& path); /** * Given the path to a program executable, get the directory part of * the path with the file stripped off. If there is no directory * part, the empty string is returned. */ - static kwsys_stl::string GetProgramPath(const char*); - static bool SplitProgramPath(const char* in_name, + static kwsys_stl::string GetProgramPath(const kwsys_stl::string&); + static bool SplitProgramPath(const kwsys_stl::string& in_name, kwsys_stl::string& dir, kwsys_stl::string& file, bool errorReport = true); @@ -376,6 +379,8 @@ public: static kwsys_stl::string CollapseFullPath(const kwsys_stl::string& in_relative); static kwsys_stl::string CollapseFullPath(const kwsys_stl::string& in_relative, const char* in_base); + static kwsys_stl::string CollapseFullPath(const kwsys_stl::string& in_relative, + const kwsys_stl::string& in_base); /** * Get the real path for a given path, removing all symlinks. In @@ -446,7 +451,7 @@ public: * Split a program from its arguments and handle spaces in the paths */ static void SplitProgramFromArgs( - const char* path, + const kwsys_stl::string& path, kwsys_stl::string& program, kwsys_stl::string& args); /** @@ -582,7 +587,7 @@ public: * Find a file in the system PATH, with optional extra paths */ static kwsys_stl::string FindFile( - const char* name, + const kwsys_stl::string& name, const kwsys_stl::vector<kwsys_stl::string>& path = kwsys_stl::vector<kwsys_stl::string>(), bool no_system_path = false); @@ -591,7 +596,7 @@ public: * Find a directory in the system PATH, with optional extra paths */ static kwsys_stl::string FindDirectory( - const char* name, + const kwsys_stl::string& name, const kwsys_stl::vector<kwsys_stl::string>& path = kwsys_stl::vector<kwsys_stl::string>(), bool no_system_path = false); @@ -662,13 +667,13 @@ public: * Create a symbolic link if the platform supports it. Returns whether * creation succeded. */ - static bool CreateSymlink(const char* origName, const char* newName); + static bool CreateSymlink(const kwsys_stl::string& origName, const kwsys_stl::string& newName); /** * Read the contents of a symbolic link. Returns whether reading * succeded. */ - static bool ReadSymlink(const char* newName, kwsys_stl::string& origName); + static bool ReadSymlink(const kwsys_stl::string& newName, kwsys_stl::string& origName); /** * Try to locate the file 'filename' in the directory 'dir'. @@ -750,26 +755,26 @@ public: /** * Get a list of subkeys. */ - static bool GetRegistrySubKeys(const char *key, + static bool GetRegistrySubKeys(const kwsys_stl::string& key, kwsys_stl::vector<kwsys_stl::string>& subkeys, KeyWOW64 view = KeyWOW64_Default); /** * Read a registry value */ - static bool ReadRegistryValue(const char *key, kwsys_stl::string &value, + static bool ReadRegistryValue(const kwsys_stl::string& key, kwsys_stl::string &value, KeyWOW64 view = KeyWOW64_Default); /** * Write a registry value */ - static bool WriteRegistryValue(const char *key, const char *value, + static bool WriteRegistryValue(const kwsys_stl::string& key, const kwsys_stl::string& value, KeyWOW64 view = KeyWOW64_Default); /** * Delete a registry value */ - static bool DeleteRegistryValue(const char *key, + static bool DeleteRegistryValue(const kwsys_stl::string& key, KeyWOW64 view = KeyWOW64_Default); /** ----------------------------------------------------------------- @@ -789,15 +794,17 @@ public: * Read an environment variable */ static const char* GetEnv(const char* key); + static const char* GetEnv(const kwsys_stl::string& key); static bool GetEnv(const char* key, kwsys_stl::string& result); + static bool GetEnv(const kwsys_stl::string& key, kwsys_stl::string& result); /** Put a string into the environment of the form var=value */ - static bool PutEnv(const char* env); + static bool PutEnv(const kwsys_stl::string& env); /** Remove a string from the environment. Input is of the form "var" or "var=value" (value is ignored). */ - static bool UnPutEnv(const char* env); + static bool UnPutEnv(const kwsys_stl::string& env); /** * Get current working directory CWD @@ -906,6 +913,14 @@ private: } /** + * Actual implementation of ReplaceString. + */ + static void ReplaceString(kwsys_stl::string& source, + const char* replace, + size_t replaceSize, + const kwsys_stl::string& with); + + /** * Actual implementation of FileIsFullPath. */ static bool FileIsFullPath(const char*, size_t); @@ -915,7 +930,7 @@ private: * optional extra paths. */ static kwsys_stl::string FindName( - const char* name, + const kwsys_stl::string& name, const kwsys_stl::vector<kwsys_stl::string>& path = kwsys_stl::vector<kwsys_stl::string>(), bool no_system_path = false); diff --git a/Source/kwsys/kwsysPlatformTests.cmake b/Source/kwsys/kwsysPlatformTests.cmake index 16bc969..0da0f63 100644 --- a/Source/kwsys/kwsysPlatformTests.cmake +++ b/Source/kwsys/kwsysPlatformTests.cmake @@ -25,39 +25,39 @@ MACRO(KWSYS_PLATFORM_TEST lang var description invert) FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "${description} compiled with the following output:\n${OUTPUT}\n\n") - ELSE(${var}_COMPILED) + ELSE() FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "${description} failed to compile with the following output:\n${OUTPUT}\n\n") - ENDIF(${var}_COMPILED) + ENDIF() IF(${invert} MATCHES INVERT) IF(${var}_COMPILED) MESSAGE(STATUS "${description} - no") - ELSE(${var}_COMPILED) + ELSE() MESSAGE(STATUS "${description} - yes") - ENDIF(${var}_COMPILED) - ELSE(${invert} MATCHES INVERT) + ENDIF() + ELSE() IF(${var}_COMPILED) MESSAGE(STATUS "${description} - yes") - ELSE(${var}_COMPILED) + ELSE() MESSAGE(STATUS "${description} - no") - ENDIF(${var}_COMPILED) - ENDIF(${invert} MATCHES INVERT) + ENDIF() + ENDIF() ENDIF() IF(${invert} MATCHES INVERT) IF(${var}_COMPILED) SET(${var} 0) - ELSE(${var}_COMPILED) + ELSE() SET(${var} 1) - ENDIF(${var}_COMPILED) - ELSE(${invert} MATCHES INVERT) + ENDIF() + ELSE() IF(${var}_COMPILED) SET(${var} 1) - ELSE(${var}_COMPILED) + ELSE() SET(${var} 0) - ENDIF(${var}_COMPILED) - ENDIF(${invert} MATCHES INVERT) -ENDMACRO(KWSYS_PLATFORM_TEST) + ENDIF() + ENDIF() +ENDMACRO() MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert) IF(NOT DEFINED ${var}) @@ -74,63 +74,63 @@ MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert) 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(${var}) + ELSE() FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "${description} compiled and ran with the following output:\n${OUTPUT}\n\n") - ENDIF(${var}) - ELSE(${var}_COMPILED) + 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(${var}_COMPILED) + ENDIF() IF(${invert} MATCHES INVERT) IF(${var}_COMPILED) IF(${var}) MESSAGE(STATUS "${description} - yes") - ELSE(${var}) + ELSE() MESSAGE(STATUS "${description} - no") - ENDIF(${var}) - ELSE(${var}_COMPILED) + ENDIF() + ELSE() MESSAGE(STATUS "${description} - failed to compile") - ENDIF(${var}_COMPILED) - ELSE(${invert} MATCHES INVERT) + ENDIF() + ELSE() IF(${var}_COMPILED) IF(${var}) MESSAGE(STATUS "${description} - no") - ELSE(${var}) + ELSE() MESSAGE(STATUS "${description} - yes") - ENDIF(${var}) - ELSE(${var}_COMPILED) + ENDIF() + ELSE() MESSAGE(STATUS "${description} - failed to compile") - ENDIF(${var}_COMPILED) - ENDIF(${invert} MATCHES INVERT) + ENDIF() + ENDIF() ENDIF() IF(${invert} MATCHES INVERT) IF(${var}_COMPILED) IF(${var}) SET(${var} 1) - ELSE(${var}) + ELSE() SET(${var} 0) - ENDIF(${var}) - ELSE(${var}_COMPILED) + ENDIF() + ELSE() SET(${var} 1) - ENDIF(${var}_COMPILED) - ELSE(${invert} MATCHES INVERT) + ENDIF() + ELSE() IF(${var}_COMPILED) IF(${var}) SET(${var} 0) - ELSE(${var}) + ELSE() SET(${var} 1) - ENDIF(${var}) - ELSE(${var}_COMPILED) + ENDIF() + ELSE() SET(${var} 0) - ENDIF(${var}_COMPILED) - ENDIF(${invert} MATCHES INVERT) -ENDMACRO(KWSYS_PLATFORM_TEST_RUN) + ENDIF() + ENDIF() +ENDMACRO() MACRO(KWSYS_PLATFORM_C_TEST var description invert) SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES}) @@ -138,7 +138,7 @@ MACRO(KWSYS_PLATFORM_C_TEST var description invert) KWSYS_PLATFORM_TEST(C "${var}" "${description}" "${invert}") SET(KWSYS_PLATFORM_TEST_DEFINES) SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS) -ENDMACRO(KWSYS_PLATFORM_C_TEST) +ENDMACRO() MACRO(KWSYS_PLATFORM_C_TEST_RUN var description invert) SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES}) @@ -146,7 +146,7 @@ MACRO(KWSYS_PLATFORM_C_TEST_RUN var description invert) KWSYS_PLATFORM_TEST_RUN(C "${var}" "${description}" "${invert}") SET(KWSYS_PLATFORM_TEST_DEFINES) SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS) -ENDMACRO(KWSYS_PLATFORM_C_TEST_RUN) +ENDMACRO() MACRO(KWSYS_PLATFORM_CXX_TEST var description invert) SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES}) @@ -156,7 +156,7 @@ MACRO(KWSYS_PLATFORM_CXX_TEST var description invert) SET(KWSYS_PLATFORM_TEST_DEFINES) SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS) SET(KWSYS_PLATFORM_TEST_LINK_LIBRARIES) -ENDMACRO(KWSYS_PLATFORM_CXX_TEST) +ENDMACRO() MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert) SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES}) @@ -164,7 +164,7 @@ MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert) KWSYS_PLATFORM_TEST_RUN(CXX "${var}" "${description}" "${invert}") SET(KWSYS_PLATFORM_TEST_DEFINES) SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS) -ENDMACRO(KWSYS_PLATFORM_CXX_TEST_RUN) +ENDMACRO() #----------------------------------------------------------------------------- # KWSYS_PLATFORM_INFO_TEST(lang var description) diff --git a/Source/kwsys/kwsysPlatformTestsCXX.cxx b/Source/kwsys/kwsysPlatformTestsCXX.cxx index 3f947f3..82620da 100644 --- a/Source/kwsys/kwsysPlatformTestsCXX.cxx +++ b/Source/kwsys/kwsysPlatformTestsCXX.cxx @@ -548,6 +548,10 @@ int main() #if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE) # define _GNU_SOURCE #endif +#if defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x5130 \ + && __linux && __SUNPRO_CC_COMPAT == 'G' +# include <iostream> +#endif #include <cxxabi.h> int main() { diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index b41532b..42b6249 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -124,7 +124,7 @@ static bool CheckFileOperations() res = false; } - if (kwsys::SystemTools::FileLength(testBinFile.c_str()) != 766) + if (kwsys::SystemTools::FileLength(testBinFile) != 766) { kwsys_ios::cerr << "Problem with FileLength - incorrect length for: " @@ -512,7 +512,7 @@ static bool CheckStringOperations() //---------------------------------------------------------------------------- -static bool CheckPutEnv(const char* env, const char* name, const char* value) +static bool CheckPutEnv(const kwsys_stl::string& env, const char* name, const char* value) { if(!kwsys::SystemTools::PutEnv(env)) { |