Bladeren bron

Merge topic 'update-kwsys'

79f30a8fc3 Merge branch 'upstream-KWSys' into update-kwsys
626f3d43f0 KWSys 2025-06-10 (d780326e)
575106995b Source: Drop support for KWSys Encoding without std::wstring methods

Acked-by: Kitware Robot <[email protected]>
Merge-request: !10866
Brad King 6 maanden geleden
bovenliggende
commit
ee698a7db4

+ 0 - 1
Source/Modules/CMakeBuildUtilities.cmake

@@ -41,7 +41,6 @@ if(WIN32)
   set(KWSYS_CXX_HAS_UTIMES_COMPILED 0)
   set(KWSYS_CXX_STAT_HAS_ST_MTIM_COMPILED 0)
   set(KWSYS_CXX_STAT_HAS_ST_MTIMESPEC_COMPILED 0)
-  set(KWSYS_STL_HAS_WSTRING_COMPILED 1)
   set(KWSYS_SYS_HAS_IFADDRS_H 0)
 endif()
 add_subdirectory(Source/kwsys)

+ 0 - 8
Source/cmArchiveWrite.cxx

@@ -39,21 +39,13 @@ static std::string cm_archive_error_string(struct archive* a)
 static void cm_archive_entry_copy_pathname(struct archive_entry* e,
                                            std::string const& dest)
 {
-#if cmsys_STL_HAS_WSTRING
   archive_entry_copy_pathname_w(e, cmsys::Encoding::ToWide(dest).c_str());
-#else
-  archive_entry_copy_pathname(e, dest.c_str());
-#endif
 }
 
 static void cm_archive_entry_copy_sourcepath(struct archive_entry* e,
                                              std::string const& file)
 {
-#if cmsys_STL_HAS_WSTRING
   archive_entry_copy_sourcepath_w(e, cmsys::Encoding::ToWide(file).c_str());
-#else
-  archive_entry_copy_sourcepath(e, file.c_str());
-#endif
 }
 
 class cmArchiveWrite::Entry

+ 0 - 8
Source/cmSystemTools.cxx

@@ -378,22 +378,14 @@ extern char** environ; // NOLINT(readability-redundant-declaration)
 #if !defined(CMAKE_BOOTSTRAP)
 static std::string cm_archive_entry_pathname(struct archive_entry* entry)
 {
-#  if cmsys_STL_HAS_WSTRING
   return cmsys::Encoding::ToNarrow(archive_entry_pathname_w(entry));
-#  else
-  return archive_entry_pathname(entry);
-#  endif
 }
 
 static int cm_archive_read_open_file(struct archive* a, char const* file,
                                      int block_size)
 {
-#  if cmsys_STL_HAS_WSTRING
   std::wstring wfile = cmsys::Encoding::ToWide(file);
   return archive_read_open_filename_w(a, wfile.c_str(), block_size);
-#  else
-  return archive_read_open_filename(a, file, block_size);
-#  endif
 }
 #endif
 

+ 1 - 11
Source/kwsys/CMakeLists.txt

@@ -351,12 +351,6 @@ endif()
 # capabilities and parent project's request.  Enforce 0/1 as only
 # possible values for configuration into Configure.hxx.
 
-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_NAMESPACE MATCHES "^kwsys$")
   set(KWSYS_NAME_IS_KWSYS 1)
 else()
@@ -953,12 +947,8 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
       testCommandLineArguments.cxx
       testCommandLineArguments1.cxx
       testDirectory.cxx
+      testEncoding.cxx
       )
-    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}
         testFStream.cxx

+ 0 - 3
Source/kwsys/Configure.hxx.in

@@ -6,8 +6,6 @@
 /* Include C configuration.  */
 #include <@KWSYS_NAMESPACE@/Configure.h>
 
-/* Whether wstring is available.  */
-#define @KWSYS_NAMESPACE@_STL_HAS_WSTRING @KWSYS_STL_HAS_WSTRING@
 /* Whether <ext/stdio_filebuf.h> is available. */
 #define @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H                         \
   @KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H@
@@ -51,7 +49,6 @@
 #    define kwsys @KWSYS_NAMESPACE@
 #  endif
 #  define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#  define KWSYS_STL_HAS_WSTRING @KWSYS_NAMESPACE@_STL_HAS_WSTRING
 #  define KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H                                   \
     @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H
 #  define KWSYS_FALLTHROUGH @KWSYS_NAMESPACE@_FALLTHROUGH

+ 2 - 6
Source/kwsys/Encoding.hxx.in

@@ -45,8 +45,6 @@ public:
    * Convert between char and wchar_t
    */
 
-#if @KWSYS_NAMESPACE@_STL_HAS_WSTRING
-
   // Convert a narrow string to a wide string.
   // On Windows, UTF-8 is assumed, and on other platforms,
   // the current locale is assumed.
@@ -59,7 +57,7 @@ public:
   static std::string ToNarrow(std::wstring const& str);
   static std::string ToNarrow(wchar_t const* str);
 
