mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-25 09:58:37 -05:00
Merge topic 'update-kwsys'
79f30a8fc3Merge branch 'upstream-KWSys' into update-kwsys626f3d43f0KWSys 2025-06-10 (d780326e)575106995bSource: Drop support for KWSys Encoding without std::wstring methods Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !10866
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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@
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user