1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

KWSys 2025-06-10 (d780326e)

Code extracted from:

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

at commit d780326e2bd8c57eaca712f87552e841aa80b415 (master).

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

Brad King (1):
      3f589f94 Encoding: Drop support for building without std::wstring
This commit is contained in:
KWSys Upstream
2025-06-10 09:43:50 -04:00
committed by Brad King
parent 0792fe05f6
commit 626f3d43f0
5 changed files with 11 additions and 43 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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@

View File

@@ -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

View File

@@ -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()