From 91197294841ee8a822007d039c07b2e697969dfb Mon Sep 17 00:00:00 2001 From: firewave Date: Sat, 11 Feb 2023 11:30:06 +0100 Subject: [PATCH] added lowercase aliases `win32a` and `win32w` for platform types `win32A` and `win32W` - and use them internally --- addons/cppcheckdata.py | 2 +- cfg/windows.cfg | 656 ++++++++++++++++++------------------- cli/cmdlineparser.cpp | 2 + gui/projectfile.h | 2 +- lib/platform.cpp | 14 +- lib/platform.h | 4 +- man/cppcheck.1.xml | 2 +- releasenotes.txt | 1 + test/CMakeLists.txt | 4 +- test/cfg/runtests.sh | 4 +- test/testcmdlineparser.cpp | 18 + test/testtokenize.cpp | 8 +- 12 files changed, 374 insertions(+), 343 deletions(-) diff --git a/addons/cppcheckdata.py b/addons/cppcheckdata.py index 6f434d5e283..4bbbe430f9a 100755 --- a/addons/cppcheckdata.py +++ b/addons/cppcheckdata.py @@ -1108,7 +1108,7 @@ class Platform: This class contains type sizes Attributes: - name Name of the platform: unspecified/native/win32A/win32W/win64/unix32/unix64/platformFile + name Name of the platform: unspecified/native/win32A/win32W/win32a/win32w/win64/unix32/unix64/platformFile char_bit CHAR_BIT value short_bit SHORT_BIT value int_bit INT_BIT value diff --git a/cfg/windows.cfg b/cfg/windows.cfg index aa464b6c40e..3542e957a30 100644 --- a/cfg/windows.cfg +++ b/cfg/windows.cfg @@ -1,112 +1,112 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -114,308 +114,308 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -423,53 +423,53 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -477,13 +477,13 @@ - - + + - - + + @@ -492,106 +492,106 @@ - - + + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - + + @@ -599,227 +599,227 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -828,13 +828,13 @@ - - + + - - + + @@ -842,43 +842,43 @@ - + - + - + - + - + - + - - + + - - + + - - + + @@ -886,45 +886,45 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -934,55 +934,55 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -991,48 +991,48 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index f2baaf39713..6bc92f11df6 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -1659,8 +1659,10 @@ void CmdLineParser::printHelp() const " * unix64\n" " 64 bit unix variant\n" " * win32A\n" + " * win32a\n" " 32 bit Windows ASCII character encoding\n" " * win32W\n" + " * win32w\n" " 32 bit Windows UNICODE character encoding\n" " * win64\n" " 64 bit Windows\n" diff --git a/gui/projectfile.h b/gui/projectfile.h index 9647256195a..7c2b9ea8801 100644 --- a/gui/projectfile.h +++ b/gui/projectfile.h @@ -174,7 +174,7 @@ class ProjectFile : public QObject { /** * @brief Get platform. - * @return Current platform. If it ends with .xml then it is a file. Otherwise it must match one of the return values from @sa cppcheck::Platform::toString() ("win32A", "unix32", ..) + * @return Current platform. If it ends with .xml then it is a file. Otherwise it must match one of the return values from @sa cppcheck::Platform::toString() ("win32a", "unix32", ..) */ const QString& getPlatform() const { return mPlatform; diff --git a/lib/platform.cpp b/lib/platform.cpp index 06e2fd49ba7..8a2f84158d8 100644 --- a/lib/platform.cpp +++ b/lib/platform.cpp @@ -152,9 +152,19 @@ bool Platform::set(Type t) bool Platform::set(const std::string& platformstr, std::string& errstr, const std::vector& paths, bool debug) { - if (platformstr == "win32A") + if (platformstr == "win32A") { + // TODO: deprecate + // std::cout << "Platform 'win32A' is deprecated and will be removed in a future version. Please use 'win32a' instead." << std::endl; set(Type::Win32A); - else if (platformstr == "win32W") + } + else if (platformstr == "win32a") + set(Type::Win32A); + else if (platformstr == "win32W") { + // TODO: deprecate + // std::cout << "Platform 'win32W' is deprecated and will be removed in a future version. Please use 'win32w' instead." << std::endl; + set(Type::Win32W); + } + else if (platformstr == "win32w") set(Type::Win32W); else if (platformstr == "win64") set(Type::Win64); diff --git a/lib/platform.h b/lib/platform.h index 24e61aecc98..fecb1f0542b 100644 --- a/lib/platform.h +++ b/lib/platform.h @@ -157,9 +157,9 @@ class CPPCHECKLIB Platform { case Type::Native: return "native"; case Type::Win32A: - return "win32A"; + return "win32a"; case Type::Win32W: - return "win32W"; + return "win32w"; case Type::Win64: return "win64"; case Type::Unix32: diff --git a/man/cppcheck.1.xml b/man/cppcheck.1.xml index f6838587b62..7f0209cff35 100644 --- a/man/cppcheck.1.xml +++ b/man/cppcheck.1.xml @@ -511,7 +511,7 @@ There are false positives with this option. Each result must be carefully invest Specifies platform specific types and sizes.The available platforms are: - unix3232 bit unix variantunix6464 bit unix variantwin32A32 bit Windows ASCII character encodingwin32W32 bit Windows UNICODE character encodingwin6464 bit Windows + unix3232 bit unix variantunix6464 bit unix variantwin32a32 bit Windows ASCII character encodingwin32w32 bit Windows UNICODE character encodingwin6464 bit Windows By default the platform which was used to compile Cppcheck is used. diff --git a/releasenotes.txt b/releasenotes.txt index ac3f5eec5b4..79e18f507c4 100644 --- a/releasenotes.txt +++ b/releasenotes.txt @@ -21,4 +21,5 @@ Deprecations: Other: - "missingInclude" is no longer implicitly enabled with "information" - you need to enable it explicitly now. +- Added lowercase aliases 'win32a' and 'win32w' for platform types 'Win32A' and 'Win32W'. The mixed case versions will be deprecated in a future version. - diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b199a147b54..08818b8bf8c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -162,8 +162,8 @@ if (BUILD_TESTS) add_cfg(sqlite3.c) add_cfg(std.c) add_cfg(std.cpp) - add_cfg(windows.cpp NAME windows32A PLATFORM win32A) - add_cfg(windows.cpp NAME windows32W PLATFORM win32W) + add_cfg(windows.cpp NAME windows32A PLATFORM win32a) + add_cfg(windows.cpp NAME windows32W PLATFORM win32w) add_cfg(windows.cpp NAME windows64 PLATFORM win64) add_cfg(wxwidgets.cpp) diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index 1ff731abe16..47d81744656 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -568,8 +568,8 @@ function check_file { ;; windows.cpp) windows_fn - "${CPPCHECK}" "${CPPCHECK_OPT[@]}" --platform=win32A --library="$lib" "${DIR}""$f" - "${CPPCHECK}" "${CPPCHECK_OPT[@]}" --platform=win32W --library="$lib" "${DIR}""$f" + "${CPPCHECK}" "${CPPCHECK_OPT[@]}" --platform=win32a --library="$lib" "${DIR}""$f" + "${CPPCHECK}" "${CPPCHECK_OPT[@]}" --platform=win32w --library="$lib" "${DIR}""$f" "${CPPCHECK}" "${CPPCHECK_OPT[@]}" --platform=win64 --library="$lib" "${DIR}""$f" ;; wxwidgets.cpp) diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index 2077618f1ed..b9cea2ff805 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -239,7 +239,9 @@ class TestCmdlineParser : public TestFixture { TEST_CASE(stdmulti2); TEST_CASE(platformWin64); TEST_CASE(platformWin32A); + TEST_CASE(platformWin32a); TEST_CASE(platformWin32W); + TEST_CASE(platformWin32w); TEST_CASE(platformUnix32); TEST_CASE(platformUnix32Unsigned); TEST_CASE(platformUnix64); @@ -1501,6 +1503,14 @@ class TestCmdlineParser : public TestFixture { ASSERT_EQUALS(Platform::Type::Win32A, settings->platform.type); } + void platformWin32a() { + REDIRECT; + const char * const argv[] = {"cppcheck", "--platform=win32a", "file.cpp"}; + ASSERT(settings->platform.set(Platform::Type::Unspecified)); + ASSERT_EQUALS_ENUM(CmdLineParser::Result::Success, parser->parseFromArgs(3, argv)); + ASSERT_EQUALS(Platform::Type::Win32A, settings->platform.type); + } + void platformWin32W() { REDIRECT; const char * const argv[] = {"cppcheck", "--platform=win32W", "file.cpp"}; @@ -1509,6 +1519,14 @@ class TestCmdlineParser : public TestFixture { ASSERT_EQUALS(Platform::Type::Win32W, settings->platform.type); } + void platformWin32w() { + REDIRECT; + const char * const argv[] = {"cppcheck", "--platform=win32w", "file.cpp"}; + ASSERT(settings->platform.set(Platform::Type::Unspecified)); + ASSERT_EQUALS_ENUM(CmdLineParser::Result::Success, parser->parseFromArgs(3, argv)); + ASSERT_EQUALS(Platform::Type::Win32W, settings->platform.type); + } + void platformUnix32() { REDIRECT; const char * const argv[] = {"cppcheck", "--platform=unix32", "file.cpp"}; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 99ca7f8f983..92e23dcfa0d 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -5681,10 +5681,10 @@ class TestTokenizer : public TestFixture { "float * ptrToFloat ;"; // These types should be defined the same on all Windows platforms - const std::string win32A = tokenizeAndStringifyWindows(code, true, Platform::Type::Win32A); - ASSERT_EQUALS(expected, win32A); - ASSERT_EQUALS(win32A, tokenizeAndStringifyWindows(code, true, Platform::Type::Win32W)); - ASSERT_EQUALS(win32A, tokenizeAndStringifyWindows(code, true, Platform::Type::Win64)); + const std::string win32a = tokenizeAndStringifyWindows(code, true, Platform::Type::Win32A); + ASSERT_EQUALS(expected, win32a); + ASSERT_EQUALS(win32a, tokenizeAndStringifyWindows(code, true, Platform::Type::Win32W)); + ASSERT_EQUALS(win32a, tokenizeAndStringifyWindows(code, true, Platform::Type::Win64)); } void platformWin32A() {