-#  if defined(_WIN32)
+#if defined(_WIN32)
   /**
    * Convert the path to an extended length path to avoid MAX_PATH length
    * limitations on Windows. If the input is a local path the result will be
@@ -70,9 +68,7 @@ public:
   static std::wstring ToWindowsExtendedPath(std::string const&);
   static std::wstring ToWindowsExtendedPath(char const* source);
   static std::wstring ToWindowsExtendedPath(std::wstring const& wsource);
-#  endif
-
-#endif // @KWSYS_NAMESPACE@_STL_HAS_WSTRING
+#endif
 
 }; // class Encoding
 } // namespace @KWSYS_NAMESPACE@

+ 8 - 12
Source/kwsys/EncodingCXX.cxx

@@ -122,12 +122,10 @@ char const* const* Encoding::CommandLineArguments::argv() const
   return &this->argv_[0];
 }
 
-#if KWSYS_STL_HAS_WSTRING
-
 std::wstring Encoding::ToWide(std::string const& str)
 {
   std::wstring wstr;
-#  if defined(_WIN32)
+#if defined(_WIN32)
   int const wlength =
     MultiByteToWideChar(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(),
                         int(str.size()), nullptr, 0);
@@ -140,7 +138,7 @@ std::wstring Encoding::ToWide(std::string const& str)
     }
     delete[] wdata;
   }
-#  else
+#else
   size_t pos = 0;
   size_t nullPos = 0;
   do {
@@ -153,14 +151,14 @@ std::wstring Encoding::ToWide(std::string const& str)
       wstr += wchar_t('\0');
     }
   } while (nullPos != std::string::npos);
-#  endif
+#endif
   return wstr;
 }
 
 std::string Encoding::ToNarrow(std::wstring const& str)
 {
   std::string nstr;
-#  if defined(_WIN32)
+#if defined(_WIN32)
   int length =
     WideCharToMultiByte(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.c_str(),
                         int(str.size()), nullptr, 0, nullptr, nullptr);
@@ -174,7 +172,7 @@ std::string Encoding::ToNarrow(std::wstring const& str)
     }
     delete[] data;
   }
-#  else
+#else
   size_t pos = 0;
   size_t nullPos = 0;
   do {
@@ -187,7 +185,7 @@ std::string Encoding::ToNarrow(std::wstring const& str)
       nstr += '\0';
     }
   } while (nullPos != std::string::npos);
-#  endif
+#endif
   return nstr;
 }
 
@@ -221,7 +219,7 @@ std::string Encoding::ToNarrow(wchar_t const* wcstr)
   return str;
 }
 
-#  if defined(_WIN32)
+#if defined(_WIN32)
 // Convert local paths to UNC style paths
 std::wstring Encoding::ToWindowsExtendedPath(std::string const& source)
 {
@@ -285,8 +283,6 @@ std::wstring Encoding::ToWindowsExtendedPath(std::wstring const& wsource)
   // unchanged
   return wsource;
 }
-#  endif
-
-#endif // KWSYS_STL_HAS_WSTRING
+#endif
 
 } // namespace KWSYS_NAMESPACE

+ 0 - 11
Source/kwsys/kwsysPlatformTestsCXX.cxx

@@ -154,17 +154,6 @@ int main()
 }
 #endif
 
-#ifdef TEST_KWSYS_STL_HAS_WSTRING
-#  include <string>
-void f(std::wstring*)
-{
-}
-int main()
-{
-  return 0;
-}
-#endif
-
 #ifdef TEST_KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H
 #  include <ext/stdio_filebuf.h>
 int main()

+ 0 - 11
bootstrap

@@ -847,7 +847,6 @@ cmake_kwsys_config_replace_string ()
               s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
               s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
               s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
-              s/@KWSYS_STL_HAS_WSTRING@/${KWSYS_STL_HAS_WSTRING}/g;
               s/@KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H@/${KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H}/g;
              }" "${INFILE}" >> "${OUTFILE}${_tmp}"
     if test -f "${OUTFILE}${_tmp}"; then
@@ -1562,7 +1561,6 @@ KWSYS_NAME_IS_KWSYS=0
 KWSYS_BUILD_SHARED=0
 KWSYS_LFS_AVAILABLE=0
 KWSYS_LFS_REQUESTED=0
-KWSYS_STL_HAS_WSTRING=0
 KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H=0
 KWSYS_CXX_HAS_SETENV=0
 KWSYS_CXX_HAS_UNSETENV=0
@@ -1597,15 +1595,6 @@ else
   echo "${cmake_cxx_compiler} does not have environ in stdlib.h"
 fi
 
-if cmake_try_run "${cmake_cxx_compiler}" \
-  "${cmake_cxx_flags} ${cmake_ld_flags} -DTEST_KWSYS_STL_HAS_WSTRING" \
-  "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
-  KWSYS_STL_HAS_WSTRING=1
-  echo "${cmake_cxx_compiler} has stl wstring"
-else
-  echo "${cmake_cxx_compiler} does not have stl wstring"
-fi
-
 if cmake_try_run "${cmake_cxx_compiler}" \
   "${cmake_cxx_flags} ${cmake_ld_flags} -DTEST_KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H" \
   "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then