From 28e40cb9b0b01d2e33ef8c91f954b5b6b634ea74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 16 Oct 2010 21:39:58 +0200 Subject: [PATCH] unicode: updates to the handling of unicode filenames. Ticket: #2100 --- cli/cppcheck.vcproj | 2 +- lib/filelister_win32.cpp | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cli/cppcheck.vcproj b/cli/cppcheck.vcproj index 376a39ef1..79a4da195 100755 --- a/cli/cppcheck.vcproj +++ b/cli/cppcheck.vcproj @@ -47,7 +47,7 @@ Optimization="0" WholeProgramOptimization="false" AdditionalIncludeDirectories="..\lib" - PreprocessorDefinitions="_DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;UNICODE" + PreprocessorDefinitions="_DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS" BasicRuntimeChecks="3" RuntimeLibrary="1" TreatWChar_tAsBuiltInType="false" diff --git a/lib/filelister_win32.cpp b/lib/filelister_win32.cpp index 13ba19844..975587c47 100644 --- a/lib/filelister_win32.cpp +++ b/lib/filelister_win32.cpp @@ -148,14 +148,12 @@ void FileListerWin32::recursiveAddFiles(std::vector &filenames, con #if defined(UNICODE) char * ansiFfd = new char[wcslen(ffd.cFileName) + 1]; TransformUcs2ToAnsi(ffd.cFileName, ansiFfd, wcslen(ffd.cFileName) + 1); - if (strchr(ansiFfd, '?')) - { - delete [] ansiFfd; - ansiFfd = new char[wcslen(ffd.cAlternateFileName) + 1]; - TransformUcs2ToAnsi(ffd.cAlternateFileName, ansiFfd, wcslen(ffd.cAlternateFileName) + 1); - } #else // defined(UNICODE) - char * ansiFfd = &ffd.cFileName[0]; + const char * ansiFfd = &ffd.cFileName[0]; + if (strchr(ansiFfd,'?')) + { + ansiFfd = &ffd.cAlternateFileName[0]; + } #endif // defined(UNICODE) std::ostringstream fname;