diff --git a/Makefile b/Makefile index c0e5675cc..3c66e8678 100644 --- a/Makefile +++ b/Makefile @@ -61,8 +61,6 @@ LIBOBJ = lib/checkautovariables.o \ CLIOBJ = cli/cmdlineparser.o \ cli/cppcheckexecutor.o \ cli/filelister.o \ - cli/filelister_unix.o \ - cli/filelister_win32.o \ cli/main.o \ cli/pathmatch.o \ cli/threadexecutor.o @@ -122,8 +120,8 @@ cppcheck: $(LIBOBJ) $(CLIOBJ) $(EXTOBJ) all: cppcheck testrunner -testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/filelister_unix.o cli/pathmatch.o - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre cli/threadexecutor.o cli/cmdlineparser.o cli/filelister.o cli/filelister_unix.o cli/pathmatch.o $(LDFLAGS) +testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/pathmatch.o + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre cli/threadexecutor.o cli/cmdlineparser.o cli/filelister.o cli/pathmatch.o $(LDFLAGS) test: all ./testrunner @@ -132,7 +130,7 @@ check: all ./testrunner -g -q dmake: tools/dmake.cpp - $(CXX) -o dmake tools/dmake.cpp cli/filelister*.cpp lib/path.cpp -Ilib + $(CXX) -o dmake tools/dmake.cpp cli/filelister.cpp lib/path.cpp -Ilib clean: rm -f lib/*.o cli/*.o test/*.o externals/tinyxml/*.o testrunner cppcheck cppcheck.1 @@ -168,7 +166,7 @@ lib/checkexceptionsafety.o: lib/checkexceptionsafety.cpp lib/checkexceptionsafet lib/checkmemoryleak.o: lib/checkmemoryleak.cpp lib/checkmemoryleak.h lib/check.h lib/token.h lib/tokenize.h lib/settings.h lib/errorlogger.h lib/symboldatabase.h lib/mathlib.h lib/executionpath.h lib/checkuninitvar.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_LIB} -c -o lib/checkmemoryleak.o lib/checkmemoryleak.cpp -lib/checknullpointer.o: lib/checknullpointer.cpp lib/checknullpointer.h lib/check.h lib/token.h lib/tokenize.h lib/settings.h lib/errorlogger.h lib/executionpath.h lib/mathlib.h +lib/checknullpointer.o: lib/checknullpointer.cpp lib/checknullpointer.h lib/check.h lib/token.h lib/tokenize.h lib/settings.h lib/errorlogger.h lib/executionpath.h lib/mathlib.h lib/symboldatabase.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_LIB} -c -o lib/checknullpointer.o lib/checknullpointer.cpp lib/checkobsoletefunctions.o: lib/checkobsoletefunctions.cpp lib/checkobsoletefunctions.h lib/check.h lib/token.h lib/tokenize.h lib/settings.h lib/errorlogger.h @@ -180,7 +178,7 @@ lib/checkother.o: lib/checkother.cpp lib/checkother.h lib/check.h lib/token.h li lib/checkpostfixoperator.o: lib/checkpostfixoperator.cpp lib/checkpostfixoperator.h lib/check.h lib/token.h lib/tokenize.h lib/settings.h lib/errorlogger.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_LIB} -c -o lib/checkpostfixoperator.o lib/checkpostfixoperator.cpp -lib/checkstl.o: lib/checkstl.cpp lib/checkstl.h lib/check.h lib/token.h lib/tokenize.h lib/settings.h lib/errorlogger.h lib/executionpath.h +lib/checkstl.o: lib/checkstl.cpp lib/checkstl.h lib/check.h lib/token.h lib/tokenize.h lib/settings.h lib/errorlogger.h lib/executionpath.h lib/symboldatabase.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_LIB} -c -o lib/checkstl.o lib/checkstl.cpp lib/checkuninitvar.o: lib/checkuninitvar.cpp lib/checkuninitvar.h lib/check.h lib/token.h lib/tokenize.h lib/settings.h lib/errorlogger.h lib/mathlib.h lib/executionpath.h lib/checknullpointer.h @@ -228,15 +226,9 @@ cli/cmdlineparser.o: cli/cmdlineparser.cpp lib/cppcheck.h lib/settings.h lib/err cli/cppcheckexecutor.o: cli/cppcheckexecutor.cpp cli/cppcheckexecutor.h lib/errorlogger.h lib/settings.h lib/cppcheck.h lib/checkunusedfunctions.h lib/check.h lib/token.h lib/tokenize.h cli/threadexecutor.h cli/cmdlineparser.h cli/filelister.h lib/path.h cli/pathmatch.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_CLI} -c -o cli/cppcheckexecutor.o cli/cppcheckexecutor.cpp -cli/filelister.o: cli/filelister.cpp cli/filelister.h cli/filelister_win32.h cli/filelister_unix.h +cli/filelister.o: cli/filelister.cpp cli/filelister.h lib/path.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_CLI} -c -o cli/filelister.o cli/filelister.cpp -cli/filelister_unix.o: cli/filelister_unix.cpp lib/path.h cli/filelister.h cli/filelister_unix.h - $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_CLI} -c -o cli/filelister_unix.o cli/filelister_unix.cpp - -cli/filelister_win32.o: cli/filelister_win32.cpp cli/filelister.h cli/filelister_win32.h lib/path.h - $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_CLI} -c -o cli/filelister_win32.o cli/filelister_win32.cpp - cli/main.o: cli/main.cpp cli/cppcheckexecutor.h lib/errorlogger.h lib/settings.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_CLI} -c -o cli/main.o cli/main.cpp @@ -300,7 +292,7 @@ test/testobsoletefunctions.o: test/testobsoletefunctions.cpp lib/tokenize.h lib/ test/testoptions.o: test/testoptions.cpp test/options.h test/testsuite.h lib/errorlogger.h lib/settings.h test/redirect.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_TEST} -c -o test/testoptions.o test/testoptions.cpp -test/testother.o: test/testother.cpp lib/tokenize.h lib/checkother.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h test/testsuite.h test/redirect.h +test/testother.o: test/testother.cpp lib/preprocessor.h lib/tokenize.h lib/checkother.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h test/testsuite.h test/redirect.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_TEST} -c -o test/testother.o test/testother.cpp test/testpath.o: test/testpath.cpp test/testsuite.h lib/errorlogger.h lib/settings.h test/redirect.h lib/path.h @@ -330,7 +322,7 @@ test/teststl.o: test/teststl.cpp lib/tokenize.h lib/checkstl.h lib/check.h lib/t test/testsuite.o: test/testsuite.cpp test/testsuite.h lib/errorlogger.h lib/settings.h test/redirect.h test/options.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_TEST} -c -o test/testsuite.o test/testsuite.cpp -test/testsuppressions.o: test/testsuppressions.cpp lib/cppcheck.h lib/settings.h lib/errorlogger.h lib/checkunusedfunctions.h lib/check.h cli/threadexecutor.h lib/token.h lib/tokenize.h test/testsuite.h test/redirect.h +test/testsuppressions.o: test/testsuppressions.cpp lib/cppcheck.h lib/settings.h lib/errorlogger.h lib/checkunusedfunctions.h lib/check.h lib/token.h lib/tokenize.h test/testsuite.h test/redirect.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_TEST} -c -o test/testsuppressions.o test/testsuppressions.cpp test/testsymboldatabase.o: test/testsymboldatabase.cpp test/testsuite.h lib/errorlogger.h lib/settings.h test/redirect.h test/testutils.h lib/tokenize.h lib/token.h lib/symboldatabase.h diff --git a/cli/cli.pro b/cli/cli.pro index efc3e4da3..3cd4dae43 100644 --- a/cli/cli.pro +++ b/cli/cli.pro @@ -16,16 +16,12 @@ SOURCES += main.cpp \ cppcheckexecutor.cpp \ cmdlineparser.cpp \ filelister.cpp \ - filelister_unix.cpp \ - filelister_win32.cpp \ pathmatch.cpp \ threadexecutor.cpp HEADERS += cppcheckexecutor.h \ cmdlineparser.h \ filelister.h \ - filelister_unix.h \ - filelister_win32.h \ pathmatch.h \ threadexecutor.h diff --git a/cli/cppcheck.vcproj b/cli/cppcheck.vcproj index bdb932e7c..bd0068804 100755 --- a/cli/cppcheck.vcproj +++ b/cli/cppcheck.vcproj @@ -3,7 +3,7 @@ ProjectType="Visual C++" Version="9,00" Name="cppcheck" - ProjectGUID="{A610CB5D-FA83-3FC9-96AB-5689E3B50CEC}" + ProjectGUID="{DFF8822D-8155-38DC-BAFD-1B7A99B650DB}" Keyword="Qt4VSv1.0"> + PreprocessorDefinitions="UNICODE,WIN32,QT_LARGEFILE_SUPPORT,HAVE_RULES,_CRT_SECURE_NO_WARNINGS,_DEBUG" /> + PreprocessorDefinitions="QT_NO_DEBUG,NDEBUG,UNICODE,WIN32,QT_LARGEFILE_SUPPORT,HAVE_RULES,NDEBUG,_CRT_SECURE_NO_WARNINGS" /> @@ -159,10 +159,6 @@ RelativePath="..\lib\executionpath.cpp" /> - - - - - {E3A516D8-D69D-32D7-A444-A3674D4B1FE8} + {D647F468-12E1-3A1D-A42E-59F4C080F475} cppcheck Qt4VSv1.0 @@ -50,7 +50,7 @@ - ".";"..\lib";"..\externals";"..\externals\tinyxml";c:\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories) + ".";"..\lib";"..\externals";"..\externals\tinyxml";..\..\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories) -Zm200 -w34100 -w34189 %(AdditionalOptions) temp\ false @@ -59,7 +59,7 @@ Sync temp\ Disabled - UNICODE;WIN32;QT_LARGEFILE_SUPPORT;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false .\ MultiThreadedDebugDLL @@ -79,12 +79,12 @@ - UNICODE;WIN32;QT_LARGEFILE_SUPPORT;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions) + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions) - ".";"..\lib";"..\externals";"..\externals\tinyxml";c:\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories) + ".";"..\lib";"..\externals";"..\externals\tinyxml";..\..\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories) -Zm200 -w34100 -w34189 %(AdditionalOptions) temp\ false @@ -92,7 +92,7 @@ Sync temp\ MaxSpeed - QT_NO_DEBUG;NDEBUG;UNICODE;WIN32;QT_LARGEFILE_SUPPORT;NDEBUG;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions) + QT_NO_DEBUG;NDEBUG;UNICODE;WIN32;QT_LARGEFILE_SUPPORT;HAVE_RULES;NDEBUG;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions) false .\ MultiThreadedDLL @@ -113,7 +113,7 @@ - QT_NO_DEBUG;NDEBUG;UNICODE;WIN32;QT_LARGEFILE_SUPPORT;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + QT_NO_DEBUG;NDEBUG;UNICODE;WIN32;QT_LARGEFILE_SUPPORT;HAVE_RULES;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -135,8 +135,6 @@ - - @@ -173,8 +171,6 @@ - - diff --git a/cli/cppcheck.vcxproj.filters b/cli/cppcheck.vcxproj.filters index de87f16e1..32232ad88 100644 --- a/cli/cppcheck.vcxproj.filters +++ b/cli/cppcheck.vcxproj.filters @@ -69,12 +69,6 @@ Source Files - - Source Files - - - Source Files - Source Files @@ -179,12 +173,6 @@ Header Files - - Header Files - - - Header Files - Header Files diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 33092b363..f484281b4 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -71,7 +71,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c ++iter) { const std::string path(Path::toNativeSeparators(*iter)); - if (!getFileLister()->isDirectory(path.c_str())) + if (!FileLister::isDirectory(path)) { std::cout << "cppcheck: error: Couldn't find path given by -I '" + path + "'" << std::endl; return false; @@ -87,7 +87,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c // Execute recursiveAddFiles() to each given file parameter std::vector::const_iterator iter; for (iter = pathnames.begin(); iter != pathnames.end(); ++iter) - getFileLister()->recursiveAddFiles(filenames, Path::toNativeSeparators(iter->c_str())); + FileLister::recursiveAddFiles(filenames, Path::toNativeSeparators(*iter)); } if (!filenames.empty()) diff --git a/cli/filelister.cpp b/cli/filelister.cpp index 2c15d92dd..4ce7a1b07 100644 --- a/cli/filelister.cpp +++ b/cli/filelister.cpp @@ -20,31 +20,9 @@ #include #include #include +#include #include "filelister.h" - -#if defined(_WIN32) -#include "filelister_win32.h" -#else // POSIX-style system -#include "filelister_unix.h" -#endif - -// We have one singleton FileLister. - -static FileLister *fileLister; - -FileLister * getFileLister() -{ - if (fileLister == NULL) - { -#if defined(_WIN32) - fileLister = new FileListerWin32; -#else // POSIX-style system - fileLister = new FileListerUnix; -#endif - return fileLister; - } - return fileLister; -} +#include "path.h" // This wrapper exists because Sun's CC does not allow a static_cast // from extern "C" int(*)(int) to int(*)(int). @@ -75,3 +53,276 @@ bool FileLister::acceptFile(const std::string &filename) return false; } + + +#ifdef _WIN32 + +/////////////////////////////////////////////////////////////////////////////// +////// This code is WIN32 systems ///////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// + +#include +#ifndef __BORLANDC__ +#include +#endif + +// Here is the catch: cppcheck core is Ansi code (using char type). +// When compiling Unicode targets WinAPI automatically uses *W Unicode versions +// of called functions. So we must convert data given to WinAPI functions from +// ANSI to Unicode. Likewise we must convert data we get from WinAPI from +// Unicode to ANSI. + +// Note that qmake creates VS project files that define UNICODE but don't +// define _UNICODE! Which means e.g. TCHAR macros don't work properly. + +#if defined(UNICODE) + +static bool TransformUcs2ToAnsi(LPCWSTR psUcs, LPSTR psAnsi, int nAnsi) +{ + WideCharToMultiByte(CP_ACP, 0, psUcs, -1, psAnsi, nAnsi, NULL, NULL); + return true; +} + +static bool TransformAnsiToUcs2(LPCSTR psAnsi, LPWSTR psUcs, UINT nUcs) +{ + MultiByteToWideChar(CP_ACP, 0, psAnsi, -1, psUcs, nUcs); + return true; +} + +static BOOL MyIsDirectory(std::string path) +{ + WCHAR * unicodeCleanPath = new WCHAR[path.size() + 1]; + TransformAnsiToUcs2(path.c_str(), unicodeCleanPath, + (path.size() * sizeof(WCHAR)) + 1); + // See http://msdn.microsoft.com/en-us/library/bb773621(VS.85).aspx + BOOL res = PathIsDirectory(unicodeCleanPath); + delete [] unicodeCleanPath; + return res; +} + +static HANDLE MyFindFirstFile(std::string path, LPWIN32_FIND_DATA findData) +{ + WCHAR * unicodeOss = new wchar_t[path.size() + 1]; + TransformAnsiToUcs2(path.c_str(), unicodeOss, (path.size() + 1) * sizeof(WCHAR)); + HANDLE hFind = FindFirstFile(unicodeOss, findData); + delete [] unicodeOss; + return hFind; +} + +#else // defined(UNICODE) + +static BOOL MyIsDirectory(std::string path) +{ +#ifdef __BORLANDC__ + return (GetFileAttributes(path.c_str()) & FILE_ATTRIBUTE_DIRECTORY); +#else +// See http://msdn.microsoft.com/en-us/library/bb773621(VS.85).aspx + return PathIsDirectory(path.c_str()); +#endif +} + +static HANDLE MyFindFirstFile(std::string path, LPWIN32_FIND_DATA findData) +{ + HANDLE hFind = FindFirstFile(path.c_str(), findData); + return hFind; +} + +#endif // defined(UNICODE) + +void FileLister::recursiveAddFiles(std::vector &filenames, const std::string &path) +{ + // oss is the search string passed into FindFirst and FindNext. + // bdir is the base directory which is used to form pathnames. + // It always has a trailing backslash available for concatenation. + std::ostringstream bdir, oss; + + std::string cleanedPath = Path::toNativeSeparators(path); + + oss << cleanedPath; + + if (MyIsDirectory(cleanedPath.c_str())) + { + char c = cleanedPath[ cleanedPath.size()-1 ]; + switch (c) + { + case '\\': + oss << '*'; + bdir << cleanedPath; + break; + case '*': + bdir << cleanedPath.substr(0, cleanedPath.length() - 1); + break; + default: + oss << "\\*"; + if (cleanedPath != ".") + bdir << cleanedPath << '\\'; + } + } + else + { + std::string::size_type pos; + pos = cleanedPath.find_last_of('\\'); + if (std::string::npos != pos) + { + bdir << cleanedPath.substr(0, pos + 1); + } + } + + WIN32_FIND_DATA ffd; + HANDLE hFind = MyFindFirstFile(oss.str(), &ffd); + if (INVALID_HANDLE_VALUE == hFind) + return; + + do + { + if (ffd.cFileName[0] == '.' || ffd.cFileName[0] == '\0') + continue; + +#if defined(UNICODE) + char * ansiFfd = new char[wcslen(ffd.cFileName) + 1]; + TransformUcs2ToAnsi(ffd.cFileName, ansiFfd, wcslen(ffd.cFileName) + 1); +#else // defined(UNICODE) + const char * ansiFfd = &ffd.cFileName[0]; + if (strchr(ansiFfd,'?')) + { + ansiFfd = &ffd.cAlternateFileName[0]; + } +#endif // defined(UNICODE) + + std::ostringstream fname; + fname << bdir.str().c_str() << ansiFfd; + + if ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + { + // File + + // If recursive is not used, accept all files given by user + if (Path::sameFileName(path,ansiFfd) || FileLister::acceptFile(ansiFfd)) + { + const std::string nativename = Path::fromNativeSeparators(fname.str()); + filenames.push_back(nativename); + } + } + else + { + // Directory + FileLister::recursiveAddFiles(filenames, fname.str()); + } +#if defined(UNICODE) + delete [] ansiFfd; +#endif // defined(UNICODE) + } + while (FindNextFile(hFind, &ffd) != FALSE); + + if (INVALID_HANDLE_VALUE != hFind) + { + FindClose(hFind); + hFind = INVALID_HANDLE_VALUE; + } +} + +bool FileLister::isDirectory(const std::string &path) +{ + return (MyIsDirectory(path) != FALSE); +} + + + + +#else + +/////////////////////////////////////////////////////////////////////////////// +////// This code is POSIX-style systems /////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include + +void FileLister::recursiveAddFiles2(std::vector &relative, + std::vector &absolute, + const std::string &path) +{ + std::ostringstream oss; + oss << path; + if (path.length() > 0 && path[path.length()-1] == '/') + oss << "*"; + + glob_t glob_results; + glob(oss.str().c_str(), GLOB_MARK, 0, &glob_results); + for (unsigned int i = 0; i < glob_results.gl_pathc; i++) + { + const std::string filename = glob_results.gl_pathv[i]; + if (filename == "." || filename == ".." || filename.length() == 0) + continue; + + if (filename[filename.length()-1] != '/') + { + // File +#ifdef PATH_MAX + char fname[PATH_MAX]; + if (realpath(filename.c_str(), fname) == NULL) +#else + char *fname; + if ((fname = realpath(filename.c_str(), NULL)) == NULL) +#endif + { + continue; + } + + // Does absolute path exist? then bail out + if (std::find(absolute.begin(), absolute.end(), std::string(fname)) != absolute.end()) + { +#ifndef PATH_MAX + free(fname); +#endif + continue; + } + + if (Path::sameFileName(path,filename) || FileLister::acceptFile(filename)) + { + relative.push_back(filename); + absolute.push_back(fname); + } + +#ifndef PATH_MAX + free(fname); +#endif + } + else + { + // Directory + recursiveAddFiles2(relative, absolute, filename); + } + } + globfree(&glob_results); +} + + +void FileLister::recursiveAddFiles(std::vector &filenames, const std::string &path) +{ + std::vector abs; + recursiveAddFiles2(filenames, abs, path); +} + +bool FileLister::isDirectory(const std::string &path) +{ + bool ret = false; + + glob_t glob_results; + glob(path.c_str(), GLOB_MARK, 0, &glob_results); + if (glob_results.gl_pathc == 1) + { + const std::string glob_path = glob_results.gl_pathv[0]; + if (!glob_path.empty() && glob_path[glob_path.size() - 1] == '/') + { + ret = true; + } + } + globfree(&glob_results); + + return ret; +} + +#endif diff --git a/cli/filelister.h b/cli/filelister.h index 4c6cd7d03..b2ee6569e 100644 --- a/cli/filelister.h +++ b/cli/filelister.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef FileListerH -#define FileListerH +#ifndef filelisterH +#define filelisterH #include #include @@ -25,19 +25,10 @@ /// @addtogroup CLI /// @{ -/** - * @brief Base class for Cppcheck filelisters. - * Used to recursively search for source files. This class defines a platform - * independant interface and subclasses will provide platform dependant - * implementation. */ +/** @brief Cross-platform FileLister */ class FileLister { public: - /** - * @brief destructor of class filelister - */ - virtual ~FileLister() {} - /** * @brief Recursively add source files to a vector. * Add source files from given directory and all subdirectries to the @@ -46,8 +37,8 @@ public: * @param filenames output vector that filenames are written to * @param path root path */ - virtual void recursiveAddFiles(std::vector &filenames, - const std::string &path) = 0; + static void recursiveAddFiles(std::vector &filenames, + const std::string &path); /** * @brief Check if the file extension indicates that it's a source file. @@ -61,12 +52,15 @@ public: * @brief Is given path a directory? * @return returns true if the path is a directory */ - virtual bool isDirectory(const std::string &path) = 0; -}; + static bool isDirectory(const std::string &path); -/** @brief get filelister (platform dependent implementation) */ -FileLister * getFileLister(); +#ifndef _WIN32 + static void recursiveAddFiles2(std::vector &relative, + std::vector &absolute, + const std::string &path); +#endif +}; /// @} -#endif // #ifndef FileListerH +#endif // #ifndef filelisterH diff --git a/cli/filelister_unix.cpp b/cli/filelister_unix.cpp deleted file mode 100644 index e961f9a84..000000000 --- a/cli/filelister_unix.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include - -#ifndef _WIN32 // POSIX-style system -#include -#include -#include -#include -#endif - -#ifndef _WIN32 - -#include "path.h" -#include "filelister.h" -#include "filelister_unix.h" - -/////////////////////////////////////////////////////////////////////////////// -////// This code is POSIX-style systems /////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - - -void FileListerUnix::recursiveAddFiles2(std::vector &relative, - std::vector &absolute, - const std::string &path) -{ - std::ostringstream oss; - oss << path; - if (path.length() > 0 && path[path.length()-1] == '/') - oss << "*"; - - glob_t glob_results; - glob(oss.str().c_str(), GLOB_MARK, 0, &glob_results); - for (unsigned int i = 0; i < glob_results.gl_pathc; i++) - { - const std::string filename = glob_results.gl_pathv[i]; - if (filename == "." || filename == ".." || filename.length() == 0) - continue; - - if (filename[filename.length()-1] != '/') - { - // File -#ifdef PATH_MAX - char fname[PATH_MAX]; - if (realpath(filename.c_str(), fname) == NULL) -#else - char *fname; - if ((fname = realpath(filename.c_str(), NULL)) == NULL) -#endif - { - continue; - } - - // Does absolute path exist? then bail out - if (std::find(absolute.begin(), absolute.end(), std::string(fname)) != absolute.end()) - { -#ifndef PATH_MAX - free(fname); -#endif - continue; - } - - if (Path::sameFileName(path,filename) || FileLister::acceptFile(filename)) - { - relative.push_back(filename); - absolute.push_back(fname); - } - -#ifndef PATH_MAX - free(fname); -#endif - } - else - { - // Directory - recursiveAddFiles2(relative, absolute, filename); - } - } - globfree(&glob_results); -} - - -void FileListerUnix::recursiveAddFiles(std::vector &filenames, const std::string &path) -{ - std::vector abs; - recursiveAddFiles2(filenames, abs, path); -} - -bool FileListerUnix::isDirectory(const std::string &path) -{ - bool ret = false; - - glob_t glob_results; - glob(path.c_str(), GLOB_MARK, 0, &glob_results); - if (glob_results.gl_pathc == 1) - { - const std::string glob_path = glob_results.gl_pathv[0]; - if (!glob_path.empty() && glob_path[glob_path.size() - 1] == '/') - { - ret = true; - } - } - globfree(&glob_results); - - return ret; -} - -#endif // _WIN32 diff --git a/cli/filelister_unix.h b/cli/filelister_unix.h deleted file mode 100644 index 594580f0d..000000000 --- a/cli/filelister_unix.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef FileListerUnixH -#define FileListerUnixH - -#include -#include -#include "filelister.h" - -/// @addtogroup CLI -/// @{ - - -class FileListerUnix : public FileLister -{ -public: - virtual void recursiveAddFiles(std::vector &filenames, const std::string &path); - virtual bool isDirectory(const std::string &path); -private: -#ifndef _WIN32 - void recursiveAddFiles2(std::vector &relative, - std::vector &absolute, - const std::string &path); -#endif -}; - -/// @} - -#endif // #ifndef FileListerUnixH diff --git a/cli/filelister_win32.cpp b/cli/filelister_win32.cpp deleted file mode 100644 index 776e0245a..000000000 --- a/cli/filelister_win32.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include - -#include "filelister.h" -#include "filelister_win32.h" -#include "path.h" - -#if defined(_WIN32) -#include -#ifndef __BORLANDC__ -#include -#endif -#endif - - -#if defined(_WIN32) - -// Here is the catch: cppcheck core is Ansi code (using char type). -// When compiling Unicode targets WinAPI automatically uses *W Unicode versions -// of called functions. So we must convert data given to WinAPI functions from -// ANSI to Unicode. Likewise we must convert data we get from WinAPI from -// Unicode to ANSI. - -// Note that qmake creates VS project files that define UNICODE but don't -// define _UNICODE! Which means e.g. TCHAR macros don't work properly. - -#if defined(UNICODE) - -static bool TransformUcs2ToAnsi(LPCWSTR psUcs, LPSTR psAnsi, int nAnsi) -{ - WideCharToMultiByte(CP_ACP, 0, psUcs, -1, psAnsi, nAnsi, NULL, NULL); - return true; -} - -static bool TransformAnsiToUcs2(LPCSTR psAnsi, LPWSTR psUcs, UINT nUcs) -{ - MultiByteToWideChar(CP_ACP, 0, psAnsi, -1, psUcs, nUcs); - return true; -} - -static BOOL MyIsDirectory(std::string path) -{ - WCHAR * unicodeCleanPath = new WCHAR[path.size() + 1]; - TransformAnsiToUcs2(path.c_str(), unicodeCleanPath, - (path.size() * sizeof(WCHAR)) + 1); - // See http://msdn.microsoft.com/en-us/library/bb773621(VS.85).aspx - BOOL res = PathIsDirectory(unicodeCleanPath); - delete [] unicodeCleanPath; - return res; -} - -static HANDLE MyFindFirstFile(std::string path, LPWIN32_FIND_DATA findData) -{ - WCHAR * unicodeOss = new wchar_t[path.size() + 1]; - TransformAnsiToUcs2(path.c_str(), unicodeOss, (path.size() + 1) * sizeof(WCHAR)); - HANDLE hFind = FindFirstFile(unicodeOss, findData); - delete [] unicodeOss; - return hFind; -} - -#else // defined(UNICODE) - -static BOOL MyIsDirectory(std::string path) -{ -#ifdef __BORLANDC__ - return (GetFileAttributes(path.c_str()) & FILE_ATTRIBUTE_DIRECTORY); -#else -// See http://msdn.microsoft.com/en-us/library/bb773621(VS.85).aspx - return PathIsDirectory(path.c_str()); -#endif -} - -static HANDLE MyFindFirstFile(std::string path, LPWIN32_FIND_DATA findData) -{ - HANDLE hFind = FindFirstFile(path.c_str(), findData); - return hFind; -} - -#endif // defined(UNICODE) - -void FileListerWin32::recursiveAddFiles(std::vector &filenames, const std::string &path) -{ - // oss is the search string passed into FindFirst and FindNext. - // bdir is the base directory which is used to form pathnames. - // It always has a trailing backslash available for concatenation. - std::ostringstream bdir, oss; - - std::string cleanedPath = Path::toNativeSeparators(path); - - oss << cleanedPath; - - if (MyIsDirectory(cleanedPath.c_str())) - { - char c = cleanedPath[ cleanedPath.size()-1 ]; - switch (c) - { - case '\\': - oss << '*'; - bdir << cleanedPath; - break; - case '*': - bdir << cleanedPath.substr(0, cleanedPath.length() - 1); - break; - default: - oss << "\\*"; - if (cleanedPath != ".") - bdir << cleanedPath << '\\'; - } - } - else - { - std::string::size_type pos; - pos = cleanedPath.find_last_of('\\'); - if (std::string::npos != pos) - { - bdir << cleanedPath.substr(0, pos + 1); - } - } - - WIN32_FIND_DATA ffd; - HANDLE hFind = MyFindFirstFile(oss.str(), &ffd); - if (INVALID_HANDLE_VALUE == hFind) - return; - - do - { - if (ffd.cFileName[0] == '.' || ffd.cFileName[0] == '\0') - continue; - -#if defined(UNICODE) - char * ansiFfd = new char[wcslen(ffd.cFileName) + 1]; - TransformUcs2ToAnsi(ffd.cFileName, ansiFfd, wcslen(ffd.cFileName) + 1); -#else // defined(UNICODE) - const char * ansiFfd = &ffd.cFileName[0]; - if (strchr(ansiFfd,'?')) - { - ansiFfd = &ffd.cAlternateFileName[0]; - } -#endif // defined(UNICODE) - - std::ostringstream fname; - fname << bdir.str().c_str() << ansiFfd; - - if ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) - { - // File - - // If recursive is not used, accept all files given by user - if (Path::sameFileName(path,ansiFfd) || FileLister::acceptFile(ansiFfd)) - { - const std::string nativename = Path::fromNativeSeparators(fname.str()); - filenames.push_back(nativename); - } - } - else - { - // Directory - getFileLister()->recursiveAddFiles(filenames, fname.str()); - } -#if defined(UNICODE) - delete [] ansiFfd; -#endif // defined(UNICODE) - } - while (FindNextFile(hFind, &ffd) != FALSE); - - if (INVALID_HANDLE_VALUE != hFind) - { - FindClose(hFind); - hFind = INVALID_HANDLE_VALUE; - } -} - -bool FileListerWin32::isDirectory(const std::string &path) -{ - return (MyIsDirectory(path) != FALSE); -} - -#endif // _WIN32 diff --git a/cli/filelister_win32.h b/cli/filelister_win32.h deleted file mode 100644 index 1095c79d7..000000000 --- a/cli/filelister_win32.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef FileListerWin32H -#define FileListerWin32H - -#include -#include -#include "filelister.h" - -/// @addtogroup CLI -/// @{ - - -class FileListerWin32 : public FileLister -{ -public: - virtual void recursiveAddFiles(std::vector &filenames, const std::string &path); - virtual bool isDirectory(const std::string &path); -private: - -}; - -/// @} - -#endif // #ifndef FileListerWin32H diff --git a/gui/cppcheck_de.ts b/gui/cppcheck_de.ts index 4d41ecd63..cca70d731 100644 --- a/gui/cppcheck_de.ts +++ b/gui/cppcheck_de.ts @@ -20,8 +20,8 @@ - Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. - Copyright (C) 2007-2010 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2011 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. Copyright (C) 2007-2010 Daniel Marjamäki und das Cppcheck-Team. @@ -220,12 +220,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -537,97 +537,97 @@ kate -l(line) (file) &Hilfe - + Select files to check Dateien zum Überprüfen auswählen - + Select directory to check Verzeichnis zum Überprüfen auswählen - + No suitable files found to check! Kein passenden Dateien zum Überprüfen gefunden! - + License Lizenz - + Authors Autoren - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML-Dateien (*.xml);;Textdateien (*.txt);;CSV-Dateien (*.csv) - + Save the report file Speichert die Berichtdatei - + XML files (*.xml) XML-Dateien (*.xml) - + You must close the project file before selecting new files or directories! - + - + Project: - + Open the report file - + Checking is running. Do you want to stop the checking and exit Cppcheck?. - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) Textdateien (*.txt) - + CSV files (*.csv) CSV-Dateien (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -649,24 +649,24 @@ Do you want to stop the checking and exit Cppcheck?. - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - + Project files (*.cppcheck);;All files(*.*) @@ -676,12 +676,12 @@ Do you want to stop the checking and exit Cppcheck?. - + Select Project Filename - + No project file loaded @@ -741,7 +741,7 @@ Do you want to stop the checking and exit Cppcheck?. Project - + Cppcheck Cppcheck @@ -751,7 +751,7 @@ Do you want to stop the checking and exit Cppcheck?. - + Could not write the project file. @@ -775,24 +775,28 @@ Do you want to stop the checking and exit Cppcheck?. + Paths: + Add... + Edit + Remove @@ -806,6 +810,11 @@ Do you want to stop the checking and exit Cppcheck?. Include directories: + + + Ignore + + Defines: @@ -820,15 +829,20 @@ Do you want to stop the checking and exit Cppcheck?. - + Select include directory - + Select directory to check Verzeichnis zum Überprüfen auswählen + + + Select directory to ignore + + QObject @@ -858,25 +872,25 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File Datei - + Severity Schweregrad - + Line Zeile - + Summary @@ -886,43 +900,48 @@ Do you want to stop the checking and exit Cppcheck?. Undefinierte Datei - + + debug + + + + Copy filename Dateiname kopieren - + Copy full path Vollständigen Pfad kopieren - + Copy message Meldung kopieren - + Hide - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. Konfigurieren Sie das Text-Dateibetrachter-Programm unter Einstellungen/Anwendungen. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. @@ -931,44 +950,44 @@ Please check the application path and parameters are correct. Bitte überprüfen Sie ob der Pfad und die Parameter der Anwendung richtig eingestellt sind. - + Could not find file: %1 Please select the directory where file is located. - + Select Directory - + style Stil - + error Fehler - + warning - + performance - + portability - + information diff --git a/gui/cppcheck_en.ts b/gui/cppcheck_en.ts index 926c62f56..480338c6d 100644 --- a/gui/cppcheck_en.ts +++ b/gui/cppcheck_en.ts @@ -20,8 +20,8 @@ - Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. - Copyright (C) 2007-2010 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2011 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team. @@ -222,12 +222,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -539,97 +539,97 @@ kate -l(line) (file) &Help - + Select files to check Select files to check - + Select directory to check Select directory to check - + No suitable files found to check! No suitable files found to check! - + License License - + Authors Authors - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Save the report file Save the report file - + XML files (*.xml) XML files (*.xml) - + You must close the project file before selecting new files or directories! - + - + Project: - + Open the report file - + Checking is running. Do you want to stop the checking and exit Cppcheck?. - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -649,24 +649,24 @@ Do you want to stop the checking and exit Cppcheck?. %1 - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - + Project files (*.cppcheck);;All files(*.*) @@ -676,12 +676,12 @@ Do you want to stop the checking and exit Cppcheck?. - + Select Project Filename - + No project file loaded @@ -741,7 +741,7 @@ Do you want to stop the checking and exit Cppcheck?. Project - + Cppcheck Cppcheck @@ -751,7 +751,7 @@ Do you want to stop the checking and exit Cppcheck?. - + Could not write the project file. @@ -775,24 +775,28 @@ Do you want to stop the checking and exit Cppcheck?. + Paths: + Add... + Edit + Remove @@ -806,6 +810,11 @@ Do you want to stop the checking and exit Cppcheck?. Include directories: + + + Ignore + + Defines: @@ -820,15 +829,20 @@ Do you want to stop the checking and exit Cppcheck?. - + Select include directory - + Select directory to check Select directory to check + + + Select directory to ignore + + QObject @@ -858,25 +872,25 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File File - + Severity Severity - + Line Line - + Summary @@ -886,43 +900,48 @@ Do you want to stop the checking and exit Cppcheck?. Undefined file - + + debug + + + + Copy filename Copy filename - + Copy full path Copy full path - + Copy message - + Hide - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. You can open this error by specifying applications in program's settings. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. @@ -931,44 +950,44 @@ Please check the application path and parameters are correct. Please check the application path and parameters are correct. - + Could not find file: %1 Please select the directory where file is located. - + Select Directory - + style Style - + error Error - + warning - + performance - + portability - + information diff --git a/gui/cppcheck_fi.ts b/gui/cppcheck_fi.ts index afc617cb1..517bd3527 100644 --- a/gui/cppcheck_fi.ts +++ b/gui/cppcheck_fi.ts @@ -20,8 +20,8 @@ - Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. - Copyright (C) 2007-2010 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2011 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. Copyright (C) 2007-2009 Daniel Marjamäki ja cppcheck tiimi. @@ -224,12 +224,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -541,97 +541,97 @@ kate -l(line) (file) &Ohje - + Select files to check Valitse tarkistettavat tiedostot - + Select directory to check Valitse tarkistettava hakemisto - + No suitable files found to check! Tarkistettavaksi sopivia tiedostoja ei löytynyt! - + License Lisenssi - + Authors Tekijät - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML-tiedostot (*.xml);;Tekstitiedostot (*.txt);;CSV-tiedostot (*.csv) - + Save the report file Tallenna raportti - + XML files (*.xml) XML-tiedostot (*xml) - + You must close the project file before selecting new files or directories! - + - + Project: - + Open the report file - + Checking is running. Do you want to stop the checking and exit Cppcheck?. - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) Tekstitiedostot (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -653,24 +653,24 @@ Do you want to stop the checking and exit Cppcheck?. - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - + Project files (*.cppcheck);;All files(*.*) @@ -680,12 +680,12 @@ Do you want to stop the checking and exit Cppcheck?. - + Select Project Filename - + No project file loaded @@ -745,7 +745,7 @@ Do you want to stop the checking and exit Cppcheck?. Project - + Cppcheck Cppcheck @@ -755,7 +755,7 @@ Do you want to stop the checking and exit Cppcheck?. - + Could not write the project file. @@ -779,24 +779,28 @@ Do you want to stop the checking and exit Cppcheck?. + Paths: + Add... + Edit + Remove @@ -810,6 +814,11 @@ Do you want to stop the checking and exit Cppcheck?. Include directories: + + + Ignore + + Defines: @@ -824,15 +833,20 @@ Do you want to stop the checking and exit Cppcheck?. - + Select include directory - + Select directory to check Valitse tarkistettava hakemisto + + + Select directory to ignore + + QObject @@ -862,25 +876,25 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File Tiedosto - + Severity Tyyppi - + Line Rivi - + Summary @@ -890,43 +904,48 @@ Do you want to stop the checking and exit Cppcheck?. Määrittelemätön tiedosto - + + debug + + + + Copy filename Kopioi tiedostonimi - + Copy full path Kopioi tiedoston koko polku - + Copy message - + Hide - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. Voit asetuksista määritellä muita ohjelmia joilla avata tämän virheen sisältävän tiedoston. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. @@ -935,44 +954,44 @@ Please check the application path and parameters are correct. Tarkista että ohjelman polku ja parametrit ovat oikeat. - + Could not find file: %1 Please select the directory where file is located. - + Select Directory - + style Tyyli - + error Yleinen - + warning - + performance - + portability - + information diff --git a/gui/cppcheck_fr.ts b/gui/cppcheck_fr.ts index 1c512ee03..00826c6e3 100644 --- a/gui/cppcheck_fr.ts +++ b/gui/cppcheck_fr.ts @@ -26,7 +26,7 @@ General Public License version 3 Visitez le site Cppcheck : %1 - Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2011 Daniel Marjamäki and cppcheck team. @@ -631,6 +631,10 @@ Do you want to stop the checking and exit Cppcheck?. Include directories: + + Ignore + + ProjectFileDialog @@ -646,6 +650,10 @@ Do you want to stop the checking and exit Cppcheck?. Select directory to check Sélectionner le répertoire à vérifier + + Select directory to ignore + + QObject @@ -758,6 +766,10 @@ Please select the directory where file is located. information + + debug + + ResultsView diff --git a/gui/cppcheck_ja.ts b/gui/cppcheck_ja.ts index 9b244d533..3fea0bf5b 100644 --- a/gui/cppcheck_ja.ts +++ b/gui/cppcheck_ja.ts @@ -20,9 +20,9 @@ - Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. - Copyright (C) 2007-2010 Daniel Marjamäki and cppcheck team. - + Copyright © 2007-2011 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. + @@ -208,12 +208,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -525,44 +525,44 @@ kate -l(line) (file) ログ表示 - + No suitable files found to check! 解析可能なファイルではありません - + You must close the project file before selecting new files or directories! 新しいファイル/ディレクトリを解析するには現在のプロジェクトを閉じてください - + Select files to check チェック対象のファイルを選択 - + Select directory to check チェック対象のディレクトリを選択 - + - + Project: プロジェクト: - + XML files (*.xml) XML ファイル (*.xml) - + Open the report file レポートを開く - + Checking is running. Do you want to stop the checking and exit Cppcheck?. @@ -571,53 +571,53 @@ Do you want to stop the checking and exit Cppcheck?. 解析を停止してCppcheckを終了しますか?. - + License ライセンス - + Authors 作者 - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML ファイル (*.xml);;テキストファイル (*.txt);;CSV形式ファイル (*.csv) - + Save the report file レポートを保存 - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) テキストファイル (*.txt) - + CSV files (*.csv) CSV形式ファイル (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -636,24 +636,24 @@ Do you want to stop the checking and exit Cppcheck?. - - + + Cppcheck Help Cppcheck ヘルプ - + Failed to load help file (not found) ヘルプファイルが見つかりませんでした - + Failed to load help file ヘルプファイルの読み込みに失敗しました - + Project files (*.cppcheck);;All files(*.*) プロジェクトファイル (*.cppcheck);;All files(*.*) @@ -663,12 +663,12 @@ Do you want to stop the checking and exit Cppcheck?. プロジェクトファイルを選択 - + Select Project Filename プロジェクトファイル名を選択 - + No project file loaded プロジェクトファイルが読み込まれていません @@ -728,7 +728,7 @@ Do you want to stop the checking and exit Cppcheck?. Project - + Cppcheck Cppcheck @@ -738,7 +738,7 @@ Do you want to stop the checking and exit Cppcheck?. プロジェクトファイルが読み込めませんでした - + Could not write the project file. プロジェクトファイルが保存できませんでした @@ -762,24 +762,28 @@ Do you want to stop the checking and exit Cppcheck?. + Paths: パス: + Add... 追加... + Edit + Remove @@ -793,6 +797,11 @@ Do you want to stop the checking and exit Cppcheck?. Include directories: + + + Ignore + + Include paths: Include ディレクトリ: @@ -811,15 +820,20 @@ Do you want to stop the checking and exit Cppcheck?. プロジェクトファイル:%1 - + Select include directory includeディレクトリを選択 - + Select directory to check チェック対象のディレクトリを選択 + + + Select directory to ignore + + QObject @@ -843,25 +857,25 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File ファイル - + Severity 警告種別 - + Line - + Summary 内容 @@ -871,42 +885,47 @@ Do you want to stop the checking and exit Cppcheck?. 未定義ファイル - + + debug + + + + Copy filename ファイル名をコピー - + Copy full path フルパスをコピー - + Copy message メッセージをコピー - + Hide 非表示 - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. メニューの「編集」→「設定」からテキストファイルを表示するアプリケーションを設定してください。 - + Could not find the file! ファイルが見つかりません - + Could not start %1 Please check the application path and parameters are correct. @@ -915,7 +934,7 @@ Please check the application path and parameters are correct. 実行ファイルパスや引数の設定を確認してください。 - + Could not find file: %1 Please select the directory where file is located. @@ -924,37 +943,37 @@ Please select the directory where file is located. ディレクトリにファイルが存在するか確認してください。 - + Select Directory ディレクトリを選択 - + style スタイル - + error エラー - + warning 警告 - + performance パフォーマンス - + portability - + information diff --git a/gui/cppcheck_nl.ts b/gui/cppcheck_nl.ts index 957f80c22..2018fe841 100644 --- a/gui/cppcheck_nl.ts +++ b/gui/cppcheck_nl.ts @@ -20,8 +20,8 @@ - Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. - Copyright (C) 2007-2010 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2011 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. Copyright (C) 2007-2009 Daniel Marjamäki en het cppcheck. @@ -222,12 +222,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -539,97 +539,97 @@ kate -l(line) (file) &Help - + Select files to check Selecteer bestanden om te controleren - + Select directory to check Selecteer een map om te controleren - + No suitable files found to check! Geen geschikte bestanden gevonden om te controleren! - + License Licentie - + Authors Auteurs - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML bestanden (*.xml);;Tekst bestanden (*.txt);;CSV bestanden (*.csv) - + Save the report file Rapport opslaan - + XML files (*.xml) XML bestanden (*.xml) - + You must close the project file before selecting new files or directories! - + - + Project: - + Open the report file - + Checking is running. Do you want to stop the checking and exit Cppcheck?. - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) Tekst bestanden (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -649,24 +649,24 @@ Do you want to stop the checking and exit Cppcheck?. %1 - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - + Project files (*.cppcheck);;All files(*.*) @@ -676,12 +676,12 @@ Do you want to stop the checking and exit Cppcheck?. - + Select Project Filename - + No project file loaded @@ -741,7 +741,7 @@ Do you want to stop the checking and exit Cppcheck?. Project - + Cppcheck Cppcheck @@ -751,7 +751,7 @@ Do you want to stop the checking and exit Cppcheck?. - + Could not write the project file. @@ -775,24 +775,28 @@ Do you want to stop the checking and exit Cppcheck?. + Paths: + Add... + Edit + Remove @@ -806,6 +810,11 @@ Do you want to stop the checking and exit Cppcheck?. Include directories: + + + Ignore + + Defines: @@ -820,15 +829,20 @@ Do you want to stop the checking and exit Cppcheck?. - + Select include directory - + Select directory to check Selecteer een map om te controleren + + + Select directory to ignore + + QObject @@ -858,25 +872,25 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File Bestand - + Severity Ernst - + Line Regel - + Summary @@ -886,43 +900,48 @@ Do you want to stop the checking and exit Cppcheck?. Niet gedefinieerd bestand - + + debug + + + + Copy filename Kopier bestandsnaam - + Copy full path Kopieer volledig pad - + Copy message - + Hide - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. U dient een applicatie te configureren in de instellingen om deze fout in te openen. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. @@ -931,44 +950,44 @@ Please check the application path and parameters are correct. Gelieve te controleren of de het pad en de parameters correct zijn. - + Could not find file: %1 Please select the directory where file is located. - + Select Directory - + style Stijlfouten - + error Fouten - + warning - + performance - + portability - + information diff --git a/gui/cppcheck_pl.ts b/gui/cppcheck_pl.ts index e00aa58de..3cd5d6cd3 100644 --- a/gui/cppcheck_pl.ts +++ b/gui/cppcheck_pl.ts @@ -20,8 +20,8 @@ - Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. - Copyright (C) 2007-2010 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2011 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. @@ -209,12 +209,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck @@ -526,131 +526,131 @@ kate -l(line) (file) - + No suitable files found to check! - + You must close the project file before selecting new files or directories! - + Select files to check - + Select directory to check - + - + Project: - + Open the report file - + License - + Authors - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Save the report file - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Failed to change the language: %1 - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - + Select Project Filename - + No project file loaded - + XML files (*.xml) - + Checking is running. Do you want to stop the checking and exit Cppcheck?. - + Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 - + Project files (*.cppcheck);;All files(*.*) @@ -715,7 +715,7 @@ Do you want to stop the checking and exit Cppcheck?. Project - + Cppcheck @@ -725,7 +725,7 @@ Do you want to stop the checking and exit Cppcheck?. - + Could not write the project file. @@ -749,24 +749,28 @@ Do you want to stop the checking and exit Cppcheck?. + Paths: + Add... + Edit + Remove @@ -780,6 +784,11 @@ Do you want to stop the checking and exit Cppcheck?. Include directories: + + + Ignore + + Defines: @@ -794,15 +803,20 @@ Do you want to stop the checking and exit Cppcheck?. - + Select include directory - + Select directory to check + + + Select directory to ignore + + QObject @@ -826,25 +840,25 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File - + Severity - + Line - + Summary @@ -854,86 +868,91 @@ Do you want to stop the checking and exit Cppcheck?. - + + debug + + + + Copy filename - + Copy full path - + Copy message - + Hide - + Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. - + Could not find file: %1 Please select the directory where file is located. - + Select Directory - + style - + error - + warning - + performance - + portability - + information diff --git a/gui/cppcheck_ru.ts b/gui/cppcheck_ru.ts index 8f66703e5..c5e39377c 100644 --- a/gui/cppcheck_ru.ts +++ b/gui/cppcheck_ru.ts @@ -20,8 +20,8 @@ - Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. - Copyright (C) 2007-2010 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2011 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. @@ -212,12 +212,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -529,97 +529,97 @@ kate -l(line) (file) Помощь - + Select files to check Выберите файлы для проверки - + Select directory to check Выберите каталог для проверки - + No suitable files found to check! - + License Лицензия - + Authors Авторы - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Save the report file - + XML files (*.xml) - + You must close the project file before selecting new files or directories! - + - + Project: - + Open the report file - + Checking is running. Do you want to stop the checking and exit Cppcheck?. - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) Текстовые файлы (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -641,24 +641,24 @@ Do you want to stop the checking and exit Cppcheck?. - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - + Project files (*.cppcheck);;All files(*.*) @@ -668,12 +668,12 @@ Do you want to stop the checking and exit Cppcheck?. - + Select Project Filename - + No project file loaded @@ -733,7 +733,7 @@ Do you want to stop the checking and exit Cppcheck?. Project - + Cppcheck Cppcheck @@ -743,7 +743,7 @@ Do you want to stop the checking and exit Cppcheck?. - + Could not write the project file. @@ -767,24 +767,28 @@ Do you want to stop the checking and exit Cppcheck?. + Paths: + Add... + Edit + Remove @@ -798,6 +802,11 @@ Do you want to stop the checking and exit Cppcheck?. Include directories: + + + Ignore + + Defines: @@ -812,15 +821,20 @@ Do you want to stop the checking and exit Cppcheck?. - + Select include directory - + Select directory to check Выберите каталог для проверки + + + Select directory to ignore + + QObject @@ -850,25 +864,25 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File Файл - + Severity Важность - + Line Строка - + Summary @@ -878,87 +892,92 @@ Do you want to stop the checking and exit Cppcheck?. - + + debug + + + + Copy filename Скопировать имя файла - + Copy full path Скопировать полный путь - + Copy message - + Hide - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. - + Could not find file: %1 Please select the directory where file is located. - + Select Directory - + style - + error - + warning - + performance - + portability - + information diff --git a/gui/cppcheck_sr.ts b/gui/cppcheck_sr.ts index fa23f823a..da345b890 100644 --- a/gui/cppcheck_sr.ts +++ b/gui/cppcheck_sr.ts @@ -20,8 +20,8 @@ - Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. - Copyright (C) 2007-2010 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2011 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team. @@ -222,12 +222,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -539,97 +539,97 @@ kate -l(line) (file) &Help - + Select files to check Select files to check - + Select directory to check Select directory to check - + No suitable files found to check! No suitable files found to check! - + License License - + Authors Authors - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Save the report file Save the report file - + XML files (*.xml) XML files (*.xml) - + You must close the project file before selecting new files or directories! - + - + Project: - + Open the report file - + Checking is running. Do you want to stop the checking and exit Cppcheck?. - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -649,24 +649,24 @@ Do you want to stop the checking and exit Cppcheck?. %1 - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - + Project files (*.cppcheck);;All files(*.*) @@ -676,12 +676,12 @@ Do you want to stop the checking and exit Cppcheck?. - + Select Project Filename - + No project file loaded @@ -741,7 +741,7 @@ Do you want to stop the checking and exit Cppcheck?. Project - + Cppcheck Cppcheck @@ -751,7 +751,7 @@ Do you want to stop the checking and exit Cppcheck?. - + Could not write the project file. @@ -775,24 +775,28 @@ Do you want to stop the checking and exit Cppcheck?. + Paths: + Add... + Edit + Remove @@ -806,6 +810,11 @@ Do you want to stop the checking and exit Cppcheck?. Include directories: + + + Ignore + + Defines: @@ -820,15 +829,20 @@ Do you want to stop the checking and exit Cppcheck?. - + Select include directory - + Select directory to check Select directory to check + + + Select directory to ignore + + QObject @@ -858,25 +872,25 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File File - + Severity Severity - + Line Line - + Summary @@ -886,43 +900,48 @@ Do you want to stop the checking and exit Cppcheck?. Undefined file - + + debug + + + + Copy filename Copy filename - + Copy full path Copy full path - + Copy message - + Hide - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. You can open this error by specifying applications in program's settings. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. @@ -931,44 +950,44 @@ Please check the application path and parameters are correct. Please check the application path and parameters are correct. - + Could not find file: %1 Please select the directory where file is located. - + Select Directory - + style Style - + error Error - + warning - + performance - + portability - + information diff --git a/gui/cppcheck_se.ts b/gui/cppcheck_sv.ts similarity index 92% rename from gui/cppcheck_se.ts rename to gui/cppcheck_sv.ts index 3cdea4876..80eec52ce 100644 --- a/gui/cppcheck_se.ts +++ b/gui/cppcheck_sv.ts @@ -20,9 +20,9 @@ - Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. - Copyright (C) 2007-2010 Daniel Marjamäki and cppcheck team. - Copyright (C) 2007-2010 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2011 Daniel Marjamäki and cppcheck team. + Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. + Copyright (C) 2007-2010 Daniel Marjamäki and cppcheck team. @@ -222,12 +222,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -540,65 +540,65 @@ kate -l(line) (file) &Hjälp - + Select files to check Välj filer att kontrollera - + Select directory to check Välj katalog som skall kontrolleras - + No suitable files found to check! Inga lämpliga filer hittades! - + License Licens - + Authors Utvecklare - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML filer (*.xml);;Text filer (*.txt);;CSV filer (*.csv) - + Save the report file Spara rapport - + XML files (*.xml) XML filer (*.xml) - + You must close the project file before selecting new files or directories! Du måste stänga projektfilen innan nya filer eller sökvägar kan väljas! - + - + Project: Projekt. - + Open the report file Öppna rapportfilen - + Checking is running. Do you want to stop the checking and exit Cppcheck?. @@ -607,32 +607,32 @@ Do you want to stop the checking and exit Cppcheck?. Vill du stoppa analysen och avsluta Cppcheck? - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) Text filer (*.txt) - + CSV files (*.csv) CSV filer (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -654,24 +654,24 @@ Vill du stoppa analysen och avsluta Cppcheck? - - + + Cppcheck Help Cppcheck Hjälp - + Failed to load help file (not found) Misslyckades att öppna hjälpfilen (hittades ej) - + Failed to load help file Misslykades att öppna hjälpfilen - + Project files (*.cppcheck);;All files(*.*) Projektfiler (*.cppcheck);;Alla filer(*.*) @@ -681,12 +681,12 @@ Vill du stoppa analysen och avsluta Cppcheck? Välj projektfil - + Select Project Filename Välj Projektfil - + No project file loaded Inget projekt laddat @@ -746,7 +746,7 @@ Vill du stoppa analysen och avsluta Cppcheck? Project - + Cppcheck Cppcheck @@ -756,7 +756,7 @@ Vill du stoppa analysen och avsluta Cppcheck? Kunde ej läsa projektfilen. - + Could not write the project file. Kunde ej skriva projektfilen @@ -780,24 +780,28 @@ Vill du stoppa analysen och avsluta Cppcheck? + Paths: Sökvägar: + Add... Lägg till... + Edit + Remove @@ -811,6 +815,11 @@ Vill du stoppa analysen och avsluta Cppcheck? Include directories: + + + Ignore + + Browse... Bläddra... @@ -833,15 +842,20 @@ Vill du stoppa analysen och avsluta Cppcheck? Projektfil: %1 - + Select include directory Välj include sökväg - + Select directory to check Välj katalog som skall kontrolleras + + + Select directory to ignore + + QObject @@ -871,25 +885,25 @@ Vill du stoppa analysen och avsluta Cppcheck? ResultsTree - + File Fil - + Severity Typ - + Line Rad - + Summary Sammanfattning @@ -899,43 +913,48 @@ Vill du stoppa analysen och avsluta Cppcheck? Odefinierad fil - + + debug + + + + Copy filename Kopiera filnamn - + Copy full path Kopiera full sökväg - + Copy message Kopiera meddelande - + Hide Dölj - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. Konfigurera program i inställningar/program. - + Could not find the file! Kunde inte hitta filen! - + Could not start %1 Please check the application path and parameters are correct. @@ -944,7 +963,7 @@ Please check the application path and parameters are correct. Kontrollera att sökvägen och parametrarna är korrekta. - + Could not find file: %1 Please select the directory where file is located. @@ -953,37 +972,37 @@ Please select the directory where file is located. Välj mappen där filen finns. - + Select Directory Välj mapp - + style stil - + error fel - + warning varning - + performance prestanda - + portability portabilitet - + information information diff --git a/gui/gui.pro b/gui/gui.pro index 26428b4ed..a238a6262 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -38,7 +38,7 @@ TRANSLATIONS = cppcheck_fi.ts \ cppcheck_fr.ts \ cppcheck_nl.ts \ cppcheck_en.ts \ - cppcheck_se.ts \ + cppcheck_sv.ts \ cppcheck_de.ts \ cppcheck_pl.ts \ cppcheck_ru.ts \ diff --git a/gui/translationhandler.cpp b/gui/translationhandler.cpp index 6a1cb1d9a..646d04c4c 100644 --- a/gui/translationhandler.cpp +++ b/gui/translationhandler.cpp @@ -38,7 +38,7 @@ TranslationHandler::TranslationHandler(QObject *parent) : AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Polish"), "cppcheck_pl"); AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Russian"), "cppcheck_ru"); AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Serbian"), "cppcheck_sr"); - AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Swedish"), "cppcheck_se"); + AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Swedish"), "cppcheck_sv"); //Load English as a fallback language QTranslator *english = new QTranslator(); diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index d917ed8ce..0a0f7a3bb 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1446,13 +1446,45 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok) return false; } +static int countParameters(const Token *tok) +{ + if (Token::Match(tok->tokAt(2), "void| )")) + return 0; + + int numpar = 1; + int parlevel = 0; + for (; tok; tok = tok->next()) + { + if (tok->str() == "(") + ++parlevel; + + else if (tok->str() == ")") + { + if (parlevel <= 1) + break; + --parlevel; + } + + else if (parlevel == 1 && tok->str() == ",") + { + ++numpar; + } + } + + return numpar; +} + bool CheckClass::isConstMemberFunc(const Scope *scope, const Token *tok) { + unsigned int args = countParameters(tok); + std::list::const_iterator func; for (func = scope->functionList.begin(); func != scope->functionList.end(); ++func) { - if (func->tokenDef->str() == tok->str() && func->isConst) + /** @todo we need to look at the argument types when there are overloaded functions + * with the same number of arguments */ + if (func->tokenDef->str() == tok->str() && func->argCount() == args && func->isConst) return true; } @@ -1546,7 +1578,17 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Token *tok) // increment/decrement (member variable?).. else if (Token::Match(tok1, "++|--")) { - isconst = false; + if (Token::Match(tok1->previous(), "%var%") && + tok1->previous()->str() != "return") + { + if (isMemberVar(scope, tok1->previous())) + isconst = false; + } + else if (Token::Match(tok1->next(), "%var%")) + { + if (isMemberVar(scope, tok1->next())) + isconst = false; + } break; } diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 92c60ace8..cdd7d4a4e 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -42,25 +42,37 @@ CheckMemoryLeakNoVar instance4; } -// This list needs to be alphabetically sorted so we can run bsearch on it +// This list needs to be alphabetically sorted so we can run bsearch on it. +// This list contains function names whith const parameters e.g.: atof(const char *) +// Reference: http://www.aquaphoenix.com/ref/gnu_c_library/libc_492.html#SEC492 static const char * const call_func_white_list[] = { - "asctime", "asctime_r", "asprintf", "assert", "atof", "atoi", "atol", "clearerr" - , "ctime", "ctime_r", "delete", "fchmod", "fclose", "fcntl" - , "fdatasync", "feof", "ferror", "fflush", "fgetc", "fgetpos", "fgets" - , "flock", "for", "fprintf", "fputc", "fputs", "fread", "free", "fscanf", "fseek" - , "fseeko", "fsetpos", "fstat", "fsync", "ftell", "ftello", "ftruncate" - , "fwrite", "getc", "gets", "gmtime", "gmtime_r", "if", "ioctl" - , "localtime", "localtime_r" - , "lockf", "lseek", "memchr", "memcmp", "memcpy", "memmove", "memset" - , "posix_fadvise", "posix_fallocate", "pread" - , "printf", "puts", "pwrite", "qsort", "read", "readahead", "readdir", "readdir_r", "readv" - , "realloc", "return", "rewind", "rewinddir", "scandir", "scanf", "seekdir" - , "setbuf", "setbuffer", "setlinebuf", "setvbuf", "snprintf", "sprintf", "sscanf", "strcasecmp" - , "strcat", "strchr", "strcmp", "strcpy", "stricmp", "strlen", "strncat", "strncmp" - , "strncpy", "strrchr", "strstr", "strtod", "strtol", "strtoul", "switch" - , "sync_file_range", "telldir", "time", "typeid", "vfprintf", "vprintf" - , "vsnprintf", "vsprintf", "while", "write", "writev" + "_open", "_wopen", "access", "adjtime", "asctime", "asctime_r", "asprintf", "assert" + , "atof", "atoi", "atol", "chdir", "chmod", "chown" + , "clearerr", "creat", "ctime", "ctime_r", "delete", "execl", "execle" + , "execlp", "execv", "execve", "fchmod", "fclose", "fcntl" + , "fdatasync", "fdopen", "feof", "ferror", "fflush", "fgetc", "fgetpos", "fgets" + , "flock", "fmemopen", "fnmatch", "fopen", "fopencookie", "for", "fprintf", "fputc", "fputs", "fread", "free" + , "freopen", "fscanf", "fseek", "fseeko", "fsetpos", "fstat", "fsync", "ftell", "ftello" + , "ftruncate", "fwrite", "getc", "getenv","getgrnam", "gethostbyaddr", "gethostbyname", "getnetbyname" + , "getopt", "getopt_long", "getprotobyname", "getpwnam", "gets", "getservbyname", "getservbyport" + , "glob", "gmtime", "gmtime_r", "if", "index", "inet_addr", "inet_aton", "inet_network", "initgroups", "ioctl" + , "link", "localtime", "localtime_r" + , "lockf", "lseek", "lstat", "mblen", "mbstowcs", "mbtowc", "memchr", "memcmp", "memcpy", "memmove", "memset" + , "mkdir", "mkfifo", "mknod" + , "obstack_printf", "obstack_vprintf", "open", "opendir", "parse_printf_format", "pathconf" + , "perror", "popen" ,"posix_fadvise", "posix_fallocate", "pread" + , "printf", "psignal", "putenv", "puts", "pwrite", "qsort", "read", "readahead", "readdir", "readdir_r" + , "readlink", "readv" + , "realloc", "regcomp", "remove", "rename", "return", "rewind", "rewinddir", "rindex" + , "rmdir" ,"scandir", "scanf", "seekdir" + , "setbuf", "setbuffer", "sethostname", "setlinebuf", "setlocale" ,"setvbuf", "snprintf", "sprintf", "sscanf" + , "stat", "stpcpy", "strcasecmp", "strcat", "strchr", "strcmp", "strcoll" + , "strcpy", "strcspn", "strdup", "stricmp", "strlen", "strncasecmp", "strncat", "strncmp" + , "strncpy", "strpbrk","strrchr", "strspn", "strstr", "strtod", "strtol", "strtoul", "strxfrm", "switch" + , "symlink", "sync_file_range", "system", "telldir", "tempnam", "time", "typeid", "unlink" + , "utime", "utimes", "vasprintf", "vfprintf", "vfscanf", "vprintf" + , "vscanf", "vsnprintf", "vsprintf", "vsscanf", "while", "wordexp","write", "writev" }; static int call_func_white_list_compare(const void *a, const void *b) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 8bcb5c7d8..566839852 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -122,7 +122,7 @@ unsigned int CppCheck::check() std::list configurations; std::string filedata = ""; - if (_fileContents.size() > 0 && _fileContents.find(_filenames[c]) != _fileContents.end()) + if ((!_fileContents.empty()) && (_fileContents.find(_filenames[c]) != _fileContents.end())) { // File content was given as a string std::istringstream iss(_fileContents[ _filenames[c] ]); diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 6c94c572e..bacf7ccd5 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -555,28 +555,20 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti // finish filling in base class info for (unsigned int i = 0; i < scope->derivedFrom.size(); ++i) { - std::list::iterator it1; + std::list::const_iterator it1; + // check all scopes for match for (it1 = scopeList.begin(); it1 != scopeList.end(); ++it1) { - Scope *scope1 = &(*it1); + // check scope for match + const Scope *scope1 = it1->findQualifiedScope(scope->derivedFrom[i].name); - /** @todo handle derived base classes and namespaces */ - if (scope1->type == Scope::eClass || scope1->type == Scope::eStruct) + // found match? + if (scope1) { - // do class names match? - if (scope1->className == scope->derivedFrom[i].name) - { - // are they in the same namespace or different namespaces with same name? - if ((scope1->nestedIn == scope->nestedIn) || - ((scope1->nestedIn && scope1->nestedIn->type == Scope::eNamespace) && - (scope->nestedIn && scope->nestedIn->type == Scope::eNamespace) && - (scope1->nestedIn->className == scope->nestedIn->className))) - { - scope->derivedFrom[i].scope = scope1; - break; - } - } + // set found scope + scope->derivedFrom[i].scope = const_cast(scope1); + break; } } } @@ -1060,12 +1052,20 @@ const Token *SymbolDatabase::initBaseInfo(Scope *scope, const Token *tok) { Scope::BaseInfo base; + base.isVirtual = false; + tok2 = tok2->next(); // check for invalid code if (!tok2 || !tok2->next()) return NULL; + if (tok2->str() == "virtual") + { + base.isVirtual = true; + tok2 = tok2->next(); + } + if (tok2->str() == "public") { base.access = Public; @@ -1089,6 +1089,12 @@ const Token *SymbolDatabase::initBaseInfo(Scope *scope, const Token *tok) base.access = Public; } + if (tok2->str() == "virtual") + { + base.isVirtual = true; + tok2 = tok2->next(); + } + // handle derived base classes while (Token::Match(tok2, "%var% ::")) { @@ -1760,6 +1766,34 @@ Scope * Scope::findInNestedListRecursive(const std::string & name) //--------------------------------------------------------------------------- +const Scope * Scope::findQualifiedScope(const std::string & name) const +{ + if (type == Scope::eClass || type == Scope::eStruct || type == Scope::eNamespace) + { + if (name.compare(0, className.size(), className) == 0) + { + std::string path = name; + path.erase(0, className.size()); + if (path.compare(0, 4, " :: ") == 0) + path.erase(0, 4); + else if (path.empty()) + return this; + + std::list::const_iterator it; + + for (it = nestedList.begin() ; it != nestedList.end(); ++it) + { + const Scope *scope1 = (*it)->findQualifiedScope(path); + if (scope1) + return scope1; + } + } + } + return 0; +} + +//--------------------------------------------------------------------------- + const Function *Scope::getDestructor() const { std::list::const_iterator it; diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index 2d8c733e4..37f94d59c 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -369,6 +369,7 @@ public: struct BaseInfo { AccessControl access; // public/protected/private + bool isVirtual; std::string name; Scope *scope; }; @@ -430,6 +431,8 @@ public: */ Scope * findInNestedListRecursive(const std::string & name); + const Scope * findQualifiedScope(const std::string & name) const; + void addVariable(const Token *token_, const Token *start_, const Token *end_, AccessControl access_, bool mutable_, bool static_, bool const_, bool class_, const Scope *type_, diff --git a/lib/token.cpp b/lib/token.cpp index e40a18fa8..940bb7f09 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -384,21 +384,44 @@ bool Token::Match(const Token *tok, const char pattern[], unsigned int varid) // Compare the first character of the string for optimization reasons // before doing more detailed checks. + bool patternUnderstood = false; if (p[0] == '%') { - // TODO: %var% should match only for - // variables that have varId != 0, but that needs a lot of - // work, before that change can be made. - // Any symbolname.. - if (firstWordEquals(p, "%var%") == 0) + switch (p[1]) { - if (!tok->isName()) - return false; - p += 5; - } + case 'v': + // TODO: %var% should match only for + // variables that have varId != 0, but that needs a lot of + // work, before that change can be made. + // Any symbolname.. + if (p[4] == '%') // %var% + { + if (!tok->isName()) + return false; + p += 5; + patternUnderstood = true; + } + else // %varid% + { + if (varid == 0) + { + std::list locationList; + const ErrorLogger::ErrorMessage errmsg(locationList, + Severity::error, + "Internal error. Token::Match called with varid 0.", + "cppcheckError"); + Check::reportError(errmsg); + } - // Type.. - else if (firstWordEquals(p, "%type%") == 0) + if (tok->varId() != varid) + return false; + + p += 7; + patternUnderstood = true; + } + break; + case 't': + // Type (%type%) { if (!tok->isName()) return false; @@ -410,73 +433,71 @@ bool Token::Match(const Token *tok, const char pattern[], unsigned int varid) return false; p += 6; + patternUnderstood = true; } - - // Accept any token - else if (firstWordEquals(p, "%any%") == 0) + break; + case 'a': + // Accept any token (%any%) { p += 5; + patternUnderstood = true; } - - else if (firstWordEquals(p, "%varid%") == 0) - { - if (varid == 0) - { - std::list locationList; - const ErrorLogger::ErrorMessage errmsg(locationList, - Severity::error, - "Internal error. Token::Match called with varid 0.", - "cppcheckError"); - Check::reportError(errmsg); - } - - if (tok->varId() != varid) - return false; - - p += 7; - } - - else if (firstWordEquals(p, "%num%") == 0) + break; + case 'n': + // Number (%num) { if (!tok->isNumber()) return false; p += 5; + patternUnderstood = true; } - - else if (firstWordEquals(p, "%bool%") == 0) - { - if (!tok->isBoolean()) - return false; - p += 6; - } - - else if (firstWordEquals(p, "%str%") == 0) + break; + case 's': + // String (%str%) { if (tok->_str[0] != '\"') return false; p += 5; + patternUnderstood = true; } - - else if (firstWordEquals(p, "%or%") == 0) + break; + case 'b': + // Bool (%bool%) { - if (tok->str() != "|") - return false; - p += 4; - } - - else if (firstWordEquals(p, "%oror%") == 0) - { - if (tok->str() != "||") + if (!tok->isBoolean()) return false; p += 6; + patternUnderstood = true; + } + break; + case 'o': + // Or (%or%) + if (p[3] == '%') + { + if (tok->str() != "|") + return false; + p += 4; + patternUnderstood = true; + } + // Oror (%oror%) + else + { + if (tok->str() != "||") + return false; + p += 6; + patternUnderstood = true; + } + break; + default: + if (firstWordEquals(p, tok->_str.c_str())) + { + p += tok->_str.length(); + patternUnderstood = true; + } + break; } - else if (firstWordEquals(p, tok->_str.c_str())) - { - p += tok->_str.length(); - } - - else + if (!patternUnderstood) { return false; } diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index f630a4c0a..48955d39c 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3468,7 +3468,8 @@ void Tokenizer::setVarId() tok2 = tok2->next(); again = true; } - else if (level > 1 && Token::Match(tok2, "%type% *|&| >")) + else if (level > 1 && (Token::Match(tok2, "%type% *|&| >") || + Token::Match(tok2, "%num% >"))) { --level; while (tok2->str() != ">") @@ -9316,7 +9317,7 @@ void Tokenizer::simplifyBitfields() Token *last = 0; if (Token::Match(tok, ";|{|}|public:|protected:|private: const| %type% %var% :") && - !Token::Match(tok->next(), "case|public|protected|private")) + !Token::Match(tok->next(), "case|public|protected|private|class|struct")) { int offset = 0; if (tok->next()->str() == "const") diff --git a/test/test.pro b/test/test.pro index f7237777c..75f9b7997 100644 --- a/test/test.pro +++ b/test/test.pro @@ -19,16 +19,12 @@ include(../lib/lib.pri) SOURCES += ../cli/cmdlineparser.cpp \ ../cli/cppcheckexecutor.cpp \ ../cli/filelister.cpp \ - ../cli/filelister_unix.cpp \ - ../cli/filelister_win32.cpp \ ../cli/pathmatch.cpp \ ../cli/threadexecutor.cpp \ testpathmatch.cpp HEADERS += ../cli/cmdlineparser.h \ ../cli/cppcheckexecutor.h \ ../cli/filelister.h \ - ../cli/filelister_unix.h \ - ../cli/filelister_win32.h \ ../cli/pathmatch.h \ ../cli/threadexecutor.h diff --git a/test/test.vcproj b/test/test.vcproj index 51217b726..b93a39bc9 100755 --- a/test/test.vcproj +++ b/test/test.vcproj @@ -3,7 +3,7 @@ ProjectType="Visual C++" Version="9,00" Name="test" - ProjectGUID="{E690724D-4286-3049-8439-595D1CB80EAB}" + ProjectGUID="{4B6CBD22-5689-3C50-A5A4-1204D4D28E54}" Keyword="Qt4VSv1.0"> - - - - - {597BA843-2D03-3F45-AB51-2E1DF1EA5136} + {B0719A50-6567-3359-B337-92D9F9DDE38A} test Qt4VSv1.0 @@ -50,7 +50,7 @@ - ".";"..\cli";"..\lib";"..\externals";"..\externals\tinyxml";c:\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories) + ".";"..\cli";"..\lib";"..\externals";"..\externals\tinyxml";..\..\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories) -Zm200 -w34100 -w34189 %(AdditionalOptions) temp\ false @@ -84,7 +84,7 @@ - ".";"..\cli";"..\lib";"..\externals";"..\externals\tinyxml";c:\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories) + ".";"..\cli";"..\lib";"..\externals";"..\externals\tinyxml";..\..\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories) -Zm200 -w34100 -w34189 %(AdditionalOptions) temp\ false @@ -135,8 +135,6 @@ - - @@ -207,8 +205,6 @@ - - diff --git a/test/test.vcxproj.filters b/test/test.vcxproj.filters index deb632b52..755d7fc2a 100644 --- a/test/test.vcxproj.filters +++ b/test/test.vcxproj.filters @@ -65,12 +65,6 @@ Source Files - - Source Files - - - Source Files - Source Files @@ -277,12 +271,6 @@ Header Files - - Header Files - - - Header Files - Header Files diff --git a/test/testclass.cpp b/test/testclass.cpp index 8dd0d4d8e..e4944addc 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -165,6 +165,9 @@ private: TEST_CASE(const42); // ticket #2282 TEST_CASE(const43); // ticket #2377 TEST_CASE(const44); // ticket #2595 + TEST_CASE(const45); // ticket #2664 + TEST_CASE(const46); // ticket #2636 + TEST_CASE(const47); // ticket #2670 TEST_CASE(assigningPointerToPointerIsNotAConstOperation); TEST_CASE(assigningArrayElementIsNotAConstOperation); TEST_CASE(constoperator1); // operator< can often be const @@ -5191,6 +5194,62 @@ private: ASSERT_EQUALS("", errout.str()); } + void const45() // ticket 2664 + { + checkConst("namespace wraps {\n" + " class BaseLayout {};\n" + "}\n" + "namespace tools {\n" + " class WorkspaceControl :\n" + " public wraps::BaseLayout\n" + " {\n" + " int toGrid(int _value)\n" + " {\n" + " }\n" + " };\n" + "}\n"); + + ASSERT_EQUALS("[test.cpp:8]: (information) Technically the member function 'tools::WorkspaceControl::toGrid' can be const.\n", errout.str()); + } + + void const46() // ticket 2663 + { + checkConst("class Altren {\n" + "public:\n" + " int fun1() {\n" + " int a;\n" + " a++;\n" + " }\n" + " int fun2() {\n" + " b++;\n" + " }\n" + "}\n"); + + ASSERT_EQUALS("[test.cpp:3]: (information) Technically the member function 'Altren::fun1' can be const.\n" + "[test.cpp:7]: (information) Technically the member function 'Altren::fun2' can be const.\n", errout.str()); + } + + void const47() // ticket 2670 + { + checkConst("class Altren {\n" + "public:\n" + " void foo() { delete this; }\n" + " void foo(int i) const { }\n" + " void bar() { foo(); }\n" + "}\n"); + + ASSERT_EQUALS("", errout.str()); + + checkConst("class Altren {\n" + "public:\n" + " void foo() { delete this; }\n" + " void foo(int i) const { }\n" + " void bar() { foo(1); }\n" + "}\n"); + + ASSERT_EQUALS("[test.cpp:5]: (information) Technically the member function 'Altren::bar' can be const.\n", errout.str()); + } + void assigningPointerToPointerIsNotAConstOperation() { checkConst("struct s\n" diff --git a/test/testfilelister_unix.cpp b/test/testfilelister_unix.cpp index 86b038cec..fddd2944b 100644 --- a/test/testfilelister_unix.cpp +++ b/test/testfilelister_unix.cpp @@ -18,9 +18,7 @@ #include "testsuite.h" -#define private public - -#include "filelister_unix.h" +#include "filelister.h" class TestFileLister: public TestFixture { @@ -32,16 +30,18 @@ public: private: void run() { +#ifndef _WIN32 TEST_CASE(test_recursiveAddFiles2); +#endif } +#ifndef _WIN32 void test_recursiveAddFiles2() { std::vector relative, absolute; - FileListerUnix ful; - ful.recursiveAddFiles2(relative, absolute, "."); + FileLister::recursiveAddFiles2(relative, absolute, "."); - ASSERT(relative.size() != 0); + ASSERT(!relative.empty()); ASSERT_EQUALS((int)relative.size(), (int)absolute.size()); for (std::vector::const_iterator r = relative.begin(), r_end = relative.end(), @@ -56,6 +56,7 @@ private: ASSERT_EQUALS(r->substr(start_at_relative), a->substr(start_at_absolute)); } } +#endif }; REGISTER_TEST(TestFileLister) diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index c549b57b2..bf0c0376f 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -228,6 +228,9 @@ private: TEST_CASE(func18); TEST_CASE(func19); // Ticket #2056 - if (!f(p)) return 0; TEST_CASE(func20); // Ticket #2182 - exit is not handled + TEST_CASE(func21); // Ticket #2569 + TEST_CASE(func22); // Ticket #2668 + TEST_CASE(func23); // Ticket #2667 TEST_CASE(allocfunc1); TEST_CASE(allocfunc2); @@ -564,18 +567,27 @@ private: static const char * const call_func_white_list[] = { - "asprintf", "atof", "atoi", "atol", "clearerr", "delete", "fchmod", "fcntl" - , "fdatasync", "feof", "ferror", "fflush", "fgetc", "fgetpos", "fgets" - , "flock", "for", "fprintf", "fputc", "fputs", "fread", "free", "fscanf", "fseek" + "access", "asprintf", "atof", "atoi", "atol", "chdir", "chmod", "clearerr", "chown", "delete" + , "fchmod", "fcntl", "fdatasync", "feof", "ferror", "fflush", "fgetc", "fgetpos", "fgets" + , "flock", "for", "fprintf", "fputc", "fputs", "fread", "free", "freopen", "fscanf", "fseek" , "fseeko", "fsetpos", "fstat", "fsync", "ftell", "ftello", "ftruncate" - , "fwrite", "getc", "if", "ioctl", "lockf", "lseek", "memchr", "memcpy" - , "memmove", "memset", "posix_fadvise", "posix_fallocate", "pread" + , "fwrite", "getc", "if", "ioctl", "lockf", "lseek", "open", "memchr", "memcpy" + , "memmove", "memset", "perror", "posix_fadvise", "posix_fallocate", "pread" , "printf", "puts", "pwrite", "read", "readahead", "readdir", "readdir_r", "readv" , "realloc", "return", "rewind", "rewinddir", "scandir", "seekdir" - , "setbuf", "setbuffer", "setlinebuf", "setvbuf", "snprintf", "sprintf", "strcasecmp" + , "setbuf", "setbuffer", "setlinebuf", "setvbuf", "snprintf", "sprintf", "stpcpy", "strcasecmp" , "strcat", "strchr", "strcmp", "strcpy", "stricmp", "strlen", "strncat", "strncmp" - , "strncpy", "strrchr", "strstr", "strtod", "strtol", "strtoul", "switch" - , "sync_file_range", "telldir", "typeid", "while", "write", "writev" + , "strncpy", "strrchr", "strspn" ,"strstr", "strtod", "strtol", "strtoul", "switch" + , "sync_file_range", "telldir", "typeid", "while", "write", "writev", "lstat", "stat" + , "_open", "_wopen", "vscanf", "vsscanf", "vfscanf", "vasprintf", "utime", "utimes", "unlink" + , "tempnam", "system", "symlink", "strpbrk", "strncasecmp", "strdup", "strcspn", "strcoll" + , "setlocale", "sethostname", "rmdir", "rindex", "rename", "remove", "adjtime", "creat", "execle" + , "execl", "execlp", "execve", "execv", "fdopen", "fmemopen", "fnmatch", "fopencookie", "fopen" + , "getgrnam", "gethostbyaddr", "getnetbyname", "getopt", "getopt_long", "getprotobyname", "getpwnam" + , "getservbyname", "getservbyport", "glob", "index", "inet_addr", "inet_aton", "inet_network" + , "initgroups", "link", "mblen", "mbstowcs", "mbtowc", "mkdir", "mkfifo", "mknod", "obstack_printf" + , "obstack_vprintf", "opendir", "parse_printf_format", "pathconf", "popen", "psignal", "putenv" + , "readlink", "regcomp", "strxfrm", "wordexp" }; for (unsigned int i = 0; i < (sizeof(call_func_white_list) / sizeof(char *)); ++i) @@ -1731,8 +1743,442 @@ private: ASSERT_EQUALS("", errout.str()); } + //# Ticket 2569 + void func21() + { + // checking for lstat function: + // ---------------------------- + check("void foo ()\n" + "{\n" + " struct stat CFileAttr;\n" + " char *cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " if (lstat (cpFile, &CFileAttr) != 0)\n" + " {\n" + " return;\n" + " }\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: cpFile\n", errout.str()); + + check("void foo ()\n" + "{\n" + " struct stat CFileAttr;\n" + " char *cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " if (lstat (cpFile, &CFileAttr) != 0)\n" + " {\n" + " delete [] cpFile;\n" + " return;\n" + " }\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:11]: (error) Memory leak: cpFile\n", errout.str()); + + check("void foo ()\n" + "{\n" + " struct stat CFileAttr;\n" + " char *cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " if (lstat (cpFile, &CFileAttr) != 0)\n" + " {\n" + " delete [] cpFile;\n" + " return;\n" + " }\n" + " delete [] cpFile;\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + /// checking for stat function: + // ---------------------------- + check("void foo ()\n" + "{\n" + " struct stat CFileAttr;\n" + " char *cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " if ( stat (cpFile, &CFileAttr) != 0)\n" + " {\n" + " return;\n" + " }\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: cpFile\n", errout.str()); + + check("void foo ()\n" + "{\n" + " struct stat CFileAttr;\n" + " char *cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " if ( stat (cpFile, &CFileAttr) != 0)\n" + " {\n" + " delete [] cpFile;\n" + " return;\n" + " }\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:11]: (error) Memory leak: cpFile\n", errout.str()); + + check("void foo ()\n" + "{\n" + " struct stat CFileAttr;\n" + " char *cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " if ( stat (cpFile, &CFileAttr) != 0)\n" + " {\n" + " delete [] cpFile;\n" + " return;\n" + " }\n" + " delete [] cpFile;\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + // checking for access function + // http://www.gnu.org/s/libc/manual/html_node/Testing-File-Access.html + // -------------------------------------------------------------------- + + check("void foo ()\n" + "{\n" + " struct stat CFileAttr;\n" + " char *cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " if ( access (cpFile, R_OK) != 0)\n" + " {\n" + " return;\n" + " }\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: cpFile\n", errout.str()); + + check("void foo ()\n" + "{\n" + " struct stat CFileAttr;\n" + " char *cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " if (access (cpFile, R_OK) != 0)\n" + " {\n" + " delete [] cpFile;\n" + " return;\n" + " }\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:11]: (error) Memory leak: cpFile\n", errout.str()); + + check("void foo ()\n" + "{\n" + " struct stat CFileAttr;\n" + " char *cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " if (access (cpFile, R_OK) != 0)\n" + " {\n" + " delete [] cpFile;\n" + " return;\n" + " }\n" + " delete [] cpFile;\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + + // checking for chdir function + // http://home.fhtw-berlin.de/~junghans/cref/MAN/chdir.htm + // -------------------------------------------------------- + + check("void foo()\n" + "{\n" + " char * cpDir = new char [7];\n" + " strcpy (cpDir, \"/home/\");\n" + " if (chdir (cpDir) != 0)\n" + " {\n" + " return;\n" + " }\n" + " delete [] cpDir;\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:7]: (error) Memory leak: cpDir\n", errout.str()); + + check("void foo()\n" + "{\n" + " char * cpDir = new char [7];\n" + " strcpy (cpDir, \"/home/\");\n" + " if (chdir (cpDir) != 0)\n" + " {\n" + " delete [] cpDir;\n" + " return;\n" + " }\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: cpDir\n", errout.str()); + + check("void foo()\n" + "{\n" + " char * cpDir = new char [7];\n" + " strcpy (cpDir, \"/home/\");\n" + " if (chdir (cpDir) != 0)\n" + " {\n" + " delete [] cpDir;\n" + " return;\n" + " }\n" + " delete [] cpDir;\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + // checking for chmod function + // http://publib.boulder.ibm.com/infocenter/zos/v1r10/index.jsp?topic=/com.ibm.zos.r10.bpxbd00/rtchm.htm + // ------------------------------------------------------------------------------------------------------ + + check("void foo()\n" + "{\n" + " char * cpDir = new char [7];\n" + " strcpy (cpDir, \"/home/\");\n" + " if (chmod(cpDir, S_IRWXU|S_IRWXG) != 0)\n" + " {\n" + " return;\n" + " }\n" + " delete [] cpDir;\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:7]: (error) Memory leak: cpDir\n", errout.str()); + + check("void foo()\n" + "{\n" + " char * cpDir = new char [7];\n" + " strcpy (cpDir, \"/home/\");\n" + " if (chmod(cpDir, S_IRWXU|S_IRWXG) != 0)\n" + " {\n" + " delete [] cpDir;\n" + " return;\n" + " }\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: cpDir\n", errout.str()); + + check("void foo()\n" + "{\n" + " char * cpDir = new char [7];\n" + " strcpy (cpDir, \"/home/\");\n" + " if (chmod(cpDir, S_IRWXU|S_IRWXG) != 0)\n" + " {\n" + " delete [] cpDir;\n" + " return;\n" + " }\n" + " delete [] cpDir;\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + + // checking for chown function + // http://publib.boulder.ibm.com/infocenter/zos/v1r10/index.jsp?topic=/com.ibm.zos.r10.bpxbd00/rtchm.htm + // ------------------------------------------------------------------------------------------------------ + + check("void foo()\n" + "{\n" + " char * cpDir = new char [7];\n" + " strcpy (cpDir, \"/home/\");\n" + " if (chown(cpDir, 25, 0) != 0)\n" + " {\n" + " return;\n" + " }\n" + " delete [] cpDir;\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:7]: (error) Memory leak: cpDir\n", errout.str()); + + check("void foo()\n" + "{\n" + " char * cpDir = new char [7];\n" + " strcpy (cpDir, \"/home/\");\n" + " if (chown(cpDir, 25, 0) != 0)\n" + " {\n" + " delete [] cpDir;\n" + " return;\n" + " }\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: cpDir\n", errout.str()); + + check("void foo()\n" + "{\n" + " char * cpDir = new char [7];\n" + " strcpy (cpDir, \"/home/\");\n" + " if (chown(cpDir, 25, 0) != 0)\n" + " {\n" + " delete [] cpDir;\n" + " return;\n" + " }\n" + " delete [] cpDir;\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + // checking perror + //http://www.cplusplus.com/reference/clibrary/cstdio/perror/ + // --------------------------------------------------------- + + check("void foo()\n" + "{\n" + " char *cBuf = new char[11];\n" + " sprintf(cBuf,\"%s\",\"testtest..\");\n" + " perror (cBuf);\n" + " delete [] cBuf;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + check("void foo()\n" + "{\n" + " char *cBuf = new char[11];\n" + " sprintf(cBuf,\"%s\",\"testtest..\");\n" + " perror (cBuf);\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:6]: (error) Memory leak: cBuf\n", errout.str()); + } + + // # 2668 + void func22() + { + check("void foo()\n" + "{\n" + " char * cpFile;\n" + " cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " if(freopen(cpFile,\"w\",stdout)==0)\n" + " {\n" + " return;\n" + " }\n" + " delete [] cpFile;\n" + " fclose (stdout);\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:8]: (error) Memory leak: cpFile\n", errout.str()); + + check("void foo()\n" + "{\n" + " char * cpFile;\n" + " cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " if(freopen(cpFile,\"w\",stdout)==0)\n" + " {\n" + " delete [] cpFile;\n" + " return;\n" + " }\n" + " fclose (stdout);\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:12]: (error) Memory leak: cpFile\n", errout.str()); + + check("void foo()\n" + "{\n" + " char * cpFile;\n" + " cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " if(freopen(cpFile,\"w\",stdout)==0)\n" + " {\n" + " delete [] cpFile;\n" + " return;\n" + " }\n" + " delete [] cpFile;\n" + " fclose (stdout);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + + // # 2667 + void func23() + { + + // check open() function + // ---------------------- + check("int * foo()\n" + "{\n" + " char * cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " int file=open(cpFile,O_RDONLY);\n" + " if(file < -1)\n" + " {\n" + " return file;\n" + " }\n" + " delete [] cpFile;\n" + " return file;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:8]: (error) Memory leak: cpFile\n", errout.str()); + + check("int * foo()\n" + "{\n" + " char * cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " int file=open(cpFile,O_RDONLY);\n" + " if(file < -1)\n" + " {\n" + " delete [] cpFile;\n" + " return file;\n" + " }\n" + " return file;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:11]: (error) Memory leak: cpFile\n", errout.str()); + + check("int * foo()\n" + "{\n" + " char * cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " int file=open(cpFile,O_RDONLY);\n" + " if(file < -1)\n" + " {\n" + " delete [] cpFile;\n" + " return file;\n" + " }\n" + " delete [] cpFile;\n" + " return file;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + // check for _open, _wopen + // http://msdn.microsoft.com/en-us/library/z0kc8e3z(VS.80).aspx + // ------------------------------------------------------------- + check("int * foo()\n" + "{\n" + " char * cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " int file=_open(cpFile,_O_RDONLY);\n" + " if(file == -1)\n" + " {\n" + " return file;\n" + " }\n" + " delete [] cpFile;\n" + " return file;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:8]: (error) Memory leak: cpFile\n", errout.str()); + + check("int * foo()\n" + "{\n" + " char * cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " int file=_open(cpFile,_O_RDONLY);\n" + " if(file == -1)\n" + " {\n" + " delete [] cpFile;\n" + " return file;\n" + " }\n" + " return file;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:11]: (error) Memory leak: cpFile\n", errout.str()); + + check("int * foo()\n" + "{\n" + " char * cpFile = new char [13];\n" + " strcpy (cpFile, \"testfile.txt\");\n" + " int file=_open(cpFile,_O_RDONLY);\n" + " if(file == -1)\n" + " {\n" + " delete [] cpFile;\n" + " return file;\n" + " }\n" + " delete [] cpFile;\n" + " return file;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } void allocfunc1() { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 5406b6bf6..19bf4fb03 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -171,6 +171,7 @@ private: TEST_CASE(varid26); // ticket #1967 (list of function pointers) TEST_CASE(varid27); // Ticket #2280 (same name for namespace and variable) TEST_CASE(varid28); // ticket #2630 + TEST_CASE(varid29); // ticket #1974 TEST_CASE(varidFunctionCall1); TEST_CASE(varidFunctionCall2); TEST_CASE(varidFunctionCall3); @@ -291,6 +292,7 @@ private: TEST_CASE(bitfields5); // ticket #1956 TEST_CASE(bitfields6); // ticket #2595 TEST_CASE(bitfields7); // ticket #1987 + TEST_CASE(bitfields8); TEST_CASE(microsoftMFC); @@ -2829,6 +2831,18 @@ private: ASSERT_EQUALS("", errout.str()); } + void varid29() + { + const std::string code("class A {\n" + " B,1> b;\n" + "};\n"); + const std::string expected("\n\n##file 0\n" + "1: class A {\n" + "2: B < C < 1 > , 1 > b@1 ;\n" + "3: } ;\n"); + ASSERT_EQUALS(expected, tokenizeDebugListing(code)); + } + void varidFunctionCall1() { const std::string code("void f() {\n" @@ -5300,6 +5314,22 @@ private: ASSERT_EQUALS("", errout.str()); } + void bitfields8() + { + const char code[] = "struct A;" + "class B : virtual public C" + "{" + " int f();" + "};"; + const char expected[] = "struct A ; " + "class B : virtual public C " + "{ " + "int f ( ) ; " + "} ;"; + ASSERT_EQUALS(expected, tokenizeAndStringify(code,false)); + ASSERT_EQUALS("", errout.str()); + } + void microsoftMFC() { const char code1[] = "class MyDialog : public CDialog { DECLARE_MESSAGE_MAP() private: CString text; };"; diff --git a/tools/dmake.cpp b/tools/dmake.cpp index 3332f14c5..a3819c216 100644 --- a/tools/dmake.cpp +++ b/tools/dmake.cpp @@ -25,11 +25,7 @@ #include #include -#if defined(_WIN32) -#include "../cli/filelister_win32.h" -#else // POSIX-style system -#include "../cli/filelister_unix.h" -#endif +#include "../cli/filelister.h" std::string objfile(std::string cppfile) { @@ -88,7 +84,7 @@ static void compilefiles(std::ostream &fout, const std::vector &fil static void getCppFiles(std::vector &files, const std::string &path) { - getFileLister()->recursiveAddFiles(files, path); + FileLister::recursiveAddFiles(files, path); // only get *.cpp files.. for (std::vector::iterator it = files.begin(); it != files.end();) { @@ -280,14 +276,14 @@ int main(int argc, char **argv) fout << "cppcheck: $(LIBOBJ) $(CLIOBJ) $(EXTOBJ)\n"; fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre $(LDFLAGS)\n\n"; fout << "all:\tcppcheck testrunner\n\n"; - fout << "testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/filelister_unix.o cli/pathmatch.o\n"; - fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre cli/threadexecutor.o cli/cmdlineparser.o cli/filelister.o cli/filelister_unix.o cli/pathmatch.o $(LDFLAGS)\n\n"; + fout << "testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/pathmatch.o\n"; + fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre cli/threadexecutor.o cli/cmdlineparser.o cli/filelister.o cli/pathmatch.o $(LDFLAGS)\n\n"; fout << "test:\tall\n"; fout << "\t./testrunner\n\n"; fout << "check:\tall\n"; fout << "\t./testrunner -g -q\n\n"; fout << "dmake:\ttools/dmake.cpp\n"; - fout << "\t$(CXX) -o dmake tools/dmake.cpp cli/filelister*.cpp lib/path.cpp -Ilib\n\n"; + fout << "\t$(CXX) -o dmake tools/dmake.cpp cli/filelister.cpp lib/path.cpp -Ilib\n\n"; fout << "clean:\n"; #ifdef _WIN32 fout << "\tdel lib\*.o\n\tdel cli\*.o\n\tdel test\*.o\n\tdel *.exe\n"; diff --git a/win_installer/cppcheck.wxs b/win_installer/cppcheck.wxs old mode 100755 new mode 100644 index 1b7e438a1..3c9a5c66e --- a/win_installer/cppcheck.wxs +++ b/win_installer/cppcheck.wxs @@ -48,7 +48,7 @@ - + @@ -58,13 +58,16 @@ - + + + diff --git a/win_installer/productInfo.wxi b/win_installer/productInfo.wxi old mode 100755 new mode 100644