KWSys 2020-03-04 (6af2e592)

Code extracted from:

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

at commit 6af2e59217a7e10ed507da564a1445b60ac2a095 (master).

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

Hans Johnson (17):
      81d1e737 STYLE: Use modern path naming
      28b8e6c2 STYLE: Convert CMake-language commands to lower case
      6ce3d69a DOC: Update documentation for modern add_subdirectory.
      8a7fe7ac STYLE: Remove redundant void argument lists
      1c3e193d COMP: Use nullptr instead of 0 or NULL
      2a4c1252 STYLE: Replace integer literals which are cast to bool.
      0fe7214d STYLE: Make prototype match definition names
      3b30d0ff STYLE: Make prototype match definition names
      691d5612 PERF: readability container size empty
      7be4043f STYLE: Prefer c++11 'using' to 'typedef'
      acc916ed COMP: Prefer const pointer when value does not change
      4c7f64eb COMP: Prefer const member functions
      d07092a0 STYLE: Use default member initialization
      6d20e7c9 STYLE: Prefer = default to explicitly trivial implementations
      91429382 PERF: emplace_back method results in potentially more efficient code
      cc8fc323 STYLE: Use auto for variable type matches the type of the initializer
      6621b069 STYLE: Use range-based loops from C++11

Julien Schueller (1):
      a1a261ac CMake: Fix psapi lib name on case-sensitive fs
This commit is contained in:
KWSys Upstream
2020-03-04 08:00:23 -05:00
committed by Brad King
parent 4e8c4c7ebe
commit ec33e3600c
19 changed files with 999 additions and 968 deletions
+9 -10
View File
@@ -85,7 +85,7 @@ static int testRobustEncoding()
std::wstring wstr = kwsys::Encoding::ToWide(cstr);
wstr = kwsys::Encoding::ToWide(nullptr);
if (wstr != L"") {
if (!wstr.empty()) {
const wchar_t* wcstr = wstr.c_str();
std::cout << "ToWide(NULL) returned";
for (size_t i = 0; i < wstr.size(); i++) {
@@ -95,7 +95,7 @@ static int testRobustEncoding()
ret++;
}
wstr = kwsys::Encoding::ToWide("");
if (wstr != L"") {
if (!wstr.empty()) {
const wchar_t* wcstr = wstr.c_str();
std::cout << "ToWide(\"\") returned";
for (size_t i = 0; i < wstr.size(); i++) {
@@ -113,13 +113,13 @@ static int testRobustEncoding()
#endif
std::string str = kwsys::Encoding::ToNarrow(nullptr);
if (str != "") {
if (!str.empty()) {
std::cout << "ToNarrow(NULL) returned " << str << std::endl;
ret++;
}
str = kwsys::Encoding::ToNarrow(L"");
if (wstr != L"") {
if (!wstr.empty()) {
std::cout << "ToNarrow(\"\") returned " << str << std::endl;
ret++;
}
@@ -140,14 +140,13 @@ static int testWithNulls()
strings.push_back(std::string("k") + '\0' + '\0');
strings.push_back(std::string("\0\0\0\0", 4) + "lmn" +
std::string("\0\0\0\0", 4));
for (std::vector<std::string>::iterator it = strings.begin();
it != strings.end(); ++it) {
std::wstring wstr = kwsys::Encoding::ToWide(*it);
for (auto& string : strings) {
std::wstring wstr = kwsys::Encoding::ToWide(string);
std::string str = kwsys::Encoding::ToNarrow(wstr);
std::string s(*it);
std::string s(string);
std::replace(s.begin(), s.end(), '\0', ' ');
std::cout << "'" << s << "' (" << it->size() << ")" << std::endl;
if (str != *it) {
std::cout << "'" << s << "' (" << string.size() << ")" << std::endl;
if (str != string) {
std::replace(str.begin(), str.end(), '\0', ' ');
std::cout << "string with null was different: '" << str << "' ("
<< str.size() << ")" << std::endl;