This commit is contained in:
Sébastien Debrard 2011-02-08 21:08:40 +01:00
commit 54f523717c
67 changed files with 5431 additions and 1547 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@ tools/dmake
dmake
tools/errmsg
# VS generated files
*.obj
*.ncb
*.suo
*.user

2710
Changelog

File diff suppressed because it is too large Load Diff

View File

@ -205,7 +205,7 @@ lib/token.o: lib/token.cpp lib/token.h lib/errorlogger.h lib/check.h lib/tokeniz
lib/tokenize.o: lib/tokenize.cpp lib/tokenize.h lib/token.h lib/mathlib.h lib/settings.h lib/errorlogger.h lib/check.h lib/path.h lib/symboldatabase.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -Ilib -c -o lib/tokenize.o lib/tokenize.cpp
cli/cmdlineparser.o: cli/cmdlineparser.cpp lib/cppcheck.h lib/settings.h lib/errorlogger.h lib/checkunusedfunctions.h lib/check.h lib/token.h lib/tokenize.h lib/timer.h cli/cmdlineparser.h lib/path.h
cli/cmdlineparser.o: cli/cmdlineparser.cpp lib/cppcheck.h lib/settings.h lib/errorlogger.h lib/checkunusedfunctions.h lib/check.h lib/token.h lib/tokenize.h lib/timer.h cli/cmdlineparser.h lib/path.h cli/filelister.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -Ilib -Iexternals -c -o cli/cmdlineparser.o cli/cmdlineparser.cpp
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
@ -256,7 +256,7 @@ test/testcppcheck.o: test/testcppcheck.cpp lib/cppcheck.h lib/settings.h lib/err
test/testdivision.o: test/testdivision.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
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testdivision.o test/testdivision.cpp
test/testerrorlogger.o: test/testerrorlogger.cpp test/testsuite.h lib/errorlogger.h test/redirect.h
test/testerrorlogger.o: test/testerrorlogger.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) -Ilib -Icli -Iexternals -c -o test/testerrorlogger.o test/testerrorlogger.cpp
test/testexceptionsafety.o: test/testexceptionsafety.cpp lib/tokenize.h lib/checkexceptionsafety.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h test/testsuite.h test/redirect.h

View File

@ -607,68 +607,67 @@ void CmdLineParser::PrintHelp()
std::cout << "Cppcheck - A tool for static C/C++ code analysis\n"
"\n"
"Syntax:\n"
" cppcheck [--append=file] [-D<ID>] [--enable=<id>] [--error-exitcode=[n]]\n"
" [--exitcode-suppressions file] [--file-list=file.txt] [--force]\n"
" [--help] [-Idir] [--inline-suppr] [-j [jobs]] [--quiet]\n"
" [--report-progress] [--style] [--suppressions-list=file.txt]\n"
" [--verbose] [--version] [--xml] [file or path1] [file or path]\n"
" cppcheck [OPTIONS] [files or paths]\n"
"\n"
"If path is given instead of filename, *.cpp, *.cxx, *.cc, *.c++ and *.c files\n"
"are checked recursively from given directory.\n\n"
"Options:\n"
" --append=file This allows you to provide information about\n"
" --append=<file> This allows you to provide information about\n"
" functions by providing an implementation for these.\n"
" -D<ID> By default Cppcheck checks all configurations.\n"
" Use -D to limit the checking. When -D is used the\n"
" checking is limited to the given configuration.\n"
" Example: -DDEBUG=1 -D__cplusplus\n"
" --enable=id Enable additional checks. The available ids are:\n"
" --enable=<id> Enable additional checks. The available ids are:\n"
" * all - enable all checks\n"
" * style - Check coding style\n"
" * information - Enable information messages\n"
" * unusedFunction - check for unused functions\n"
" * missingInclude - check for missing includes\n"
" Several ids can be given if you separate them with commas\n"
" --error-exitcode=[n] If errors are found, integer [n] is returned instead\n"
" Several ids can be given if you separate them with commas.\n"
" --error-exitcode=<n> If errors are found, integer [n] is returned instead\n"
" of default 0. EXIT_FAILURE is returned\n"
" if arguments are not valid or if no input files are\n"
" provided. Note that your operating system can\n"
" modify this value, e.g. 256 can become 0.\n"
" --errorlist Print a list of all error messages in XML format.\n"
" --exitcode-suppressions=file\n"
" --exitcode-suppressions=<file>\n"
" Used when certain messages should be displayed but\n"
" should not cause a non-zero exitcode.\n"
" --file-list=file Specify the files to check in a text file. One Filename per line.\n"
" --file-list=<file> Specify the files to check in a text file. One Filename per line.\n"
" -f, --force Force checking on files that have \"too many\"\n"
" configurations\n"
" -h, --help Print this help\n"
" -I [dir] Give include path. Give several -I parameters to give\n"
" configurations.\n"
" -h, --help Print this help.\n"
" -I <dir> Give include path. Give several -I parameters to give\n"
" several paths. First given path is checked first. If\n"
" paths are relative to source files, this is not needed\n"
" -i [dir] Give path to ignore. Give several -i parameters to ignore\n"
" paths are relative to source files, this is not needed.\n"
" -i <dir> Give path to ignore. Give several -i parameters to ignore\n"
" several paths. Give directory name or filename with path\n"
" as parameter. Directory name is matched to all parts of the\n"
" path.\n"
" --inline-suppr Enable inline suppressions. Use them by placing one or\n"
" more comments, like: // cppcheck-suppress warningId\n"
" on the lines before the warning to suppress.\n"
" -j [jobs] Start [jobs] threads to do the checking simultaneously.\n"
" -q, --quiet Only print error messages\n"
" -j <jobs> Start [jobs] threads to do the checking simultaneously.\n"
" -q, --quiet Only print error messages.\n"
" --report-progress Report progress messages while checking a file.\n"
" -s, --style deprecated, use --enable=style\n"
" --suppressions-list=file\n"
" --rule=<rule> Match regular expression.\n"
" --rule-file=<file> Use given rule file. For more information, see: \n"
" https://sourceforge.net/projects/cppcheck/files/Articles/\n"
" -s, --style Deprecated, use --enable=style\n"
" --suppressions-list=<file>\n"
" Suppress warnings listed in the file. Filename and line\n"
" are optional in the suppression file. The format of the\n"
" single line in the suppression file is:\n"
" [error id]:[filename]:[line]\n"
" --template '[text]' Format the error messages. E.g.\n"
" --template '<text>' Format the error messages. E.g.\n"
" '{file}:{line},{severity},{id},{message}' or\n"
" '{file}({line}):({severity}) {message}'\n"
" Pre-defined templates: gcc, vs\n"
" -v, --verbose More detailed error reports\n"
" --version Print out version number\n"
" -v, --verbose More detailed error reports.\n"
" --version Print out version number.\n"
" --xml Write results in xml to error stream.\n"
" --xml-version=[version]\n"
" --xml-version=<version>\n"
" Select the XML file version. Currently versions 1 and 2\n"
" are available. The default version is 1."
"\n"

View File

@ -56,8 +56,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,46,0,0
PRODUCTVERSION 1,46,0,0
FILEVERSION 1,47,0,0
PRODUCTVERSION 1,47,0,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -73,12 +73,12 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "cppcheck Application"
VALUE "FileVersion", "1.46"
VALUE "FileVersion", "1.47"
VALUE "InternalName", "cppcheck"
VALUE "LegalCopyright", "Copyright (C) 2007-2010 Daniel Marjamäki and Cppcheck team."
VALUE "OriginalFilename", "cppcheck.exe"
VALUE "ProductName", "cppcheck Application"
VALUE "ProductVersion", "1.46"
VALUE "ProductVersion", "1.47"
END
END
BLOCK "VarFileInfo"

View File

@ -20,7 +20,7 @@
/**
*
* @mainpage Cppcheck
* @version 1.46
* @version 1.47
*
* @section overview_sec Overview
* Cppcheck is a simple tool for static analysis of C/C++ code.

View File

@ -1,11 +1,15 @@
#!/bin/bash
# A script for tagging and releasing.
#
# A tag will be created with the given name.
# A script for creating release packages. The release packages are create in the home directory.
#
# Archive files are created in user's home directory.
# Make sure "cppcheck --errorlist" works. For example with:
# make test
# cppcheck --errorlist > errlist.xml
# xmllint --noout errlist.xml
# cppcheck --xml-version=2 --errorlist > errlist.xml
# xmllint --noout errlist.xml
#
# Before running this script, remember to update version number in:
# Update version numbers in:
# - lib/cppcheck.cpp
# - cli/main.cpp
# - cli/cppcheck.rc
@ -16,12 +20,16 @@
# wget http://josefsson.org/git2cl/git2cl
# chmod 744 git2cl
# ./git2cl > Changelog
# git commit -a -m "Changelog: Updated for release"
# git commit -a -m "1.43: Updated Changelog"
#
# Update the Makefile:
# g++ -o dmake tools/dmake.cpp lib/filelister*.cpp
# make dmake
# ./dmake --release
# git commit -a -m "Makefile: Set release mode"
# git commit -a -m "1.43: Updated Makefile"
#
# Tag:
# git tag 1.43
# git push --tags
#
# Create release:
# ./createrelease 1.43
@ -33,13 +41,11 @@
# Generate the manual.pdf and version.txt
# make
# ./cppcheck --version > version.txt
# docbook2pdf man/manual.pdf
# docbook2pdf man/manual.docbook
#
# Upload manual.pdf and version.txt...
# sftp hyd_danmar,cppcheck@web.sourceforge.net
#
# Make sure "cppcheck --errorlist" works
#
# save "cppcheck --doc" output on wiki
# Tag to use

View File

@ -223,9 +223,9 @@ kate -l(line) (file)</translation>
<location filename="mainwindow.cpp" line="203"/>
<location filename="mainwindow.cpp" line="233"/>
<location filename="mainwindow.cpp" line="524"/>
<location filename="mainwindow.cpp" line="642"/>
<location filename="mainwindow.cpp" line="660"/>
<location filename="mainwindow.cpp" line="811"/>
<location filename="mainwindow.cpp" line="648"/>
<location filename="mainwindow.cpp" line="666"/>
<location filename="mainwindow.cpp" line="817"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
@ -563,8 +563,9 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="582"/>
<source>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<translation>XML-Dateien (*.xml);;Textdateien (*.txt);;CSV-Dateien (*.csv)</translation>
<source>XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<oldsource>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</oldsource>
<translation type="unfinished">XML-Dateien (*.xml);;Textdateien (*.txt);;CSV-Dateien (*.csv)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="584"/>
@ -573,7 +574,6 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="443"/>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files (*.xml)</source>
<translation>XML-Dateien (*.xml)</translation>
</message>
@ -584,8 +584,8 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="306"/>
<location filename="mainwindow.cpp" line="742"/>
<location filename="mainwindow.cpp" line="788"/>
<location filename="mainwindow.cpp" line="748"/>
<location filename="mainwindow.cpp" line="794"/>
<source>Project: </source>
<translation type="unfinished"></translation>
</message>
@ -601,23 +601,33 @@ kate -l(line) (file)</translation>
Do you want to stop the checking and exit Cppcheck?.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files version 1 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="598"/>
<source>XML files version 2 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<source>Text files (*.txt)</source>
<translation>Textdateien (*.txt)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="610"/>
<source>CSV files (*.csv)</source>
<translation>CSV-Dateien (*.csv)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="644"/>
<location filename="mainwindow.cpp" line="650"/>
<source>Cppcheck - %1</source>
<translation>Cppcheck - %1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="661"/>
<location filename="mainwindow.cpp" line="667"/>
<source>Failed to change the language:
%1
@ -633,39 +643,39 @@ Do you want to stop the checking and exit Cppcheck?.</source>
</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="715"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Cppcheck Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="715"/>
<source>Failed to load help file (not found)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Failed to load help file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="732"/>
<location filename="mainwindow.cpp" line="777"/>
<location filename="mainwindow.cpp" line="738"/>
<location filename="mainwindow.cpp" line="783"/>
<source>Project files (*.cppcheck);;All files(*.*)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="734"/>
<location filename="mainwindow.cpp" line="740"/>
<source>Select Project File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="779"/>
<location filename="mainwindow.cpp" line="785"/>
<source>Select Project Filename</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="812"/>
<location filename="mainwindow.cpp" line="818"/>
<source>No project file loaded</source>
<translation type="unfinished"></translation>
</message>
@ -929,18 +939,18 @@ Please select the directory where file is located.</source>
<context>
<name>ResultsView</name>
<message>
<location filename="resultsview.cpp" line="190"/>
<location filename="resultsview.cpp" line="202"/>
<location filename="resultsview.cpp" line="195"/>
<location filename="resultsview.cpp" line="207"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
<message>
<location filename="resultsview.cpp" line="191"/>
<location filename="resultsview.cpp" line="196"/>
<source>No errors found.</source>
<translation>Keine Fehler gefunden.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="199"/>
<location filename="resultsview.cpp" line="204"/>
<source>Errors were found, but they are configured to be hidden.
To toggle what kind of errors are shown, open view menu.</source>
<translation>Es wurden Fehler gefunden, aber sie sind so konfiguriert, ausgeblendet zu werden.
@ -948,28 +958,29 @@ Legen Sie unter dem Menü Ansicht fest, welche Art von Fehlern angezeigt werden
</message>
<message>
<location filename="resultsview.cpp" line="251"/>
<location filename="resultsview.cpp" line="261"/>
<location filename="resultsview.cpp" line="271"/>
<location filename="resultsview.cpp" line="281"/>
<source>Failed to read the report.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="302"/>
<location filename="resultsview.cpp" line="321"/>
<source>Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="303"/>
<location filename="resultsview.cpp" line="322"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="117"/>
<location filename="resultsview.cpp" line="119"/>
<source>No errors found, nothing to save.</source>
<translation>Keine Fehler gefunden, nichts zu speichern.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="144"/>
<location filename="resultsview.cpp" line="154"/>
<location filename="resultsview.cpp" line="149"/>
<location filename="resultsview.cpp" line="159"/>
<source>Failed to save the report.</source>
<translation>Der Bericht konnte nicht speichern werden.</translation>
</message>

View File

@ -225,9 +225,9 @@ kate -l(line) (file)</translation>
<location filename="mainwindow.cpp" line="203"/>
<location filename="mainwindow.cpp" line="233"/>
<location filename="mainwindow.cpp" line="524"/>
<location filename="mainwindow.cpp" line="642"/>
<location filename="mainwindow.cpp" line="660"/>
<location filename="mainwindow.cpp" line="811"/>
<location filename="mainwindow.cpp" line="648"/>
<location filename="mainwindow.cpp" line="666"/>
<location filename="mainwindow.cpp" line="817"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
@ -565,8 +565,9 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="582"/>
<source>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<translation>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</translation>
<source>XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<oldsource>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</oldsource>
<translation type="unfinished">XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="584"/>
@ -575,7 +576,6 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="443"/>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files (*.xml)</source>
<translation>XML files (*.xml)</translation>
</message>
@ -586,8 +586,8 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="306"/>
<location filename="mainwindow.cpp" line="742"/>
<location filename="mainwindow.cpp" line="788"/>
<location filename="mainwindow.cpp" line="748"/>
<location filename="mainwindow.cpp" line="794"/>
<source>Project: </source>
<translation type="unfinished"></translation>
</message>
@ -603,23 +603,33 @@ kate -l(line) (file)</translation>
Do you want to stop the checking and exit Cppcheck?.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files version 1 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="598"/>
<source>XML files version 2 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<source>Text files (*.txt)</source>
<translation>Text files (*.txt)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="610"/>
<source>CSV files (*.csv)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="644"/>
<location filename="mainwindow.cpp" line="650"/>
<source>Cppcheck - %1</source>
<translation>Cppcheck - %1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="661"/>
<location filename="mainwindow.cpp" line="667"/>
<source>Failed to change the language:
%1
@ -633,39 +643,39 @@ Do you want to stop the checking and exit Cppcheck?.</source>
%1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="715"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Cppcheck Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="715"/>
<source>Failed to load help file (not found)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Failed to load help file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="732"/>
<location filename="mainwindow.cpp" line="777"/>
<location filename="mainwindow.cpp" line="738"/>
<location filename="mainwindow.cpp" line="783"/>
<source>Project files (*.cppcheck);;All files(*.*)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="734"/>
<location filename="mainwindow.cpp" line="740"/>
<source>Select Project File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="779"/>
<location filename="mainwindow.cpp" line="785"/>
<source>Select Project Filename</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="812"/>
<location filename="mainwindow.cpp" line="818"/>
<source>No project file loaded</source>
<translation type="unfinished"></translation>
</message>
@ -929,18 +939,18 @@ Please select the directory where file is located.</source>
<context>
<name>ResultsView</name>
<message>
<location filename="resultsview.cpp" line="190"/>
<location filename="resultsview.cpp" line="202"/>
<location filename="resultsview.cpp" line="195"/>
<location filename="resultsview.cpp" line="207"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
<message>
<location filename="resultsview.cpp" line="191"/>
<location filename="resultsview.cpp" line="196"/>
<source>No errors found.</source>
<translation>No errors found.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="199"/>
<location filename="resultsview.cpp" line="204"/>
<source>Errors were found, but they are configured to be hidden.
To toggle what kind of errors are shown, open view menu.</source>
<translation>Errors were found, but they are configured to be hidden.
@ -948,28 +958,29 @@ To toggle what kind of errors are shown, open view menu.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="251"/>
<location filename="resultsview.cpp" line="261"/>
<location filename="resultsview.cpp" line="271"/>
<location filename="resultsview.cpp" line="281"/>
<source>Failed to read the report.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="302"/>
<location filename="resultsview.cpp" line="321"/>
<source>Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="303"/>
<location filename="resultsview.cpp" line="322"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="117"/>
<location filename="resultsview.cpp" line="119"/>
<source>No errors found, nothing to save.</source>
<translation>No errors found, nothing to save.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="144"/>
<location filename="resultsview.cpp" line="154"/>
<location filename="resultsview.cpp" line="149"/>
<location filename="resultsview.cpp" line="159"/>
<source>Failed to save the report.</source>
<translation>Failed to save the report.</translation>
</message>

View File

@ -227,9 +227,9 @@ kate -l(line) (file)
<location filename="mainwindow.cpp" line="203"/>
<location filename="mainwindow.cpp" line="233"/>
<location filename="mainwindow.cpp" line="524"/>
<location filename="mainwindow.cpp" line="642"/>
<location filename="mainwindow.cpp" line="660"/>
<location filename="mainwindow.cpp" line="811"/>
<location filename="mainwindow.cpp" line="648"/>
<location filename="mainwindow.cpp" line="666"/>
<location filename="mainwindow.cpp" line="817"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
@ -567,8 +567,9 @@ kate -l(line) (file)
</message>
<message>
<location filename="mainwindow.cpp" line="582"/>
<source>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<translation>XML-tiedostot (*.xml);;Tekstitiedostot (*.txt);;CSV-tiedostot (*.csv)</translation>
<source>XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<oldsource>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</oldsource>
<translation type="unfinished">XML-tiedostot (*.xml);;Tekstitiedostot (*.txt);;CSV-tiedostot (*.csv)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="584"/>
@ -577,7 +578,6 @@ kate -l(line) (file)
</message>
<message>
<location filename="mainwindow.cpp" line="443"/>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files (*.xml)</source>
<translation>XML-tiedostot (*xml)</translation>
</message>
@ -588,8 +588,8 @@ kate -l(line) (file)
</message>
<message>
<location filename="mainwindow.cpp" line="306"/>
<location filename="mainwindow.cpp" line="742"/>
<location filename="mainwindow.cpp" line="788"/>
<location filename="mainwindow.cpp" line="748"/>
<location filename="mainwindow.cpp" line="794"/>
<source>Project: </source>
<translation type="unfinished"></translation>
</message>
@ -605,23 +605,33 @@ kate -l(line) (file)
Do you want to stop the checking and exit Cppcheck?.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files version 1 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="598"/>
<source>XML files version 2 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<source>Text files (*.txt)</source>
<translation>Tekstitiedostot (*.txt)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="610"/>
<source>CSV files (*.csv)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="644"/>
<location filename="mainwindow.cpp" line="650"/>
<source>Cppcheck - %1</source>
<translation>Cppcheck - %1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="661"/>
<location filename="mainwindow.cpp" line="667"/>
<source>Failed to change the language:
%1
@ -637,39 +647,39 @@ Do you want to stop the checking and exit Cppcheck?.</source>
</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="715"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Cppcheck Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="715"/>
<source>Failed to load help file (not found)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Failed to load help file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="732"/>
<location filename="mainwindow.cpp" line="777"/>
<location filename="mainwindow.cpp" line="738"/>
<location filename="mainwindow.cpp" line="783"/>
<source>Project files (*.cppcheck);;All files(*.*)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="734"/>
<location filename="mainwindow.cpp" line="740"/>
<source>Select Project File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="779"/>
<location filename="mainwindow.cpp" line="785"/>
<source>Select Project Filename</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="812"/>
<location filename="mainwindow.cpp" line="818"/>
<source>No project file loaded</source>
<translation type="unfinished"></translation>
</message>
@ -933,18 +943,18 @@ Please select the directory where file is located.</source>
<context>
<name>ResultsView</name>
<message>
<location filename="resultsview.cpp" line="190"/>
<location filename="resultsview.cpp" line="202"/>
<location filename="resultsview.cpp" line="195"/>
<location filename="resultsview.cpp" line="207"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
<message>
<location filename="resultsview.cpp" line="191"/>
<location filename="resultsview.cpp" line="196"/>
<source>No errors found.</source>
<translation>Virheitä ei löytynyt.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="199"/>
<location filename="resultsview.cpp" line="204"/>
<source>Errors were found, but they are configured to be hidden.
To toggle what kind of errors are shown, open view menu.</source>
<translation>Virheitä löytyi, mutta asetuksissa kyseiset virheet on määritelty piilotettavaksi.
@ -952,28 +962,29 @@ Määrittääksesi minkä tyyppisiä virheitä näytetään, avaa näkymä valik
</message>
<message>
<location filename="resultsview.cpp" line="251"/>
<location filename="resultsview.cpp" line="261"/>
<location filename="resultsview.cpp" line="271"/>
<location filename="resultsview.cpp" line="281"/>
<source>Failed to read the report.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="302"/>
<location filename="resultsview.cpp" line="321"/>
<source>Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="303"/>
<location filename="resultsview.cpp" line="322"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="117"/>
<location filename="resultsview.cpp" line="119"/>
<source>No errors found, nothing to save.</source>
<translation>Virheitä ei löytynyt, ei mitään tallennettavaa.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="144"/>
<location filename="resultsview.cpp" line="154"/>
<location filename="resultsview.cpp" line="149"/>
<location filename="resultsview.cpp" line="159"/>
<source>Failed to save the report.</source>
<translation>Raportin tallentaminen epäonnistui.</translation>
</message>

View File

@ -15,10 +15,6 @@
<source>Cppcheck - A tool for static C/C++ code analysis.</source>
<translation>Cppcheck - Un outil d&apos;analyse statique de code C/C++.</translation>
</message>
<message utf8="true">
<source>Copyright (C) 2007-2010 Daniel Marjamäki and cppcheck team.</source>
<translation>Copyright (C) 2007-2010 Daniel Marjamäki et cppcheck team.</translation>
</message>
<message>
<source>This program is licensed under the terms
of the GNU General Public License version 3</source>
@ -29,6 +25,10 @@ General Public License version 3</translation>
<source>Visit Cppcheck homepage at %1</source>
<translation>Visitez le site Cppcheck : %1</translation>
</message>
<message utf8="true">
<source>Copyright © 2007-2010 Daniel Marjamäki and cppcheck team.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ApplicationDialog</name>
@ -61,14 +61,6 @@ Les textes suivants sont remplacés avec les valeurs appropriées lorsque l&apos
Example : ouvrir un fichier avec kate et position l&apos;affichage sur la bonne ligne:
kate -l(ligne) (fichier)</translation>
</message>
<message>
<source>Application&apos;s name</source>
<translation>Nom de l&apos;application</translation>
</message>
<message>
<source>Application to execute</source>
<translation>Application à exécuter</translation>
</message>
<message>
<source>Browse</source>
<translation>Parcourir</translation>
@ -89,6 +81,14 @@ kate -l(ligne) (fichier)</translation>
<source>You must specify a name and a path for the application!</source>
<translation>Vous devez spécifier un nom et un chemin d&apos;accès pour l&apos;application !</translation>
</message>
<message>
<source>Application&apos;s name:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Command to execute:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FileViewDialog</name>
@ -106,10 +106,69 @@ kate -l(ligne) (fichier)</translation>
</message>
</context>
<context>
<name>Fileview</name>
<name>HelpWindow</name>
<message>
<source>Fileview</source>
<translation type="unfinished">Visualisateur de fichier</translation>
<source>Cppcheck Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go back</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Back</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go forward</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Forward</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Home</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LogView</name>
<message>
<source>Checking Log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Save</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Text files (*.txt *.log);;All files (*.*)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cppcheck</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Could not open file for writing: &quot;%1&quot;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@ -126,10 +185,6 @@ kate -l(ligne) (fichier)</translation>
<source>&amp;View</source>
<translation type="unfinished">&amp;Affichage</translation>
</message>
<message>
<source>&amp;Language</source>
<translation type="unfinished">&amp;Langue</translation>
</message>
<message>
<source>&amp;Help</source>
<translation type="unfinished">&amp;Aide</translation>
@ -210,26 +265,6 @@ kate -l(ligne) (fichier)</translation>
<source>&amp;Preferences</source>
<translation type="unfinished">&amp;Préférences</translation>
</message>
<message>
<source>Show possible false positives</source>
<translation type="unfinished">Afficher les possibles faux positifs</translation>
</message>
<message>
<source>Show security errors</source>
<translation type="unfinished">Afficher les erreurs de sécurité</translation>
</message>
<message>
<source>Show style errors</source>
<translation type="unfinished">Afficher les erreurs de style</translation>
</message>
<message>
<source>Show possible style errors</source>
<translation type="unfinished">Afficher les erreurs possibles de style</translation>
</message>
<message>
<source>Show common errors</source>
<translation type="unfinished">Afficher les erreurs</translation>
</message>
<message>
<source>&amp;Check all</source>
<translation type="unfinished">Tout &amp;cocher</translation>
@ -246,10 +281,6 @@ kate -l(ligne) (fichier)</translation>
<source>&amp;Expand all</source>
<translation type="unfinished">Tout &amp;afficher</translation>
</message>
<message>
<source>&amp;Toolbar</source>
<translation type="unfinished">&amp;Barre d&apos;outil</translation>
</message>
<message>
<source>&amp;Contents</source>
<translation type="unfinished">&amp;Contenu</translation>
@ -274,14 +305,6 @@ kate -l(ligne) (fichier)</translation>
<source>Select directory to check</source>
<translation type="unfinished">Sélectionner le répertoire à vérifier</translation>
</message>
<message>
<source>Cannot exit while checking.
Stop the checking before exiting.</source>
<translation type="unfinished">Ne peut pas quitter pendant une vérification.
Arrêter la vérification avant de quitter.</translation>
</message>
<message>
<source>License</source>
<translation type="unfinished">Licence</translation>
@ -290,10 +313,6 @@ Arrêter la vérification avant de quitter.</translation>
<source>Authors</source>
<translation type="unfinished">Auteur</translation>
</message>
<message>
<source>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<translation type="unfinished">Fichier XML (*.xml);;Fichier Texte (*.txt);;Fichier CSV (*.csv)</translation>
</message>
<message>
<source>Save the report file</source>
<translation type="unfinished">Sauvegarder le rapport</translation>
@ -354,6 +373,253 @@ Arrêter la vérification avant de quitter.</translation>
<source>Polish</source>
<translation type="unfinished">Polonais</translation>
</message>
<message>
<source>&amp;Toolbars</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Categories</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Check files</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Check directory</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stop checking</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Style warnings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show style warnings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Errors</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show errors</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Standard</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Standard items</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toolbar</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Categories</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Error categories</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Open XML...</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open P&amp;roject File...</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;New Project File...</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Log View</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log View</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>C&amp;lose Project File</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Edit Project File...</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Warnings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show warnings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Performance warnings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show performance warnings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show &amp;hidden</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Information</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show information messages</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portability</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show portability warnings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>You must close the project file before selecting new files or directories!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Project: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open the report file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Checking is running.
Do you want to stop the checking and exit Cppcheck?.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>XML files version 1 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>XML files version 2 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cppcheck Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to load help file (not found)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to load help file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Project files (*.cppcheck);;All files(*.*)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select Project File</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select Project Filename</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No project file loaded</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Japanese</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Serbian</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Project</name>
<message>
<source>Cppcheck</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Could not read the project file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Could not write the project file.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProjectFile</name>
<message>
<source>Project File</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Project:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Paths:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Browse...</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Include paths:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Defines:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProjectFileDialog</name>
<message>
<source>Project file: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select include directory</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select directory to check</source>
<translation type="unfinished">Sélectionner le répertoire à vérifier</translation>
</message>
</context>
<context>
<name>QObject</name>
@ -384,10 +650,6 @@ Arrêter la vérification avant de quitter.</translation>
<source>Line</source>
<translation type="unfinished">Ligne</translation>
</message>
<message>
<source>Message</source>
<translation type="unfinished">Message</translation>
</message>
<message>
<source>Undefined file</source>
<translation type="unfinished">Fichier indéterminé</translation>
@ -420,22 +682,52 @@ Please check the application path and parameters are correct.</source>
Merci de vérifier que le chemin de l&apos;application et que les paramètres sont corrects.</translation>
</message>
<message>
<source>possible error</source>
<translation type="unfinished">erreur possible</translation>
</message>
<message>
<source>style</source>
<translation type="unfinished">erreur de style</translation>
</message>
<message>
<source>possible style</source>
<translation type="unfinished">erreur de style possible</translation>
</message>
<message>
<source>error</source>
<translation type="unfinished">erreur</translation>
</message>
<message>
<source>Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hide</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Could not find the file!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Could not find file:
%1
Please select the directory where file is located.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select Directory</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>warning</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>performance</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>portability</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>information</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ResultsView</name>
@ -465,6 +757,18 @@ Pour configurer les erreurs affichées, ouvrez le menu d&apos;affichage.</transl
<source>Failed to save the report.</source>
<translation type="unfinished">Erreur lors de la sauvegarde du rapport.</translation>
</message>
<message>
<source>Failed to read the report.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Message</source>
<translation type="unfinished">Message</translation>
</message>
</context>
<context>
<name>Settings</name>
@ -480,10 +784,6 @@ Pour configurer les erreurs affichées, ouvrez le menu d&apos;affichage.</transl
<source>Number of threads: </source>
<translation type="unfinished">Nombre de processus : </translation>
</message>
<message>
<source>Check all #ifdef configurations</source>
<translation type="unfinished">Vérifier toutes les configurations #ifdef</translation>
</message>
<message>
<source>Show full path of files</source>
<translation type="unfinished">Montrer le chemin complet des fichiers</translation>
@ -524,6 +824,38 @@ Pour configurer les erreurs affichées, ouvrez le menu d&apos;affichage.</transl
<source>Save full path to files in reports</source>
<translation type="unfinished">Sauvegarder le chemin complet des fichiers dans les rapports</translation>
</message>
<message>
<source>Include paths:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add...</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ideal count:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TextLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Force checking all #ifdef configurations</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show internal warnings in log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable inline suppressions</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Language</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsDialog</name>
@ -535,5 +867,173 @@ Pour configurer les erreurs affichées, ouvrez le menu d&apos;affichage.</transl
<source>Modify an application</source>
<translation type="unfinished">Modifier une application</translation>
</message>
<message>
<source>N/A</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select include directory</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>StatsDialog</name>
<message>
<source>Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Project</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Project:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Paths:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Include paths:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Defines:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Previous Scan</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Path Selected:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Number of Files Scanned:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Scan Duration:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Errors:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Warnings:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stylistic warnings:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portability warnings:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TextLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Performance issues:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Information messages:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy to Clipboard</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>1 day</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 days</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>1 hour</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 hours</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>1 minute</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 minutes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>1 second</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 seconds</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0.%1 seconds</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> and </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Project Settings
Project: %1
Paths: %2
Include paths: %3
Defines: %4
Previous Scan
Path selected: %5
Number of files scanned: %6
Scan duration: %7
Statistics
Errors: %8
Warnings: %9
Style warnings: %10
Portability warnings: %11
Performance warnings: %12
Information messages: %13
</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;h3&gt;Project Settings&lt;h3&gt;
&lt;table&gt;
&lt;tr&gt;&lt;th&gt;Project:&lt;/th&gt;&lt;td&gt;%1&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Paths:&lt;/th&gt;&lt;td&gt;%2&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Include paths:&lt;/th&gt;&lt;td&gt;%3&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Defines:&lt;/th&gt;&lt;td&gt;%4&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;h3&gt;Previous Scan&lt;/h3&gt;
&lt;table&gt;
&lt;tr&gt;&lt;th&gt;Path selected:&lt;/th&gt;&lt;td&gt;%5&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Number of files scanned:&lt;/th&gt;&lt;td&gt;%6&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Scan duration:&lt;/th&gt;&lt;td&gt;%7&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;h3&gt;Statistics&lt;/h3&gt;
&lt;tr&gt;&lt;th&gt;Errors:&lt;/th&gt;&lt;td&gt;%8&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Warnings:&lt;/th&gt;&lt;td&gt;%9&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Style warnings:&lt;/th&gt;&lt;td&gt;%10&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Portability warnings:&lt;/th&gt;&lt;td&gt;%11&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Performance warnings:&lt;/th&gt;&lt;td&gt;%12&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Information messages:&lt;/th&gt;&lt;td&gt;%13&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@ -211,9 +211,9 @@ kate -l(line) (file)</translation>
<location filename="mainwindow.cpp" line="203"/>
<location filename="mainwindow.cpp" line="233"/>
<location filename="mainwindow.cpp" line="524"/>
<location filename="mainwindow.cpp" line="642"/>
<location filename="mainwindow.cpp" line="660"/>
<location filename="mainwindow.cpp" line="811"/>
<location filename="mainwindow.cpp" line="648"/>
<location filename="mainwindow.cpp" line="666"/>
<location filename="mainwindow.cpp" line="817"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
@ -546,14 +546,13 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="306"/>
<location filename="mainwindow.cpp" line="742"/>
<location filename="mainwindow.cpp" line="788"/>
<location filename="mainwindow.cpp" line="748"/>
<location filename="mainwindow.cpp" line="794"/>
<source>Project: </source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="443"/>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files (*.xml)</source>
<translation>XML (*.xml)</translation>
</message>
@ -583,31 +582,42 @@ Do you want to stop the checking and exit Cppcheck?.</source>
</message>
<message>
<location filename="mainwindow.cpp" line="582"/>
<source>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<translation>XML (*.xml);; (*.txt);;CSV形式ファイル (*.csv)</translation>
<source>XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<oldsource>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</oldsource>
<translation type="unfinished">XML (*.xml);; (*.txt);;CSV形式ファイル (*.csv)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="584"/>
<source>Save the report file</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files version 1 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="598"/>
<source>XML files version 2 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<source>Text files (*.txt)</source>
<translation> (*.txt)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="610"/>
<source>CSV files (*.csv)</source>
<translation>CSV形式ファイル (*.csv)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="644"/>
<location filename="mainwindow.cpp" line="650"/>
<source>Cppcheck - %1</source>
<translation>Cppcheck - %1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="661"/>
<location filename="mainwindow.cpp" line="667"/>
<source>Failed to change the language:
%1
@ -620,39 +630,39 @@ Do you want to stop the checking and exit Cppcheck?.</source>
</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="715"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Cppcheck Help</source>
<translation>Cppcheck </translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="715"/>
<source>Failed to load help file (not found)</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Failed to load help file</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="732"/>
<location filename="mainwindow.cpp" line="777"/>
<location filename="mainwindow.cpp" line="738"/>
<location filename="mainwindow.cpp" line="783"/>
<source>Project files (*.cppcheck);;All files(*.*)</source>
<translation> (*.cppcheck);;All files(*.*)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="734"/>
<location filename="mainwindow.cpp" line="740"/>
<source>Select Project File</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="779"/>
<location filename="mainwindow.cpp" line="785"/>
<source>Select Project Filename</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="812"/>
<location filename="mainwindow.cpp" line="818"/>
<source>No project file loaded</source>
<translation></translation>
</message>
@ -920,46 +930,47 @@ Please select the directory where file is located.</source>
<translation></translation>
</message>
<message>
<location filename="resultsview.cpp" line="117"/>
<location filename="resultsview.cpp" line="119"/>
<source>No errors found, nothing to save.</source>
<translation>/</translation>
</message>
<message>
<location filename="resultsview.cpp" line="144"/>
<location filename="resultsview.cpp" line="154"/>
<location filename="resultsview.cpp" line="149"/>
<location filename="resultsview.cpp" line="159"/>
<source>Failed to save the report.</source>
<translation></translation>
</message>
<message>
<location filename="resultsview.cpp" line="190"/>
<location filename="resultsview.cpp" line="202"/>
<location filename="resultsview.cpp" line="195"/>
<location filename="resultsview.cpp" line="207"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
<message>
<location filename="resultsview.cpp" line="191"/>
<location filename="resultsview.cpp" line="196"/>
<source>No errors found.</source>
<translation>/</translation>
</message>
<message>
<location filename="resultsview.cpp" line="199"/>
<location filename="resultsview.cpp" line="204"/>
<source>Errors were found, but they are configured to be hidden.
To toggle what kind of errors are shown, open view menu.</source>
<translation>/</translation>
</message>
<message>
<location filename="resultsview.cpp" line="251"/>
<location filename="resultsview.cpp" line="261"/>
<location filename="resultsview.cpp" line="271"/>
<location filename="resultsview.cpp" line="281"/>
<source>Failed to read the report.</source>
<translation>.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="302"/>
<location filename="resultsview.cpp" line="321"/>
<source>Summary</source>
<translation></translation>
</message>
<message>
<location filename="resultsview.cpp" line="303"/>
<location filename="resultsview.cpp" line="322"/>
<source>Message</source>
<translation></translation>
</message>

View File

@ -225,9 +225,9 @@ kate -l(line) (file)</translation>
<location filename="mainwindow.cpp" line="203"/>
<location filename="mainwindow.cpp" line="233"/>
<location filename="mainwindow.cpp" line="524"/>
<location filename="mainwindow.cpp" line="642"/>
<location filename="mainwindow.cpp" line="660"/>
<location filename="mainwindow.cpp" line="811"/>
<location filename="mainwindow.cpp" line="648"/>
<location filename="mainwindow.cpp" line="666"/>
<location filename="mainwindow.cpp" line="817"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
@ -565,8 +565,9 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="582"/>
<source>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<translation>XML bestanden (*.xml);;Tekst bestanden (*.txt);;CSV bestanden (*.csv)</translation>
<source>XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<oldsource>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</oldsource>
<translation type="unfinished">XML bestanden (*.xml);;Tekst bestanden (*.txt);;CSV bestanden (*.csv)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="584"/>
@ -575,7 +576,6 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="443"/>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files (*.xml)</source>
<translation>XML bestanden (*.xml)</translation>
</message>
@ -586,8 +586,8 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="306"/>
<location filename="mainwindow.cpp" line="742"/>
<location filename="mainwindow.cpp" line="788"/>
<location filename="mainwindow.cpp" line="748"/>
<location filename="mainwindow.cpp" line="794"/>
<source>Project: </source>
<translation type="unfinished"></translation>
</message>
@ -603,23 +603,33 @@ kate -l(line) (file)</translation>
Do you want to stop the checking and exit Cppcheck?.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files version 1 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="598"/>
<source>XML files version 2 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<source>Text files (*.txt)</source>
<translation>Tekst bestanden (*.txt)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="610"/>
<source>CSV files (*.csv)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="644"/>
<location filename="mainwindow.cpp" line="650"/>
<source>Cppcheck - %1</source>
<translation>Cppcheck - %1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="661"/>
<location filename="mainwindow.cpp" line="667"/>
<source>Failed to change the language:
%1
@ -633,39 +643,39 @@ Do you want to stop the checking and exit Cppcheck?.</source>
%1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="715"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Cppcheck Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="715"/>
<source>Failed to load help file (not found)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Failed to load help file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="732"/>
<location filename="mainwindow.cpp" line="777"/>
<location filename="mainwindow.cpp" line="738"/>
<location filename="mainwindow.cpp" line="783"/>
<source>Project files (*.cppcheck);;All files(*.*)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="734"/>
<location filename="mainwindow.cpp" line="740"/>
<source>Select Project File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="779"/>
<location filename="mainwindow.cpp" line="785"/>
<source>Select Project Filename</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="812"/>
<location filename="mainwindow.cpp" line="818"/>
<source>No project file loaded</source>
<translation type="unfinished"></translation>
</message>
@ -929,18 +939,18 @@ Please select the directory where file is located.</source>
<context>
<name>ResultsView</name>
<message>
<location filename="resultsview.cpp" line="190"/>
<location filename="resultsview.cpp" line="202"/>
<location filename="resultsview.cpp" line="195"/>
<location filename="resultsview.cpp" line="207"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
<message>
<location filename="resultsview.cpp" line="191"/>
<location filename="resultsview.cpp" line="196"/>
<source>No errors found.</source>
<translation>Geen fouten gevonden.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="199"/>
<location filename="resultsview.cpp" line="204"/>
<source>Errors were found, but they are configured to be hidden.
To toggle what kind of errors are shown, open view menu.</source>
<translation>Fouten werden gevonden, maar volgens de configuratie zijn deze verborgen.
@ -948,28 +958,29 @@ Gebruik het uitzicht menu om te selecteren welke fouten getoond worden.</transla
</message>
<message>
<location filename="resultsview.cpp" line="251"/>
<location filename="resultsview.cpp" line="261"/>
<location filename="resultsview.cpp" line="271"/>
<location filename="resultsview.cpp" line="281"/>
<source>Failed to read the report.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="302"/>
<location filename="resultsview.cpp" line="321"/>
<source>Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="303"/>
<location filename="resultsview.cpp" line="322"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="117"/>
<location filename="resultsview.cpp" line="119"/>
<source>No errors found, nothing to save.</source>
<translation>Geen fouten gevonden; geen data om op te slaan.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="144"/>
<location filename="resultsview.cpp" line="154"/>
<location filename="resultsview.cpp" line="149"/>
<location filename="resultsview.cpp" line="159"/>
<source>Failed to save the report.</source>
<translation>Kon het rapport niet opslaan.</translation>
</message>

View File

@ -212,9 +212,9 @@ kate -l(line) (file)</oldsource>
<location filename="mainwindow.cpp" line="203"/>
<location filename="mainwindow.cpp" line="233"/>
<location filename="mainwindow.cpp" line="524"/>
<location filename="mainwindow.cpp" line="642"/>
<location filename="mainwindow.cpp" line="660"/>
<location filename="mainwindow.cpp" line="811"/>
<location filename="mainwindow.cpp" line="648"/>
<location filename="mainwindow.cpp" line="666"/>
<location filename="mainwindow.cpp" line="817"/>
<source>Cppcheck</source>
<translation type="unfinished"></translation>
</message>
@ -547,8 +547,8 @@ kate -l(line) (file)</oldsource>
</message>
<message>
<location filename="mainwindow.cpp" line="306"/>
<location filename="mainwindow.cpp" line="742"/>
<location filename="mainwindow.cpp" line="788"/>
<location filename="mainwindow.cpp" line="748"/>
<location filename="mainwindow.cpp" line="794"/>
<source>Project: </source>
<translation type="unfinished"></translation>
</message>
@ -569,7 +569,8 @@ kate -l(line) (file)</oldsource>
</message>
<message>
<location filename="mainwindow.cpp" line="582"/>
<source>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<source>XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<oldsource>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
@ -578,34 +579,43 @@ kate -l(line) (file)</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files version 1 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="598"/>
<source>XML files version 2 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="715"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Cppcheck Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="715"/>
<source>Failed to load help file (not found)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Failed to load help file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="779"/>
<location filename="mainwindow.cpp" line="785"/>
<source>Select Project Filename</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="812"/>
<location filename="mainwindow.cpp" line="818"/>
<source>No project file loaded</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="443"/>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files (*.xml)</source>
<translation type="unfinished"></translation>
</message>
@ -617,22 +627,22 @@ Do you want to stop the checking and exit Cppcheck?.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="598"/>
<location filename="mainwindow.cpp" line="604"/>
<source>Text files (*.txt)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="610"/>
<source>CSV files (*.csv)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="644"/>
<location filename="mainwindow.cpp" line="650"/>
<source>Cppcheck - %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="661"/>
<location filename="mainwindow.cpp" line="667"/>
<source>Failed to change the language:
%1
@ -641,13 +651,13 @@ Do you want to stop the checking and exit Cppcheck?.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="732"/>
<location filename="mainwindow.cpp" line="777"/>
<location filename="mainwindow.cpp" line="738"/>
<location filename="mainwindow.cpp" line="783"/>
<source>Project files (*.cppcheck);;All files(*.*)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="734"/>
<location filename="mainwindow.cpp" line="740"/>
<source>Select Project File</source>
<translation type="unfinished"></translation>
</message>
@ -906,46 +916,47 @@ Please select the directory where file is located.</source>
<context>
<name>ResultsView</name>
<message>
<location filename="resultsview.cpp" line="190"/>
<location filename="resultsview.cpp" line="202"/>
<location filename="resultsview.cpp" line="195"/>
<location filename="resultsview.cpp" line="207"/>
<source>Cppcheck</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="191"/>
<location filename="resultsview.cpp" line="196"/>
<source>No errors found.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="199"/>
<location filename="resultsview.cpp" line="204"/>
<source>Errors were found, but they are configured to be hidden.
To toggle what kind of errors are shown, open view menu.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="251"/>
<location filename="resultsview.cpp" line="261"/>
<location filename="resultsview.cpp" line="271"/>
<location filename="resultsview.cpp" line="281"/>
<source>Failed to read the report.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="302"/>
<location filename="resultsview.cpp" line="321"/>
<source>Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="303"/>
<location filename="resultsview.cpp" line="322"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="117"/>
<location filename="resultsview.cpp" line="119"/>
<source>No errors found, nothing to save.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="144"/>
<location filename="resultsview.cpp" line="154"/>
<location filename="resultsview.cpp" line="149"/>
<location filename="resultsview.cpp" line="159"/>
<source>Failed to save the report.</source>
<translation type="unfinished"></translation>
</message>

View File

@ -215,9 +215,9 @@ kate -l(line) (file)</oldsource>
<location filename="mainwindow.cpp" line="203"/>
<location filename="mainwindow.cpp" line="233"/>
<location filename="mainwindow.cpp" line="524"/>
<location filename="mainwindow.cpp" line="642"/>
<location filename="mainwindow.cpp" line="660"/>
<location filename="mainwindow.cpp" line="811"/>
<location filename="mainwindow.cpp" line="648"/>
<location filename="mainwindow.cpp" line="666"/>
<location filename="mainwindow.cpp" line="817"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
@ -555,7 +555,8 @@ kate -l(line) (file)</oldsource>
</message>
<message>
<location filename="mainwindow.cpp" line="582"/>
<source>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<source>XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<oldsource>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
@ -565,7 +566,6 @@ kate -l(line) (file)</oldsource>
</message>
<message>
<location filename="mainwindow.cpp" line="443"/>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files (*.xml)</source>
<translation type="unfinished"></translation>
</message>
@ -576,8 +576,8 @@ kate -l(line) (file)</oldsource>
</message>
<message>
<location filename="mainwindow.cpp" line="306"/>
<location filename="mainwindow.cpp" line="742"/>
<location filename="mainwindow.cpp" line="788"/>
<location filename="mainwindow.cpp" line="748"/>
<location filename="mainwindow.cpp" line="794"/>
<source>Project: </source>
<translation type="unfinished"></translation>
</message>
@ -593,23 +593,33 @@ kate -l(line) (file)</oldsource>
Do you want to stop the checking and exit Cppcheck?.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files version 1 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="598"/>
<source>XML files version 2 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<source>Text files (*.txt)</source>
<translation>Текстовые файлы (*.txt)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="610"/>
<source>CSV files (*.csv)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="644"/>
<location filename="mainwindow.cpp" line="650"/>
<source>Cppcheck - %1</source>
<translation>Cppcheck - %1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="661"/>
<location filename="mainwindow.cpp" line="667"/>
<source>Failed to change the language:
%1
@ -625,39 +635,39 @@ Do you want to stop the checking and exit Cppcheck?.</source>
</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="715"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Cppcheck Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="715"/>
<source>Failed to load help file (not found)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Failed to load help file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="732"/>
<location filename="mainwindow.cpp" line="777"/>
<location filename="mainwindow.cpp" line="738"/>
<location filename="mainwindow.cpp" line="783"/>
<source>Project files (*.cppcheck);;All files(*.*)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="734"/>
<location filename="mainwindow.cpp" line="740"/>
<source>Select Project File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="779"/>
<location filename="mainwindow.cpp" line="785"/>
<source>Select Project Filename</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="812"/>
<location filename="mainwindow.cpp" line="818"/>
<source>No project file loaded</source>
<translation type="unfinished"></translation>
</message>
@ -919,46 +929,47 @@ Please select the directory where file is located.</source>
<context>
<name>ResultsView</name>
<message>
<location filename="resultsview.cpp" line="190"/>
<location filename="resultsview.cpp" line="202"/>
<location filename="resultsview.cpp" line="195"/>
<location filename="resultsview.cpp" line="207"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
<message>
<location filename="resultsview.cpp" line="191"/>
<location filename="resultsview.cpp" line="196"/>
<source>No errors found.</source>
<translation>Ошибок не найдено.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="199"/>
<location filename="resultsview.cpp" line="204"/>
<source>Errors were found, but they are configured to be hidden.
To toggle what kind of errors are shown, open view menu.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="251"/>
<location filename="resultsview.cpp" line="261"/>
<location filename="resultsview.cpp" line="271"/>
<location filename="resultsview.cpp" line="281"/>
<source>Failed to read the report.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="302"/>
<location filename="resultsview.cpp" line="321"/>
<source>Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="303"/>
<location filename="resultsview.cpp" line="322"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="117"/>
<location filename="resultsview.cpp" line="119"/>
<source>No errors found, nothing to save.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="144"/>
<location filename="resultsview.cpp" line="154"/>
<location filename="resultsview.cpp" line="149"/>
<location filename="resultsview.cpp" line="159"/>
<source>Failed to save the report.</source>
<translation type="unfinished"></translation>
</message>

View File

@ -225,9 +225,9 @@ kate -l(line) (file)</translation>
<location filename="mainwindow.cpp" line="203"/>
<location filename="mainwindow.cpp" line="233"/>
<location filename="mainwindow.cpp" line="524"/>
<location filename="mainwindow.cpp" line="642"/>
<location filename="mainwindow.cpp" line="660"/>
<location filename="mainwindow.cpp" line="811"/>
<location filename="mainwindow.cpp" line="648"/>
<location filename="mainwindow.cpp" line="666"/>
<location filename="mainwindow.cpp" line="817"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
@ -566,8 +566,9 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="582"/>
<source>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<translation>XML filer (*.xml);;Text filer (*.txt);;CSV filer (*.csv)</translation>
<source>XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<oldsource>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</oldsource>
<translation type="unfinished">XML filer (*.xml);;Text filer (*.txt);;CSV filer (*.csv)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="584"/>
@ -576,7 +577,6 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="443"/>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files (*.xml)</source>
<translation>XML filer (*.xml)</translation>
</message>
@ -587,8 +587,8 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="306"/>
<location filename="mainwindow.cpp" line="742"/>
<location filename="mainwindow.cpp" line="788"/>
<location filename="mainwindow.cpp" line="748"/>
<location filename="mainwindow.cpp" line="794"/>
<source>Project: </source>
<translation>Projekt.</translation>
</message>
@ -606,23 +606,33 @@ Do you want to stop the checking and exit Cppcheck?.</source>
Vill du stoppa analysen och avsluta Cppcheck?</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files version 1 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="598"/>
<source>XML files version 2 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<source>Text files (*.txt)</source>
<translation>Text filer (*.txt)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="610"/>
<source>CSV files (*.csv)</source>
<translation>CSV filer (*.csv)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="644"/>
<location filename="mainwindow.cpp" line="650"/>
<source>Cppcheck - %1</source>
<translation>Cppcheck - %1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="661"/>
<location filename="mainwindow.cpp" line="667"/>
<source>Failed to change the language:
%1
@ -638,39 +648,39 @@ Vill du stoppa analysen och avsluta Cppcheck?</translation>
</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="715"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Cppcheck Help</source>
<translation>Cppcheck Hjälp</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="715"/>
<source>Failed to load help file (not found)</source>
<translation>Misslyckades att öppna hjälpfilen (hittades ej)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Failed to load help file</source>
<translation>Misslykades att öppna hjälpfilen</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="732"/>
<location filename="mainwindow.cpp" line="777"/>
<location filename="mainwindow.cpp" line="738"/>
<location filename="mainwindow.cpp" line="783"/>
<source>Project files (*.cppcheck);;All files(*.*)</source>
<translation>Projektfiler (*.cppcheck);;Alla filer(*.*)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="734"/>
<location filename="mainwindow.cpp" line="740"/>
<source>Select Project File</source>
<translation>Välj projektfil</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="779"/>
<location filename="mainwindow.cpp" line="785"/>
<source>Select Project Filename</source>
<translation>Välj Projektfil</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="812"/>
<location filename="mainwindow.cpp" line="818"/>
<source>No project file loaded</source>
<translation>Inget projekt laddat</translation>
</message>
@ -936,18 +946,18 @@ Välj mappen där filen finns.</translation>
<context>
<name>ResultsView</name>
<message>
<location filename="resultsview.cpp" line="190"/>
<location filename="resultsview.cpp" line="202"/>
<location filename="resultsview.cpp" line="195"/>
<location filename="resultsview.cpp" line="207"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
<message>
<location filename="resultsview.cpp" line="191"/>
<location filename="resultsview.cpp" line="196"/>
<source>No errors found.</source>
<translation>Inga fel hittades.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="199"/>
<location filename="resultsview.cpp" line="204"/>
<source>Errors were found, but they are configured to be hidden.
To toggle what kind of errors are shown, open view menu.</source>
<translation>Fel hittades, men de visas ej.
@ -955,28 +965,29 @@ För att ställa in vilka fel som skall visas använd visa menyn.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="251"/>
<location filename="resultsview.cpp" line="261"/>
<location filename="resultsview.cpp" line="271"/>
<location filename="resultsview.cpp" line="281"/>
<source>Failed to read the report.</source>
<translation>Misslyckades att läsa rapporten.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="302"/>
<location filename="resultsview.cpp" line="321"/>
<source>Summary</source>
<translation>Sammanfattning</translation>
</message>
<message>
<location filename="resultsview.cpp" line="303"/>
<location filename="resultsview.cpp" line="322"/>
<source>Message</source>
<translation>Meddelande</translation>
</message>
<message>
<location filename="resultsview.cpp" line="117"/>
<location filename="resultsview.cpp" line="119"/>
<source>No errors found, nothing to save.</source>
<translation>Inga fel hittades, ingenting att spara.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="144"/>
<location filename="resultsview.cpp" line="154"/>
<location filename="resultsview.cpp" line="149"/>
<location filename="resultsview.cpp" line="159"/>
<source>Failed to save the report.</source>
<translation>Misslyckades med att spara rapporten.</translation>
</message>

View File

@ -225,9 +225,9 @@ kate -l(line) (file)</translation>
<location filename="mainwindow.cpp" line="203"/>
<location filename="mainwindow.cpp" line="233"/>
<location filename="mainwindow.cpp" line="524"/>
<location filename="mainwindow.cpp" line="642"/>
<location filename="mainwindow.cpp" line="660"/>
<location filename="mainwindow.cpp" line="811"/>
<location filename="mainwindow.cpp" line="648"/>
<location filename="mainwindow.cpp" line="666"/>
<location filename="mainwindow.cpp" line="817"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
@ -565,8 +565,9 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="582"/>
<source>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<translation>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</translation>
<source>XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv)</source>
<oldsource>XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</oldsource>
<translation type="unfinished">XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="584"/>
@ -575,7 +576,6 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="443"/>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files (*.xml)</source>
<translation>XML files (*.xml)</translation>
</message>
@ -586,8 +586,8 @@ kate -l(line) (file)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="306"/>
<location filename="mainwindow.cpp" line="742"/>
<location filename="mainwindow.cpp" line="788"/>
<location filename="mainwindow.cpp" line="748"/>
<location filename="mainwindow.cpp" line="794"/>
<source>Project: </source>
<translation type="unfinished"></translation>
</message>
@ -603,23 +603,33 @@ kate -l(line) (file)</translation>
Do you want to stop the checking and exit Cppcheck?.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="592"/>
<source>XML files version 1 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="598"/>
<source>XML files version 2 (*.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<source>Text files (*.txt)</source>
<translation>Text files (*.txt)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="610"/>
<source>CSV files (*.csv)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="644"/>
<location filename="mainwindow.cpp" line="650"/>
<source>Cppcheck - %1</source>
<translation>Cppcheck - %1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="661"/>
<location filename="mainwindow.cpp" line="667"/>
<source>Failed to change the language:
%1
@ -633,39 +643,39 @@ Do you want to stop the checking and exit Cppcheck?.</source>
%1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="715"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Cppcheck Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="709"/>
<location filename="mainwindow.cpp" line="715"/>
<source>Failed to load help file (not found)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="724"/>
<source>Failed to load help file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="732"/>
<location filename="mainwindow.cpp" line="777"/>
<location filename="mainwindow.cpp" line="738"/>
<location filename="mainwindow.cpp" line="783"/>
<source>Project files (*.cppcheck);;All files(*.*)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="734"/>
<location filename="mainwindow.cpp" line="740"/>
<source>Select Project File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="779"/>
<location filename="mainwindow.cpp" line="785"/>
<source>Select Project Filename</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="812"/>
<location filename="mainwindow.cpp" line="818"/>
<source>No project file loaded</source>
<translation type="unfinished"></translation>
</message>
@ -929,18 +939,18 @@ Please select the directory where file is located.</source>
<context>
<name>ResultsView</name>
<message>
<location filename="resultsview.cpp" line="190"/>
<location filename="resultsview.cpp" line="202"/>
<location filename="resultsview.cpp" line="195"/>
<location filename="resultsview.cpp" line="207"/>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
<message>
<location filename="resultsview.cpp" line="191"/>
<location filename="resultsview.cpp" line="196"/>
<source>No errors found.</source>
<translation>No errors found.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="199"/>
<location filename="resultsview.cpp" line="204"/>
<source>Errors were found, but they are configured to be hidden.
To toggle what kind of errors are shown, open view menu.</source>
<translation>Errors were found, but they are configured to be hidden.
@ -948,28 +958,29 @@ To toggle what kind of errors are shown, open view menu.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="251"/>
<location filename="resultsview.cpp" line="261"/>
<location filename="resultsview.cpp" line="271"/>
<location filename="resultsview.cpp" line="281"/>
<source>Failed to read the report.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="302"/>
<location filename="resultsview.cpp" line="321"/>
<source>Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="303"/>
<location filename="resultsview.cpp" line="322"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="resultsview.cpp" line="117"/>
<location filename="resultsview.cpp" line="119"/>
<source>No errors found, nothing to save.</source>
<translation>No errors found, nothing to save.</translation>
</message>
<message>
<location filename="resultsview.cpp" line="144"/>
<location filename="resultsview.cpp" line="154"/>
<location filename="resultsview.cpp" line="149"/>
<location filename="resultsview.cpp" line="159"/>
<source>Failed to save the report.</source>
<translation>Failed to save the report.</translation>
</message>

View File

@ -35,6 +35,7 @@ FORMS = main.ui \
stats.ui
TRANSLATIONS = cppcheck_fi.ts \
cppcheck_fr.ts \
cppcheck_nl.ts \
cppcheck_en.ts \
cppcheck_se.ts \
@ -69,6 +70,8 @@ HEADERS += mainwindow.h \
report.h \
txtreport.h \
xmlreport.h \
xmlreportv1.h \
xmlreportv2.h \
translationhandler.h \
csvreport.h \
logview.h \
@ -96,6 +99,8 @@ SOURCES += main.cpp \
report.cpp \
txtreport.cpp \
xmlreport.cpp \
xmlreportv1.cpp \
xmlreportv2.cpp \
translationhandler.cpp \
csvreport.cpp \
logview.cpp \

View File

@ -42,7 +42,6 @@ MainWindow::MainWindow() :
mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)),
mApplications(new ApplicationList(this)),
mTranslation(new TranslationHandler(this)),
mLanguages(new QActionGroup(this)),
mLogView(NULL),
mHelpWindow(NULL),
mProject(NULL),
@ -155,7 +154,7 @@ void MainWindow::LoadSettings()
mApplications->LoadSettings(mSettings);
SetLanguage(mSettings->value(SETTINGS_LANGUAGE, mTranslation->SuggestLanguage()).toInt());
SetLanguage(mSettings->value(SETTINGS_LANGUAGE, mTranslation->SuggestLanguage()).toString());
}
void MainWindow::SaveSettings()
@ -411,10 +410,8 @@ void MainWindow::ProgramSettings()
dialog.SaveFullPath(),
dialog.SaveAllErrors(),
dialog.ShowNoErrorsMessage());
const int currentLang = mTranslation->GetCurrentLanguage();
const int newLang = mSettings->value(SETTINGS_LANGUAGE, 0).toInt();
if (currentLang != newLang)
SetLanguage(newLang);
const QString newLang = mSettings->value(SETTINGS_LANGUAGE, "en").toString();
SetLanguage(newLang);
}
}
@ -579,7 +576,7 @@ void MainWindow::ShowAuthors()
void MainWindow::Save()
{
QString selectedFilter;
QString filter(tr("XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)"));
QString filter(tr("XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv)"));
QString selectedFile = QFileDialog::getSaveFileName(this,
tr("Save the report file"),
QString(),
@ -589,12 +586,18 @@ void MainWindow::Save()
if (!selectedFile.isEmpty())
{
Report::Type type = Report::TXT;
if (selectedFilter == tr("XML files (*.xml)"))
if (selectedFilter == tr("XML files version 1 (*.xml)"))
{
type = Report::XML;
if (!selectedFile.endsWith(".xml", Qt::CaseInsensitive))
selectedFile += ".xml";
}
else if (selectedFilter == tr("XML files version 2 (*.xml)"))
{
type = Report::XMLV2;
if (!selectedFile.endsWith(".xml", Qt::CaseInsensitive))
selectedFile += ".xml";
}
else if (selectedFilter == tr("Text files (*.txt)"))
{
type = Report::TXT;
@ -645,20 +648,18 @@ void MainWindow::FormatAndSetTitle(const QString &text)
setWindowTitle(title);
}
void MainWindow::SetLanguage(int index)
void MainWindow::SetLanguage(const QString &code)
{
if (mTranslation->GetCurrentLanguage() == index)
{
const QString currentLang = mTranslation->GetCurrentLanguage();
if (currentLang == code)
return;
}
QString error;
if (!mTranslation->SetLanguage(index, error))
if (!mTranslation->SetLanguage(code, error))
{
QMessageBox msg(QMessageBox::Critical,
tr("Cppcheck"),
QString(tr("Failed to change the language:\n\n%1\n\n")).arg(error),
QString(tr("Failed to change the language:\n\n%1")).arg(error),
QMessageBox::Ok,
this);
@ -669,16 +670,6 @@ void MainWindow::SetLanguage(int index)
//Translate everything that is visible here
mUI.retranslateUi(this);
mUI.mResults->Translate();
QStringList languages = mTranslation->GetNames();
QList<QAction *> actions = mLanguages->actions();
if (languages.size() <= actions.size())
{
for (int i = 0; i < languages.size(); i++)
{
actions[i]->setText(tr(languages[i].toLatin1()));
}
}
}
}

View File

@ -255,9 +255,9 @@ protected:
/**
* @brief Set current language
* @param index Index of the language to set
* @param code Language code of the language to set (e.g. "en").
*/
void SetLanguage(const int index);
void SetLanguage(const QString &code);
/**
* @brief Event coming when application is about to close.
@ -384,12 +384,6 @@ protected:
*/
Ui::MainWindow mUI;
/**
* @brief Group holding all supported languages
*
*/
QActionGroup *mLanguages;
/**
* @brief Current checked directory.
*/

View File

@ -39,6 +39,7 @@ public:
{
TXT,
XML,
XMLV2,
CSV,
};

View File

@ -31,6 +31,8 @@
#include "report.h"
#include "txtreport.h"
#include "xmlreport.h"
#include "xmlreportv1.h"
#include "xmlreportv2.h"
#include "csvreport.h"
#include "applicationlist.h"
#include "checkstatistics.h"
@ -130,7 +132,10 @@ void ResultsView::Save(const QString &filename, Report::Type type)
report = new TxtReport(filename, this);
break;
case Report::XML:
report = new XmlReport(filename, this);
report = new XmlReportV1(filename, this);
break;
case Report::XMLV2:
report = new XmlReportV2(filename, this);
break;
}
@ -239,8 +244,23 @@ void ResultsView::DisableProgressbar()
void ResultsView::ReadErrorsXml(const QString &filename)
{
XmlReport *report = new XmlReport(filename, this);
QList<ErrorLine> errors;
const int version = XmlReport::determineVersion(filename);
if (version == 0)
{
QMessageBox msgBox;
msgBox.setText(tr("Failed to read the report."));
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
return;
}
XmlReport *report = NULL;
if (version == 1)
report = new XmlReportV1(filename, this);
else if (version == 2)
report = new XmlReportV2(filename, this);
QList<ErrorItem> errors;
if (report)
{
if (report->Open())
@ -263,10 +283,9 @@ void ResultsView::ReadErrorsXml(const QString &filename)
msgBox.exec();
}
ErrorLine line;
foreach(line, errors)
ErrorItem item;
foreach(item, errors)
{
ErrorItem item(line);
mUI.mTree->AddErrorItem(item);
}
mUI.mTree->SetCheckDirectory("");

View File

@ -91,13 +91,17 @@ SettingsDialog::~SettingsDialog()
void SettingsDialog::InitTranslationsList()
{
QStringList languages = mTranslator->GetNames();
foreach(const QString lang, languages)
const QString current = mTranslator->GetCurrentLanguage();
QList<TranslationInfo> translations = mTranslator->GetTranslations();
foreach(TranslationInfo translation, translations)
{
mUI.mListLanguages->addItem(lang);
QListWidgetItem *item = new QListWidgetItem;
item->setText(translation.mName);
item->setData(LangCodeRole, QVariant(translation.mCode));
mUI.mListLanguages->addItem(item);
if (translation.mCode == current)
mUI.mListLanguages->setCurrentItem(item);
}
const int current = mTranslator->GetCurrentLanguage();
mUI.mListLanguages->setCurrentRow(current);
}
Qt::CheckState SettingsDialog::BoolToCheckState(bool yes) const
@ -148,7 +152,10 @@ void SettingsDialog::SaveSettingValues()
SaveCheckboxValue(mUI.mShowDebugWarnings, SETTINGS_SHOW_DEBUG_WARNINGS);
SaveCheckboxValue(mUI.mInlineSuppressions, SETTINGS_INLINE_SUPPRESSIONS);
mSettings->setValue(SETTINGS_GLOBAL_INCLUDE_PATHS, mUI.mEditIncludePaths->text());
mSettings->setValue(SETTINGS_LANGUAGE, mUI.mListLanguages->currentRow());
QListWidgetItem *currentLang = mUI.mListLanguages->currentItem();
const QString langcode = currentLang->data(LangCodeRole).toString();
mSettings->setValue(SETTINGS_LANGUAGE, langcode);
}
void SettingsDialog::SaveCheckboxValue(QCheckBox *box, const QString &name)

View File

@ -201,6 +201,7 @@ protected:
*/
Ui::Settings mUI;
private:
static const int LangCodeRole = Qt::UserRole;
};
/// @}
#endif // SETTINGSDIALOG_H

View File

@ -24,29 +24,21 @@
TranslationHandler::TranslationHandler(QObject *parent) :
QObject(parent),
mCurrentLanguage(-1),
mCurrentLanguage("en"),
mTranslator(new QTranslator(this))
{
//Add our default languages
mNames << QT_TRANSLATE_NOOP("MainWindow", "English")
<< QT_TRANSLATE_NOOP("MainWindow", "Dutch")
<< QT_TRANSLATE_NOOP("MainWindow", "Finnish")
<< QT_TRANSLATE_NOOP("MainWindow", "Swedish")
<< QT_TRANSLATE_NOOP("MainWindow", "German")
<< QT_TRANSLATE_NOOP("MainWindow", "Russian")
<< QT_TRANSLATE_NOOP("MainWindow", "Polish")
<< QT_TRANSLATE_NOOP("MainWindow", "Japanese")
<< QT_TRANSLATE_NOOP("MainWindow", "Serbian");
mFiles << "cppcheck_en"
<< "cppcheck_nl"
<< "cppcheck_fi"
<< "cppcheck_se"
<< "cppcheck_de"
<< "cppcheck_ru"
<< "cppcheck_pl"
<< "cppcheck_ja"
<< "cppcheck_sr";
// Add our available languages
// Keep this list sorted
AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Dutch"), "cppcheck_nl");
AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "English"), "cppcheck_en");
AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Finnish"), "cppcheck_fi");
AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "French"), "cppcheck_fr");
AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "German"), "cppcheck_de");
AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Japanese"), "cppcheck_ja");
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");
//Load English as a fallback language
QTranslator *english = new QTranslator();
@ -67,18 +59,18 @@ TranslationHandler::~TranslationHandler()
const QStringList TranslationHandler::GetNames() const
{
return mNames;
QStringList names;
foreach(TranslationInfo translation, mTranslations)
{
names.append(translation.mName);
}
return names;
}
const QStringList TranslationHandler::GetFiles() const
{
return mFiles;
}
bool TranslationHandler::SetLanguage(const int index, QString &error)
bool TranslationHandler::SetLanguage(const QString &code, QString &error)
{
//If English is the language
if (index == 0)
if (code == "en")
{
//Just remove all extra translators
if (mTranslator)
@ -86,48 +78,49 @@ bool TranslationHandler::SetLanguage(const int index, QString &error)
qApp->removeTranslator(mTranslator);
}
mCurrentLanguage = index;
mCurrentLanguage = code;
return true;
}
//Make sure the translator is otherwise valid
if (index >= mNames.size())
int index = GetLanguageIndexByCode(code);
if (index == -1)
{
error = QObject::tr("Incorrect language specified!");
error = QObject::tr("Unknown language specified!");
return false;
}
//Load the new language
if (!mTranslator->load(mFiles[index]))
if (!mTranslator->load(mTranslations[index].mFilename))
{
//If it failed, lets check if the default file exists
if (!QFile::exists(mFiles[index] + ".qm"))
if (!QFile::exists(mTranslations[index].mFilename + ".qm"))
{
error = QObject::tr("Language file %1 not found!");
error = error.arg(mFiles[index] + ".qm");
error = error.arg(mTranslations[index].mFilename + ".qm");
return false;
}
//If file exists, there's something wrong with it
error = QObject::tr("Failed to load translation for language %1 from file %2");
error = error.arg(mNames[index]);
error = error.arg(mFiles[index] + ".qm");
error = error.arg(mTranslations[index].mName);
error = error.arg(mTranslations[index].mFilename + ".qm");
return false;
}
qApp->installTranslator(mTranslator);
mCurrentLanguage = index;
mCurrentLanguage = code;
return true;
}
int TranslationHandler::GetCurrentLanguage() const
QString TranslationHandler::GetCurrentLanguage() const
{
return mCurrentLanguage;
}
int TranslationHandler::SuggestLanguage() const
QString TranslationHandler::SuggestLanguage() const
{
/*
Get language from system locale's name
@ -138,20 +131,37 @@ int TranslationHandler::SuggestLanguage() const
QString language = QLocale::system().name().left(2);
//qDebug()<<"Your language is"<<language;
//catenate that to the default language filename
QString file = QString("cppcheck_%1").arg(language);
//qDebug()<<"Language file could be"<<file;
//And see if we can find it from our list of language files
int index = mFiles.indexOf(file);
int index = GetLanguageIndexByCode(language);
//If nothing found, return English
if (index < 0)
{
return 0;
return "en";
}
return index;
return language;
}
void TranslationHandler::AddTranslation(const char *name, const char *filename)
{
TranslationInfo info;
info.mName = name;
info.mFilename = filename;
info.mCode = QString(filename).right(2);
mTranslations.append(info);
}
int TranslationHandler::GetLanguageIndexByCode(const QString &code) const
{
int index = -1;
for (int i = 0; i < mTranslations.size(); i++)
{
if (mTranslations[i].mCode == code)
{
index = i;
break;
}
}
return index;
}

View File

@ -22,28 +22,131 @@
#include <QStringList>
#include <QTranslator>
#include <QObject>
#include <QList>
/// @addtogroup GUI
/// @{
/**
* @brief Information for one translation.
*
*/
struct TranslationInfo
{
/**
* @brief Readable name for the translation (e.g. "English").
*
*/
QString mName;
/**
* @brief Filename for the translation.
*
*/
QString mFilename;
/**
* @brief ISO 639 language code for the translation (e.g. "en").
*
*/
QString mCode;
};
/**
* @brief A class handling the available translations.
*
* This class contains a list of available translations. The class also keeps
* track which translation is the currently active translation.
*
*/
class TranslationHandler : QObject
{
Q_OBJECT
public:
TranslationHandler(QObject *parent);
virtual ~TranslationHandler();
/**
* @brief Get a list of available translation names.
* @return List of available translation names.
*
*/
const QStringList GetNames() const;
const QStringList GetFiles() const;
bool SetLanguage(const int index, QString &error);
int GetCurrentLanguage() const;
int SuggestLanguage() const;
/**
* @brief Get a list of available translations.
* @return List of available translations.
*
*/
QList<TranslationInfo> GetTranslations() const
{
return mTranslations;
}
/**
* @brief Set active translation.
* @param ISO 639 language code for new selected translation.
* @param error Returns error string if selection fails.
* @return true if succeeds, false otherwise.
*
*/
bool SetLanguage(const QString &code, QString &error);
/**
* @brief Get currently selected translation.
* @return ISO 639 language code for current translation.
*
*/
QString GetCurrentLanguage() const;
/**
* @brief Get translation suggestion for the system.
* This function checks the current system locale and determines which of
* the available translations is best as current translation. If none of
* the available translations is good then it returns English ("en").
* @return Suggested translation ISO 639 language code.
*
*/
QString SuggestLanguage() const;
protected:
int mCurrentLanguage;
QStringList mNames;
QStringList mFiles;
QTranslator *mTranslator;
/**
* @brief Add new translation to list of available translations.
* @param name Name of the translation ("English").
* @param filename Filename of the translation.
*
*/
void AddTranslation(const char *name, const char *filename);
/**
* @brief Find language in the list and return its index.
* @param code ISO 639 language code.
* @return Index at list, or -1 if not found.
*
*/
int GetLanguageIndexByCode(const QString &code) const;
private:
/**
* @brief ISO 639 language code of the currently selected translation.
*
*/
QString mCurrentLanguage;
/**
* @brief List of available translations.
*
*/
QList<TranslationInfo> mTranslations;
/**
* @brief Translator class instance.
*
*/
QTranslator *mTranslator;
};
/// @}
#endif // TRANSLATIONHANDLER_H

View File

@ -18,122 +18,70 @@
#include <QObject>
#include <QString>
#include <QList>
#include <QDir>
#include <QFile>
#include <QXmlStreamWriter>
#include <QDebug>
#include <QXmlStreamReader>
#include "report.h"
#include "erroritem.h"
#include "xmlreport.h"
static const char ResultElementName[] = "results";
static const char ErrorElementName[] = "error";
static const char FilenameAttribute[] = "file";
static const char LineAttribute[] = "line";
static const char IdAttribute[] = "id";
static const char SeverityAttribute[] = "severity";
static const char MsgAttribute[] = "msg";
static const char VersionAttribute[] = "version";
XmlReport::XmlReport(const QString &filename, QObject * parent) :
Report(filename, parent),
mXmlReader(NULL),
mXmlWriter(NULL)
Report(filename, parent)
{
}
XmlReport::~XmlReport()
QString XmlReport::quoteMessage(const QString &message)
{
delete mXmlReader;
delete mXmlWriter;
Close();
QString quotedMessage(message);
quotedMessage.replace("&", "&amp;");
quotedMessage.replace("\"", "&quot;");
quotedMessage.replace("'", "&#039;");
quotedMessage.replace("<", "&lt;");
quotedMessage.replace(">", "&gt;");
return quotedMessage;
}
bool XmlReport::Create()
QString XmlReport::unquoteMessage(const QString &message)
{
bool success = false;
if (Report::Create())
QString quotedMessage(message);
quotedMessage.replace("&amp;", "&");
quotedMessage.replace("&quot;", "\"");
quotedMessage.replace("&#039;", "'");
quotedMessage.replace("&lt;", "<");
quotedMessage.replace("&gt;", ">");
return quotedMessage;
}
int XmlReport::determineVersion(const QString &filename)
{
QFile file;
file.setFileName(filename);
bool succeed = file.open(QIODevice::ReadOnly | QIODevice::Text);
if (!succeed)
return 0;
QXmlStreamReader reader(&file);
while (!reader.atEnd())
{
mXmlWriter = new QXmlStreamWriter(Report::GetFile());
success = true;
}
return success;
}
bool XmlReport::Open()
{
bool success = false;
if (Report::Open())
{
mXmlReader = new QXmlStreamReader(Report::GetFile());
success = true;
}
return success;
}
void XmlReport::WriteHeader()
{
mXmlWriter->setAutoFormatting(true);
mXmlWriter->writeStartDocument();
mXmlWriter->writeStartElement(ResultElementName);
}
void XmlReport::WriteFooter()
{
mXmlWriter->writeEndElement();
mXmlWriter->writeEndDocument();
}
void XmlReport::WriteError(const ErrorItem &error)
{
/*
Error example from the core program in xml
<error file="gui/test.cpp" line="14" id="mismatchAllocDealloc" severity="error" msg="Mismatching allocation and deallocation: k"/>
The callstack seems to be ignored here as well, instead last item of the stack is used
*/
mXmlWriter->writeStartElement(ErrorElementName);
const QString file = QDir::toNativeSeparators(error.files[error.files.size() - 1]);
mXmlWriter->writeAttribute(FilenameAttribute, file);
const QString line = QString::number(error.lines[error.lines.size() - 1]);
mXmlWriter->writeAttribute(LineAttribute, line);
mXmlWriter->writeAttribute(IdAttribute, error.id);
mXmlWriter->writeAttribute(SeverityAttribute, error.severity);
mXmlWriter->writeAttribute(MsgAttribute, error.message);
mXmlWriter->writeEndElement();
}
QList<ErrorLine> XmlReport::Read()
{
QList<ErrorLine> errors;
bool insideResults = false;
if (!mXmlReader)
{
qDebug() << "You must Open() the file before reading it!";
return errors;
}
while (!mXmlReader->atEnd())
{
switch (mXmlReader->readNext())
switch (reader.readNext())
{
case QXmlStreamReader::StartElement:
if (mXmlReader->name() == ResultElementName)
insideResults = true;
// Read error element from inside result element
if (insideResults && mXmlReader->name() == ErrorElementName)
if (reader.name() == ResultElementName)
{
ErrorLine line = ReadError(mXmlReader);
errors.append(line);
QXmlStreamAttributes attribs = reader.attributes();
if (attribs.hasAttribute(QString(VersionAttribute)))
{
int ver = attribs.value("", VersionAttribute).toString().toInt();
return ver;
}
else
return 1;
}
break;
case QXmlStreamReader::EndElement:
if (mXmlReader->name() == ResultElementName)
insideResults = false;
break;
// Not handled
case QXmlStreamReader::EndElement:
case QXmlStreamReader::NoToken:
case QXmlStreamReader::Invalid:
case QXmlStreamReader::StartDocument:
@ -146,30 +94,5 @@ QList<ErrorLine> XmlReport::Read()
break;
}
}
return errors;
}
ErrorLine XmlReport::ReadError(QXmlStreamReader *reader)
{
ErrorLine line;
if (reader->name().toString() == ErrorElementName)
{
QXmlStreamAttributes attribs = reader->attributes();
line.file = attribs.value("", FilenameAttribute).toString();
line.line = attribs.value("", LineAttribute).toString().toUInt();
line.id = attribs.value("", IdAttribute).toString();
line.severity = attribs.value("", SeverityAttribute).toString();
// NOTE: This dublicates the message to Summary-field. But since
// old XML format doesn't have separate summary and verbose messages
// we must add same message to both data so it shows up in GUI.
// Check if there is full stop and cut the summary to it.
QString summary = attribs.value("", MsgAttribute).toString();
const int ind = summary.indexOf('.');
if (ind != -1)
summary = summary.left(ind + 1);
line.summary = summary;
line.message = attribs.value("", MsgAttribute).toString();
}
return line;
return 0;
}

View File

@ -19,78 +19,51 @@
#ifndef XML_REPORT_H
#define XML_REPORT_H
#include <QObject>
#include <QString>
#include <QStringList>
#include <QFile>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QList>
#include "report.h"
#include "erroritem.h"
class QObject;
/// @addtogroup GUI
/// @{
/**
* @brief XML file report.
* This report outputs XML-formatted report. The XML format must match command
* line version's XML output.
* @brief Base class for XML report classes.
*/
class XmlReport : public Report
{
public:
XmlReport(const QString &filename, QObject * parent = 0);
virtual ~XmlReport();
/**
* @brief Create the report (file).
* @return true if succeeded, false if file could not be created.
*/
virtual bool Create();
* @brief Read contents of the report file.
*/
virtual QList<ErrorItem> Read() = 0;
/**
* @brief Open existing report file.
*/
bool Open();
* @brief Quote the message.
* @param message Message to quote.
* @return quoted message.
*/
static QString quoteMessage(const QString &message);
/**
* @brief Write report header.
*/
virtual void WriteHeader();
* @brief Unquote the message.
* @param message Message to quote.
* @return quoted message.
*/
static QString unquoteMessage(const QString &message);
/**
* @brief Write report footer.
*/
virtual void WriteFooter();
/**
* @brief Write error to report.
* @param error Error data.
*/
virtual void WriteError(const ErrorItem &error);
/**
* @brief Read contents of the report file.
*/
QList<ErrorLine> Read();
protected:
/**
* @brief Read and parse error item from XML stream.
* @param reader XML stream reader to use.
*/
ErrorLine ReadError(QXmlStreamReader *reader);
private:
/**
* @brief XML stream reader for reading the report in XML format.
*/
QXmlStreamReader *mXmlReader;
/**
* @brief XML stream writer for writing the report in XML format.
*/
QXmlStreamWriter *mXmlWriter;
* @brief Get the XML report format version from the file.
* @param filename Filename of the report file.
* @return XML report format version or 0 if error happened.
*/
static int determineVersion(const QString &filename);
};
/// @}
#endif // XML_REPORT_H

183
gui/xmlreportv1.cpp Normal file
View File

@ -0,0 +1,183 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include <QString>
#include <QList>
#include <QDir>
#include <QFile>
#include <QXmlStreamWriter>
#include <QDebug>
#include "report.h"
#include "erroritem.h"
#include "xmlreport.h"
#include "xmlreportv1.h"
static const char ResultElementName[] = "results";
static const char ErrorElementName[] = "error";
static const char FilenameAttribute[] = "file";
static const char LineAttribute[] = "line";
static const char IdAttribute[] = "id";
static const char SeverityAttribute[] = "severity";
static const char MsgAttribute[] = "msg";
XmlReportV1::XmlReportV1(const QString &filename, QObject * parent) :
XmlReport(filename, parent),
mXmlReader(NULL),
mXmlWriter(NULL)
{
}
XmlReportV1::~XmlReportV1()
{
delete mXmlReader;
delete mXmlWriter;
Close();
}
bool XmlReportV1::Create()
{
bool success = false;
if (Report::Create())
{
mXmlWriter = new QXmlStreamWriter(Report::GetFile());
success = true;
}
return success;
}
bool XmlReportV1::Open()
{
bool success = false;
if (Report::Open())
{
mXmlReader = new QXmlStreamReader(Report::GetFile());
success = true;
}
return success;
}
void XmlReportV1::WriteHeader()
{
mXmlWriter->setAutoFormatting(true);
mXmlWriter->writeStartDocument();
mXmlWriter->writeStartElement(ResultElementName);
}
void XmlReportV1::WriteFooter()
{
mXmlWriter->writeEndElement();
mXmlWriter->writeEndDocument();
}
void XmlReportV1::WriteError(const ErrorItem &error)
{
/*
Error example from the core program in xml
<error file="gui/test.cpp" line="14" id="mismatchAllocDealloc" severity="error" msg="Mismatching allocation and deallocation: k"/>
The callstack seems to be ignored here as well, instead last item of the stack is used
*/
mXmlWriter->writeStartElement(ErrorElementName);
QString file = QDir::toNativeSeparators(error.files[error.files.size() - 1]);
file = XmlReport::quoteMessage(file);
mXmlWriter->writeAttribute(FilenameAttribute, file);
const QString line = QString::number(error.lines[error.lines.size() - 1]);
mXmlWriter->writeAttribute(LineAttribute, line);
mXmlWriter->writeAttribute(IdAttribute, error.id);
mXmlWriter->writeAttribute(SeverityAttribute, error.severity);
const QString message = XmlReport::quoteMessage(error.message);
mXmlWriter->writeAttribute(MsgAttribute, message);
mXmlWriter->writeEndElement();
}
QList<ErrorItem> XmlReportV1::Read()
{
QList<ErrorItem> errors;
bool insideResults = false;
if (!mXmlReader)
{
qDebug() << "You must Open() the file before reading it!";
return errors;
}
while (!mXmlReader->atEnd())
{
switch (mXmlReader->readNext())
{
case QXmlStreamReader::StartElement:
if (mXmlReader->name() == ResultElementName)
insideResults = true;
// Read error element from inside result element
if (insideResults && mXmlReader->name() == ErrorElementName)
{
ErrorItem item = ReadError(mXmlReader);
errors.append(item);
}
break;
case QXmlStreamReader::EndElement:
if (mXmlReader->name() == ResultElementName)
insideResults = false;
break;
// Not handled
case QXmlStreamReader::NoToken:
case QXmlStreamReader::Invalid:
case QXmlStreamReader::StartDocument:
case QXmlStreamReader::EndDocument:
case QXmlStreamReader::Characters:
case QXmlStreamReader::Comment:
case QXmlStreamReader::DTD:
case QXmlStreamReader::EntityReference:
case QXmlStreamReader::ProcessingInstruction:
break;
}
}
return errors;
}
ErrorItem XmlReportV1::ReadError(QXmlStreamReader *reader)
{
ErrorItem item;
if (reader->name().toString() == ErrorElementName)
{
QXmlStreamAttributes attribs = reader->attributes();
QString file = attribs.value("", FilenameAttribute).toString();
file = XmlReport::unquoteMessage(file);
item.file = file;
item.files.push_back(file);
const int line = attribs.value("", LineAttribute).toString().toUInt();
item.lines.push_back(line);
item.id = attribs.value("", IdAttribute).toString();
item.severity = attribs.value("", SeverityAttribute).toString();
// NOTE: This dublicates the message to Summary-field. But since
// old XML format doesn't have separate summary and verbose messages
// we must add same message to both data so it shows up in GUI.
// Check if there is full stop and cut the summary to it.
QString summary = attribs.value("", MsgAttribute).toString();
const int ind = summary.indexOf('.');
if (ind != -1)
summary = summary.left(ind + 1);
item.summary = XmlReport::unquoteMessage(summary);
QString message = attribs.value("", MsgAttribute).toString();
item.message = XmlReport::unquoteMessage(message);
}
return item;
}

96
gui/xmlreportv1.h Normal file
View File

@ -0,0 +1,96 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef XML_REPORTV1_H
#define XML_REPORTV1_H
#include <QObject>
#include <QString>
#include <QStringList>
#include <QFile>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include "xmlreport.h"
/// @addtogroup GUI
/// @{
/**
* @brief XML file report version 1.
* This report outputs XML-formatted report, version 1. The XML format must match command
* line version's XML output.
*/
class XmlReportV1 : public XmlReport
{
public:
XmlReportV1(const QString &filename, QObject * parent = 0);
virtual ~XmlReportV1();
/**
* @brief Create the report (file).
* @return true if succeeded, false if file could not be created.
*/
virtual bool Create();
/**
* @brief Open existing report file.
*/
bool Open();
/**
* @brief Write report header.
*/
virtual void WriteHeader();
/**
* @brief Write report footer.
*/
virtual void WriteFooter();
/**
* @brief Write error to report.
* @param error Error data.
*/
virtual void WriteError(const ErrorItem &error);
/**
* @brief Read contents of the report file.
*/
virtual QList<ErrorItem> Read();
protected:
/**
* @brief Read and parse error item from XML stream.
* @param reader XML stream reader to use.
*/
ErrorItem ReadError(QXmlStreamReader *reader);
private:
/**
* @brief XML stream reader for reading the report in XML format.
*/
QXmlStreamReader *mXmlReader;
/**
* @brief XML stream writer for writing the report in XML format.
*/
QXmlStreamWriter *mXmlWriter;
};
/// @}
#endif // XML_REPORTV1_H

246
gui/xmlreportv2.cpp Normal file
View File

@ -0,0 +1,246 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include <QString>
#include <QList>
#include <QDir>
#include <QFile>
#include <QXmlStreamWriter>
#include <QDebug>
#include "report.h"
#include "erroritem.h"
#include "xmlreport.h"
#include "xmlreportv2.h"
#include "cppcheck.h"
static const char ResultElementName[] = "results";
static const char CppcheckElementName[] = "cppcheck";
static const char ErrorElementName[] = "error";
static const char ErrorsElementName[] = "errors";
static const char LocationElementName[] = "location";
static const char FilenameAttribute[] = "file";
static const char LineAttribute[] = "line";
static const char IdAttribute[] = "id";
static const char SeverityAttribute[] = "severity";
static const char MsgAttribute[] = "msg";
static const char VersionAttribute[] = "version";
static const char VerboseAttribute[] = "verbose";
XmlReportV2::XmlReportV2(const QString &filename, QObject * parent) :
XmlReport(filename, parent),
mXmlReader(NULL),
mXmlWriter(NULL)
{
}
XmlReportV2::~XmlReportV2()
{
delete mXmlReader;
delete mXmlWriter;
Close();
}
bool XmlReportV2::Create()
{
bool success = false;
if (Report::Create())
{
mXmlWriter = new QXmlStreamWriter(Report::GetFile());
success = true;
}
return success;
}
bool XmlReportV2::Open()
{
bool success = false;
if (Report::Open())
{
mXmlReader = new QXmlStreamReader(Report::GetFile());
success = true;
}
return success;
}
void XmlReportV2::WriteHeader()
{
mXmlWriter->setAutoFormatting(true);
mXmlWriter->writeStartDocument();
mXmlWriter->writeStartElement(ResultElementName);
mXmlWriter->writeAttribute(VersionAttribute, QString::number(2));
mXmlWriter->writeStartElement(CppcheckElementName);
mXmlWriter->writeAttribute(VersionAttribute, QString(CppCheck::version()));
mXmlWriter->writeEndElement();
mXmlWriter->writeStartElement(ErrorsElementName);
}
void XmlReportV2::WriteFooter()
{
mXmlWriter->writeEndElement(); // errors
mXmlWriter->writeEndElement(); // results
mXmlWriter->writeEndDocument();
}
void XmlReportV2::WriteError(const ErrorItem &error)
{
/*
Error example from the core program in xml
<error id="mismatchAllocDealloc" severity="error" msg="Mismatching allocation and deallocation: k"
verbose="Mismatching allocation and deallocation: k">
<location file="..\..\test\test.cxx" line="16"/>
<location file="..\..\test\test.cxx" line="32"/>
</error>
*/
mXmlWriter->writeStartElement(ErrorElementName);
mXmlWriter->writeAttribute(IdAttribute, error.id);
mXmlWriter->writeAttribute(SeverityAttribute, error.severity);
const QString summary = XmlReport::quoteMessage(error.summary);
mXmlWriter->writeAttribute(MsgAttribute, summary);
const QString message = XmlReport::quoteMessage(error.message);
mXmlWriter->writeAttribute(VerboseAttribute, message);
for (int i = 0; i < error.files.count(); i++)
{
mXmlWriter->writeStartElement(LocationElementName);
QString file = QDir::toNativeSeparators(error.files[i]);
file = XmlReport::quoteMessage(file);
mXmlWriter->writeAttribute(FilenameAttribute, file);
const QString line = QString::number(error.lines[i]);
mXmlWriter->writeAttribute(LineAttribute, line);
mXmlWriter->writeEndElement();
}
mXmlWriter->writeEndElement();
}
QList<ErrorItem> XmlReportV2::Read()
{
QList<ErrorItem> errors;
bool insideResults = false;
if (!mXmlReader)
{
qDebug() << "You must Open() the file before reading it!";
return errors;
}
while (!mXmlReader->atEnd())
{
switch (mXmlReader->readNext())
{
case QXmlStreamReader::StartElement:
if (mXmlReader->name() == ResultElementName)
insideResults = true;
// Read error element from inside result element
if (insideResults && mXmlReader->name() == ErrorElementName)
{
ErrorItem item = ReadError(mXmlReader);
errors.append(item);
}
break;
case QXmlStreamReader::EndElement:
if (mXmlReader->name() == ResultElementName)
insideResults = false;
break;
// Not handled
case QXmlStreamReader::NoToken:
case QXmlStreamReader::Invalid:
case QXmlStreamReader::StartDocument:
case QXmlStreamReader::EndDocument:
case QXmlStreamReader::Characters:
case QXmlStreamReader::Comment:
case QXmlStreamReader::DTD:
case QXmlStreamReader::EntityReference:
case QXmlStreamReader::ProcessingInstruction:
break;
}
}
return errors;
}
ErrorItem XmlReportV2::ReadError(QXmlStreamReader *reader)
{
/*
Error example from the core program in xml
<error id="mismatchAllocDealloc" severity="error" msg="Mismatching allocation and deallocation: k"
verbose="Mismatching allocation and deallocation: k">
<location file="..\..\test\test.cxx" line="16"/>
<location file="..\..\test\test.cxx" line="32"/>
</error>
*/
ErrorItem item;
// Read error element from inside errors element
if (mXmlReader->name() == ErrorElementName)
{
QXmlStreamAttributes attribs = reader->attributes();
item.id = attribs.value("", IdAttribute).toString();
item.severity = attribs.value("", SeverityAttribute).toString();
const QString summary = attribs.value("", MsgAttribute).toString();
item.summary = XmlReport::unquoteMessage(summary);
const QString message = attribs.value("", VerboseAttribute).toString();
item.message = XmlReport::unquoteMessage(message);
}
bool errorRead = false;
while (!errorRead && !mXmlReader->atEnd())
{
switch (mXmlReader->readNext())
{
case QXmlStreamReader::StartElement:
// Read location element from inside error element
if (mXmlReader->name() == LocationElementName)
{
QXmlStreamAttributes attribs = mXmlReader->attributes();
QString file = attribs.value("", FilenameAttribute).toString();
file = XmlReport::unquoteMessage(file);
if (item.file.isEmpty())
item.file = file;
item.files.push_back(file);
const int line = attribs.value("", LineAttribute).toString().toUInt();
item.lines.push_back(line);
}
break;
case QXmlStreamReader::EndElement:
if (mXmlReader->name() == ErrorElementName)
errorRead = true;
break;
// Not handled
case QXmlStreamReader::NoToken:
case QXmlStreamReader::Invalid:
case QXmlStreamReader::StartDocument:
case QXmlStreamReader::EndDocument:
case QXmlStreamReader::Characters:
case QXmlStreamReader::Comment:
case QXmlStreamReader::DTD:
case QXmlStreamReader::EntityReference:
case QXmlStreamReader::ProcessingInstruction:
break;
}
}
return item;
}

96
gui/xmlreportv2.h Normal file
View File

@ -0,0 +1,96 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef XML_REPORTV2_H
#define XML_REPORTV2_H
#include <QObject>
#include <QString>
#include <QStringList>
#include <QFile>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include "report.h"
/// @addtogroup GUI
/// @{
/**
* @brief XML file report version 2.
* This report outputs XML-formatted report. The XML format must match command
* line version's XML output.
*/
class XmlReportV2 : public XmlReport
{
public:
XmlReportV2(const QString &filename, QObject * parent = 0);
virtual ~XmlReportV2();
/**
* @brief Create the report (file).
* @return true if succeeded, false if file could not be created.
*/
virtual bool Create();
/**
* @brief Open existing report file.
*/
bool Open();
/**
* @brief Write report header.
*/
virtual void WriteHeader();
/**
* @brief Write report footer.
*/
virtual void WriteFooter();
/**
* @brief Write error to report.
* @param error Error data.
*/
virtual void WriteError(const ErrorItem &error);
/**
* @brief Read contents of the report file.
*/
virtual QList<ErrorItem> Read();
protected:
/**
* @brief Read and parse error item from XML stream.
* @param reader XML stream reader to use.
*/
ErrorItem ReadError(QXmlStreamReader *reader);
private:
/**
* @brief XML stream reader for reading the report in XML format.
*/
QXmlStreamReader *mXmlReader;
/**
* @brief XML stream writer for writing the report in XML format.
*/
QXmlStreamWriter *mXmlWriter;
};
/// @}
#endif // XML_REPORTV2_H

View File

@ -134,178 +134,172 @@ void CheckAutoVariables::addVDA(unsigned int varId)
void CheckAutoVariables::autoVariables()
{
bool begin_function = false;
bool begin_function_decl = false;
int bindent = 0;
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
// Which variables have an unknown type?
std::set<unsigned int> unknown_type;
std::list<Scope *>::const_iterator i;
const SymbolDatabase * const symbolDatabase = _tokenizer->getSymbolDatabase();
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
{
const Scope *scope = *i;
if (Token::Match(tok, "%type% *|::| %var% ("))
{
begin_function = true;
fp_list.clear();
vd_list.clear();
vda_list.clear();
}
else if (begin_function && begin_function_decl && Token::Match(tok, "%type% * * %var%"))
{
fp_list.insert(tok->tokAt(3)->str());
}
else if (begin_function && begin_function_decl && Token::Match(tok, "%type% * %var% ["))
{
fp_list.insert(tok->tokAt(2)->str());
}
else if (begin_function && tok->str() == "(")
{
begin_function_decl = true;
}
else if (begin_function && tok->str() == ")")
{
begin_function_decl = false;
}
else if (begin_function && tok->str() == "{")
{
bindent++;
}
else if (begin_function && tok->str() == "}")
{
bindent--;
}
else if (bindent <= 0)
{
// only check functions
if (scope->type != Scope::eFunction)
continue;
}
// Inside a function body
if (Token::Match(tok, "%type% :: %any%") && !isExternOrStatic(tok))
fp_list.clear();
vd_list.clear();
vda_list.clear();
const Token *tok = scope->classDef->next();
for (; tok && tok != scope->classDef->next()->link(); tok = tok->next())
{
addVD(tok->tokAt(2)->varId());
}
else if (Token::Match(tok, "%type% %var% ["))
{
addVDA(tok->next()->varId());
}
else if (Token::Match(tok, "%var% %var% ;") && !isExternOrStatic(tok) && isTypeName(tok))
{
addVD(tok->next()->varId());
if (!tok->isStandardType() &&
!symbolDatabase->isClassOrStruct(tok->str()))
if (Token::Match(tok, "%type% * * %var%"))
{
unknown_type.insert(tok->next()->varId());
fp_list.insert(tok->tokAt(3)->str());
}
else if (Token::Match(tok, "%type% * %var% ["))
{
fp_list.insert(tok->tokAt(2)->str());
}
}
else if (Token::Match(tok, "const %var% %var% ;") && !isExternOrStatic(tok) && isTypeName(tok->next()))
unsigned int indentlevel = 0;
// Which variables have an unknown type?
std::set<unsigned int> unknown_type;
for (tok = scope->classDef->next()->link(); tok; tok = tok->next())
{
addVD(tok->tokAt(2)->varId());
// indentlevel..
if (tok->str() == "{")
++indentlevel;
else if (tok->str() == "}")
{
if (indentlevel <= 1)
break;
--indentlevel;
}
// Inside a function body
if (Token::Match(tok, "%type% :: %any%") && !isExternOrStatic(tok))
{
addVD(tok->tokAt(2)->varId());
}
else if (Token::Match(tok, "%type% %var% ["))
{
addVDA(tok->next()->varId());
}
else if (Token::Match(tok, "%var% %var% ;") && !isExternOrStatic(tok) && isTypeName(tok))
{
addVD(tok->next()->varId());
if (!tok->isStandardType() &&
!symbolDatabase->isClassOrStruct(tok->str()))
{
unknown_type.insert(tok->next()->varId());
}
}
else if (Token::Match(tok, "const %var% %var% ;") && !isExternOrStatic(tok) && isTypeName(tok->next()))
{
addVD(tok->tokAt(2)->varId());
}
//Critical assignment
else if (Token::Match(tok, "[;{}] %var% = & %var%") && errorAv(tok->tokAt(1), tok->tokAt(4)))
{
errorAutoVariableAssignment(tok);
}
else if (Token::Match(tok, "[;{}] * %var% = & %var%") && errorAv(tok->tokAt(2), tok->tokAt(5)) &&
unknown_type.find(tok->tokAt(5)->varId()) == unknown_type.end())
{
errorAutoVariableAssignment(tok);
}
else if (Token::Match(tok, "[;{}] %var% [ %any% ] = & %var%") && errorAv(tok->tokAt(1), tok->tokAt(7)))
{
errorAutoVariableAssignment(tok);
}
// Critical return
else if (Token::Match(tok, "return & %var% ;") && isAutoVar(tok->tokAt(2)->varId()))
{
reportError(tok, Severity::error, "autoVariables", "Return of the address of an auto-variable");
}
// Invalid pointer deallocation
else if (Token::Match(tok, "free ( %var% ) ;") && isAutoVarArray(tok->tokAt(2)->varId()))
{
reportError(tok, Severity::error, "autoVariables", "Invalid deallocation");
}
}
//Critical assignment
else if (Token::Match(tok, "[;{}] %var% = & %var%") && errorAv(tok->tokAt(1), tok->tokAt(4)))
{
errorAutoVariableAssignment(tok);
}
else if (Token::Match(tok, "[;{}] * %var% = & %var%") && errorAv(tok->tokAt(2), tok->tokAt(5)) &&
unknown_type.find(tok->tokAt(5)->varId()) == unknown_type.end())
{
errorAutoVariableAssignment(tok);
}
else if (Token::Match(tok, "[;{}] %var% [ %any% ] = & %var%") && errorAv(tok->tokAt(1), tok->tokAt(7)))
{
errorAutoVariableAssignment(tok);
}
// Critical return
else if (Token::Match(tok, "return & %var% ;") && isAutoVar(tok->tokAt(2)->varId()))
{
reportError(tok, Severity::error, "autoVariables", "Return of the address of an auto-variable");
}
// Invalid pointer deallocation
else if (Token::Match(tok, "free ( %var% ) ;") && isAutoVarArray(tok->tokAt(2)->varId()))
{
reportError(tok, Severity::error, "autoVariables", "Invalid deallocation");
}
vd_list.clear();
vda_list.clear();
fp_list.clear();
}
vd_list.clear();
vda_list.clear();
fp_list.clear();
}
//---------------------------------------------------------------------------
void CheckAutoVariables::returnPointerToLocalArray()
{
bool infunc = false;
int indentlevel = 0;
std::set<unsigned int> arrayVar;
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
std::list<Scope *>::const_iterator i;
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
{
// Is there a function declaration for a function that returns a pointer?
if (!infunc && (Token::Match(tok, "%type% * %var% (") || Token::Match(tok, "%type% * %var% :: %var% (")))
const Scope *scope = *i;
// only check functions
if (scope->type != Scope::eFunction)
continue;
const Token *tok = scope->classDef;
// skip any qualification
while (Token::Match(tok->tokAt(-2), "%type% ::"))
tok = tok->tokAt(-2);
// have we reached a function that returns a pointer
if (Token::Match(tok->tokAt(-2), "%type% *"))
{
for (const Token *tok2 = tok; tok2; tok2 = tok2->next())
{
if (tok2->str() == ")")
{
tok = tok2;
break;
}
}
if (Token::simpleMatch(tok, ") {"))
{
infunc = true;
indentlevel = 0;
arrayVar.clear();
}
}
// go to the '('
const Token *tok2 = scope->classDef->next();
// Parsing a function that returns a pointer..
if (infunc)
{
if (tok->str() == "{")
{
++indentlevel;
}
else if (tok->str() == "}")
{
--indentlevel;
if (indentlevel <= 0)
{
infunc = false;
}
continue;
}
// go to the ')'
tok2 = tok2->next()->link();
// Declaring a local array..
if (Token::Match(tok, "[;{}] %type% %var% ["))
unsigned int indentlevel = 0;
std::set<unsigned int> arrayVar;
for (; tok2; tok2 = tok2->next())
{
const unsigned int varid = tok->tokAt(2)->varId();
if (varid > 0)
// indentlevel..
if (tok2->str() == "{")
++indentlevel;
else if (tok2->str() == "}")
{
arrayVar.insert(varid);
if (indentlevel <= 1)
break;
--indentlevel;
}
}
// Return pointer to local array variable..
if (Token::Match(tok, "return %var% ;"))
{
const unsigned int varid = tok->next()->varId();
if (varid > 0 && arrayVar.find(varid) != arrayVar.end())
// Declaring a local array..
if (Token::Match(tok2, "[;{}] %type% %var% ["))
{
errorReturnPointerToLocalArray(tok);
const unsigned int varid = tok2->tokAt(2)->varId();
if (varid > 0)
{
arrayVar.insert(varid);
}
}
// Return pointer to local array variable..
if (Token::Match(tok2, "return %var% ;"))
{
const unsigned int varid = tok2->next()->varId();
if (varid > 0 && arrayVar.find(varid) != arrayVar.end())
{
errorReturnPointerToLocalArray(tok2);
}
}
}
}
// Declaring array variable..
}
}
@ -324,6 +318,8 @@ void CheckAutoVariables::errorAutoVariableAssignment(const Token *tok)
"is invalid after the function ends.");
}
//---------------------------------------------------------------------------
// return temporary?
bool CheckAutoVariables::returnTemporary(const Token *tok) const
{
@ -332,89 +328,91 @@ bool CheckAutoVariables::returnTemporary(const Token *tok) const
return bool(0 != Token::findmatch(_tokenizer->tokens(), ("std :: string " + tok->next()->str() + " (").c_str()));
}
//---------------------------------------------------------------------------
void CheckAutoVariables::returnReference()
{
// locate function that returns a reference..
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
std::list<Scope *>::const_iterator i;
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
{
// Skip executable scopes..
if (Token::Match(tok, ") const| {"))
{
tok = tok->next();
if (tok->str() == "const")
tok = tok->next();
tok = tok->link();
const Scope *scope = *i;
// only check functions
if (scope->type != Scope::eFunction)
continue;
}
const Token *tok = scope->classDef;
// skip any qualification
while (Token::Match(tok->tokAt(-2), "%type% ::"))
tok = tok->tokAt(-2);
// have we reached a function that returns a reference?
if (Token::Match(tok, "%type% & %var% (") ||
Token::Match(tok, "> & %var% ("))
if (Token::Match(tok->tokAt(-2), "%type% &") ||
Token::Match(tok->tokAt(-2), "> &"))
{
// go to the '('
const Token *tok2 = tok->tokAt(3);
const Token *tok2 = scope->classDef->next();
// go to the ')'
tok2 = tok2->link();
// is this a function implementation?
if (Token::Match(tok2, ") const| {"))
unsigned int indentlevel = 0;
std::set<unsigned int> localvar; // local variables in function
for (; tok2; tok2 = tok2->next())
{
unsigned int indentlevel = 0;
std::set<unsigned int> localvar; // local variables in function
while (0 != (tok2 = tok2->next()))
// indentlevel..
if (tok2->str() == "{")
++indentlevel;
else if (tok2->str() == "}")
{
// indentlevel..
if (tok2->str() == "{")
++indentlevel;
else if (tok2->str() == "}")
{
if (indentlevel <= 1)
break;
--indentlevel;
}
if (indentlevel <= 1)
break;
--indentlevel;
}
// declare local variable..
if (Token::Match(tok2, "[{};] %type%") && tok2->next()->str() != "return")
{
// goto next token..
// declare local variable..
if (Token::Match(tok2, "[{};] %type%") && tok2->next()->str() != "return")
{
// goto next token..
tok2 = tok2->next();
// skip "const"
if (Token::Match(tok2, "const %type%"))
tok2 = tok2->next();
// skip "const"
if (Token::Match(tok2, "const %type%"))
tok2 = tok2->next();
// skip "std::" if it is seen
if (Token::simpleMatch(tok2, "std ::"))
tok2 = tok2->tokAt(2);
// skip "std::" if it is seen
if (Token::simpleMatch(tok2, "std ::"))
tok2 = tok2->tokAt(2);
// is it a variable declaration?
if (Token::Match(tok2, "%type% %var% ;"))
localvar.insert(tok2->next()->varId());
else if (Token::Match(tok2, "%type% < %any% > %var% ;"))
localvar.insert(tok2->tokAt(4)->varId());
}
// is it a variable declaration?
if (Token::Match(tok2, "%type% %var% ;"))
localvar.insert(tok2->next()->varId());
else if (Token::Match(tok2, "%type% < %any% > %var% ;"))
localvar.insert(tok2->tokAt(4)->varId());
}
// return..
else if (Token::Match(tok2, "return %var% ;"))
{
// is the returned variable a local variable?
if ((tok2->next()->varId() > 0) &&
(localvar.find(tok2->next()->varId()) != localvar.end()))
{
// report error..
errorReturnReference(tok2);
}
}
// return reference to temporary..
else if (returnTemporary(tok2))
// return..
else if (Token::Match(tok2, "return %var% ;"))
{
// is the returned variable a local variable?
if ((tok2->next()->varId() > 0) &&
(localvar.find(tok2->next()->varId()) != localvar.end()))
{
// report error..
errorReturnTempReference(tok2);
errorReturnReference(tok2);
}
}
// return reference to temporary..
else if (returnTemporary(tok2))
{
// report error..
errorReturnTempReference(tok2);
}
}
}
}
@ -430,91 +428,90 @@ void CheckAutoVariables::errorReturnTempReference(const Token *tok)
reportError(tok, Severity::error, "returnTempReference", "Returning reference to temporary");
}
//---------------------------------------------------------------------------
// Return c_str
void CheckAutoVariables::returncstr()
{
// locate function that returns a const char *..
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
{
// Skip executable scopes..
if (Token::Match(tok, ") const| {"))
{
tok = tok->next();
if (tok->str() == "const")
tok = tok->next();
tok = tok->link();
continue;
}
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
// have we reached a function that returns a reference?
if (Token::simpleMatch(tok, "const char *"))
std::list<Scope *>::const_iterator i;
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
{
const Scope *scope = *i;
// only check functions
if (scope->type != Scope::eFunction)
continue;
const Token *tok = scope->classDef;
// skip any qualification
while (Token::Match(tok->tokAt(-2), "%type% ::"))
tok = tok->tokAt(-2);
// have we reached a function that returns a const char *
if (Token::simpleMatch(tok->tokAt(-3), "const char *"))
{
// go to the '('
const Token *tok2 = tok->tokAt(3);
while (Token::Match(tok2, "%var% ::"))
tok2 = tok2->tokAt(2);
if (!Token::Match(tok2, "%var% ("))
continue;
const Token *tok2 = scope->classDef->next();
// go to the ')'
tok2 = tok2->next()->link();
// is this a function implementation?
if (Token::Match(tok2, ") const| {"))
unsigned int indentlevel = 0;
std::set<unsigned int> localvar; // local variables in function
for (; tok2; tok2 = tok2->next())
{
unsigned int indentlevel = 0;
std::set<unsigned int> localvar; // local variables in function
while (0 != (tok2 = tok2->next()))
// indentlevel..
if (tok2->str() == "{")
++indentlevel;
else if (tok2->str() == "}")
{
// indentlevel..
if (tok2->str() == "{")
++indentlevel;
else if (tok2->str() == "}")
{
if (indentlevel <= 1)
break;
--indentlevel;
}
if (indentlevel <= 1)
break;
--indentlevel;
}
// declare local variable..
if (Token::Match(tok2, "[{};] %type%") && tok2->next()->str() != "return")
{
// goto next token..
// declare local variable..
if (Token::Match(tok2, "[{};] %type%") && tok2->next()->str() != "return")
{
// goto next token..
tok2 = tok2->next();
// skip "const"
if (Token::Match(tok2, "const %type%"))
tok2 = tok2->next();
// skip "const"
if (Token::Match(tok2, "const %type%"))
tok2 = tok2->next();
// skip "std::" if it is seen
if (Token::simpleMatch(tok2, "std ::"))
tok2 = tok2->tokAt(2);
// skip "std::" if it is seen
if (Token::simpleMatch(tok2, "std ::"))
tok2 = tok2->tokAt(2);
// is it a variable declaration?
if (Token::Match(tok2, "%type% %var% [;=]"))
localvar.insert(tok2->next()->varId());
}
// is it a variable declaration?
if (Token::Match(tok2, "%type% %var% [;=]"))
localvar.insert(tok2->next()->varId());
}
// return..
else if (Token::Match(tok2, "return %var% . c_str ( ) ;"))
{
// is the returned variable a local variable?
if ((tok2->next()->varId() > 0) &&
(localvar.find(tok2->next()->varId()) != localvar.end()))
{
// report error..
errorReturnAutocstr(tok2);
}
}
// return pointer to temporary..
else if (returnTemporary(tok2))
// return..
else if (Token::Match(tok2, "return %var% . c_str ( ) ;"))
{
// is the returned variable a local variable?
if ((tok2->next()->varId() > 0) &&
(localvar.find(tok2->next()->varId()) != localvar.end()))
{
// report error..
errorReturnTempPointer(tok2);
errorReturnAutocstr(tok2);
}
}
// return pointer to temporary..
else if (returnTemporary(tok2))
{
// report error..
errorReturnTempPointer(tok2);
}
}
}
}
@ -529,6 +526,3 @@ void CheckAutoVariables::errorReturnTempPointer(const Token *tok)
{
reportError(tok, Severity::error, "returnTempPointer", "Returning pointer to temporary");
}

View File

@ -167,4 +167,32 @@ void CheckExceptionSafety::deallocThrow()
}
}
//---------------------------------------------------------------------------
// catch(const exception & err)
// {
// throw err; // <- should be just "throw;"
// }
//---------------------------------------------------------------------------
void CheckExceptionSafety::checkRethrowCopy()
{
if (!_settings->_checkCodingStyle)
return;
const char catchPattern[] = "catch ( const| %type% &|*| %var% ) { %any%";
const Token *tok = Token::findmatch(_tokenizer->tokens(), catchPattern);
while (tok)
{
const Token *startBlockTok = tok->next()->link()->next();
const Token *endBlockTok = startBlockTok->link();
const unsigned int varid = startBlockTok->tokAt(-2)->varId();
const Token* rethrowTok = Token::findmatch(startBlockTok, "throw %varid%", endBlockTok, varid);
if (rethrowTok)
{
rethrowCopyError(rethrowTok, startBlockTok->tokAt(-2)->str());
}
tok = Token::findmatch(endBlockTok->next(), catchPattern);
}
}

View File

@ -57,6 +57,7 @@ public:
CheckExceptionSafety checkExceptionSafety(tokenizer, settings, errorLogger);
checkExceptionSafety.destructors();
checkExceptionSafety.deallocThrow();
checkExceptionSafety.checkRethrowCopy();
}
/** Don't throw exceptions in destructors */
@ -65,6 +66,9 @@ public:
/** deallocating memory and then throw (dead pointer) */
void deallocThrow();
/** Don't rethrow a copy of the caught exception; use a bare throw instead */
void checkRethrowCopy();
private:
/** Don't throw exceptions in destructors */
void destructorsError(const Token * const tok)
@ -77,12 +81,21 @@ private:
reportError(tok, Severity::error, "exceptDeallocThrow", "Throwing exception in invalid state, " + varname + " points at deallocated memory");
}
void rethrowCopyError(const Token * const tok, const std::string &varname)
{
reportError(tok, Severity::style, "exceptRethrowCopy",
"Throwing a copy of the caught exception instead of rethrowing the original exception\n"
"Rethrowing an exception with 'throw " + varname + ";' makes an unnecessary copy of '" + varname + "'.\n"
"To rethrow the caught exception without unnecessary copying or slicing, use a bare 'throw;'.");
}
/** Generate all possible errors (for --errorlist) */
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings)
{
CheckExceptionSafety c(0, settings, errorLogger);
c.destructorsError(0);
c.deallocThrowError(0, "p");
c.rethrowCopyError(0, "varname");
}
/** Short description of class (for --doc) */
@ -96,7 +109,8 @@ private:
{
return "Checking exception safety\n"
"* Throwing exceptions in destructors\n"
"* Throwing exception during invalid state";
"* Throwing exception during invalid state\n"
"* Throwing a copy of a caught exception instead of rethrowing the original exception";
}
};
/// @}

View File

@ -1250,7 +1250,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
if ((tok->str() == "else") || (tok->str() == "switch"))
{
addtoken(&rettail, tok, tok->str());
if (tok->str() == "switch")
if (Token::simpleMatch(tok, "switch ("))
tok = tok->next()->link();
continue;
}

View File

@ -2718,6 +2718,40 @@ void CheckOther::checkMisusedScopedObject()
}
}
void CheckOther::checkIncorrectStringCompare()
{
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
{
if (Token::Match(tok, ". substr ( %any% , %num% ) ==|!= %str%"))
{
size_t clen = MathLib::toLongNumber(tok->tokAt(5)->str());
size_t slen = Token::getStrLength(tok->tokAt(8));
if (clen != slen)
{
incorrectStringCompareError(tok->next(), "substr", tok->tokAt(8)->str(), tok->tokAt(5)->str());
}
}
if (Token::Match(tok, "%str% ==|!= %var% . substr ( %any% , %num% )"))
{
size_t clen = MathLib::toLongNumber(tok->tokAt(8)->str());
size_t slen = Token::getStrLength(tok);
if (clen != slen)
{
incorrectStringCompareError(tok->next(), "substr", tok->str(), tok->tokAt(8)->str());
}
}
if (Token::Match(tok, "strncmp ( %any% , %str% , %num% )"))
{
size_t clen = MathLib::toLongNumber(tok->tokAt(6)->str());
size_t slen = Token::getStrLength(tok->tokAt(4));
if (clen != slen)
{
incorrectStringCompareError(tok, "strncmp", tok->tokAt(4)->str(), tok->tokAt(6)->str());
}
}
}
}
void CheckOther::cstyleCastError(const Token *tok)
{
reportError(tok, Severity::style, "cstyleCast", "C-style pointer casting");
@ -2935,3 +2969,8 @@ void CheckOther::memsetZeroBytesError(const Token *tok, const std::string &varna
const std::string verbose(summary + ". Second and third arguments might be inverted.");
reportError(tok, Severity::warning, "memsetZeroBytes", summary + "\n" + verbose);
}
void CheckOther::incorrectStringCompareError(const Token *tok, const std::string& func, const std::string &string, const std::string &len)
{
reportError(tok, Severity::warning, "incorrectStringCompare", "String literal " + string + " doesn't match length argument for " + func + "(" + len + ").");
}

View File

@ -87,6 +87,7 @@ public:
checkOther.checkMisusedScopedObject();
checkOther.checkCatchExceptionByValue();
checkOther.checkMemsetZeroBytes();
checkOther.checkIncorrectStringCompare();
}
/** @brief Clarify calculation for ".. a * b ? .." */
@ -180,6 +181,9 @@ public:
/** @brief %Check for using sizeof with array given as function argument */
void checkSizeofForArrayParameter();
/** @brief %Check for using bad usage of strncmp and substr */
void checkIncorrectStringCompare();
// Error messages..
void cstyleCastError(const Token *tok);
void dangerousUsageStrtolError(const Token *tok);
@ -204,6 +208,7 @@ public:
void catchExceptionByValueError(const Token *tok);
void memsetZeroBytesError(const Token *tok, const std::string &varname);
void sizeofForArrayParameterError(const Token *tok);
void incorrectStringCompareError(const Token *tok, const std::string& func, const std::string &string, const std::string &len);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings)
{
@ -243,6 +248,7 @@ public:
c.catchExceptionByValueError(0);
c.memsetZeroBytesError(0, "varname");
c.clarifyCalculationError(0);
c.incorrectStringCompareError(0, "substr", "\"Hello World\"", "12");
}
std::string myName() const
@ -261,6 +267,7 @@ public:
"* scoped object destroyed immediately after construction\n"
"* assignment in an assert statement\n"
"* sizeof for array given as function argument\n"
"* incorrect length arguments for 'substr' and 'strncmp'\n"
// style
"* C-style pointer cast in cpp file\n"

View File

@ -73,7 +73,7 @@ void CppCheck::clearFiles()
const char * CppCheck::version()
{
return "1.46";
return "1.47";
}
unsigned int CppCheck::check()

View File

@ -908,6 +908,8 @@ std::list<std::string> Preprocessor::getcfgs(const std::string &filedata, const
def += ";";
def += *it;
}
/* TODO: Fix TestPreprocessor::test7e (#2552)
else
{
std::ostringstream lineStream;
@ -918,11 +920,12 @@ std::list<std::string> Preprocessor::getcfgs(const std::string &filedata, const
loc.setfile(filename);
loc.line = linenr;
errmsg._callStack.push_back(loc);
errmsg._severity = Severity::fromString("error");
errmsg._severity = Severity::error;
errmsg.setmsg(*it+" is already guaranteed to be defined");
errmsg._id = "preprocessor" + lineStream.str();
_errorLogger->reportErr(errmsg);
}
*/
}
if (from_negation)
{

View File

@ -213,7 +213,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
function.isConst = true;
// pure virtual function
if (Token::Match(end, ") const| = 0 ;"))
if (Token::Match(end, ") const| = %any% ;"))
function.isPure = true;
// count the number of constructors
@ -227,7 +227,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
// out of line function
if (Token::Match(end, ") const| ;") ||
Token::Match(end, ") const| = 0 ;"))
Token::Match(end, ") const| = %any% ;"))
{
// find the function implementation later
tok = end->next();

View File

@ -2071,7 +2071,8 @@ bool Tokenizer::tokenize(std::istream &code,
// Replace NULL with 0..
for (Token *tok = _tokens; tok; tok = tok->next())
{
if (tok->str() == "NULL" || tok->str() == "'\\0'" || tok->str() == "'\\x0'")
if (tok->str() == "NULL" || tok->str() == "__null" ||
tok->str() == "'\\0'" || tok->str() == "'\\x0'")
{
tok->str("0");
}
@ -3807,6 +3808,8 @@ void Tokenizer::simplifySizeof()
{
if (Token::Match(tok, "class|struct %var%"))
{
// we assume that the size of structs and classes are always
// 100 bytes.
_typeSize[tok->strAt(1)] = 100;
}
}

View File

@ -102,28 +102,30 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
<refsynopsisdiv>
<cmdsynopsis>
<command>&dhpackage;</command>
<arg choice="opt"><option>--append=[file]</option></arg>
<arg choice="opt"><option>-D[id]</option></arg>
<arg choice="opt"><option>--enable=[id]</option></arg>
<arg choice="opt"><option>--error-exitcode=[n]</option></arg>
<arg choice="opt"><option>--append=&lt;file&gt;</option></arg>
<arg choice="opt"><option>-D&lt;id&gt;</option></arg>
<arg choice="opt"><option>--enable=&lt;id&gt;</option></arg>
<arg choice="opt"><option>--error-exitcode=&lt;n&gt;</option></arg>
<arg choice="opt"><option>--errorlist</option></arg>
<arg choice="opt"><option>--exitcode-suppressions=[file]</option></arg>
<arg choice="opt"><option>--file-list=file</option></arg>
<arg choice="opt"><option>--exitcode-suppressions=&lt;file&gt;</option></arg>
<arg choice="opt"><option>--file-list=&lt;file&gt;</option></arg>
<arg choice="opt"><option>--force</option></arg>
<arg choice="opt"><option>--help</option></arg>
<arg choice="opt"><option>-I[dir]</option></arg>
<arg choice="opt"><option>-i[dir]</option></arg>
<arg choice="opt"><option>-I&lt;dir&gt;</option></arg>
<arg choice="opt"><option>-i&lt;dir&gt;</option></arg>
<arg choice="opt"><option>--inline-suppr</option></arg>
<arg choice="opt"><option>-j[jobs]</option></arg>
<arg choice="opt"><option>-j&lt;jobs&gt;</option></arg>
<arg choice="opt"><option>--quiet</option></arg>
<arg choice="opt"><option>--report-progress</option></arg>
<arg choice="opt"><option>--rule=&lt;rule&gt;</option></arg>
<arg choice="opt"><option>--rule-file=&lt;file&gt;</option></arg>
<arg choice="opt"><option>--style</option></arg>
<arg choice="opt"><option>--suppressions-list=[file]</option></arg>
<arg choice="opt"><option>--template '[text]'</option></arg>
<arg choice="opt"><option>--suppressions-list=&lt;file&gt;</option></arg>
<arg choice="opt"><option>--template '&lt;text&gt;'</option></arg>
<arg choice="opt"><option>--verbose</option></arg>
<arg choice="opt"><option>--version</option></arg>
<arg choice="opt"><option>--xml</option></arg>
<arg choice="opt"><option>--xml-version=[version]</option></arg>
<arg choice="opt"><option>--xml-version=&lt;version&gt;]</option></arg>
<arg choice="opt"><option>file or path</option></arg>
<arg choice="plain"><option>...</option></arg>
</cmdsynopsis>
@ -146,20 +148,20 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
variablelist.term.break.after parameters to
control the term elements. -->
<varlistentry>
<term><option>--append=[file]</option></term>
<term><option>--append=&lt;file&gt;</option></term>
<listitem>
<para>This allows you to provide information about functions by providing an implementation for these.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-D[id]</option></term>
<term><option>-D&lt;id&gt;</option></term>
<listitem>
<para>By default Cppcheck checks all configurations. Use -D to limit the checking. When -D is used the checking is limited to the given configuration.
Example: -DDEBUG=1 -D__cplusplus</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--enable=[id]</option></term>
<term><option>--enable=&lt;id&gt;</option></term>
<listitem>
<para>Enable additional checks. The available ids are:
<glosslist>
@ -199,9 +201,9 @@ Example: -DDEBUG=1 -D__cplusplus</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--error-exitcode=[n]</option></term>
<term><option>--error-exitcode=&lt;n&gt;</option></term>
<listitem>
<para>If errors are found, integer [n] is returned instead of default 0.
<para>If errors are found, integer &lt;n&gt; is returned instead of default 0.
EXIT_FAILURE is returned if arguments are not valid or if no input files are
provided. Note that your operating system can modify this value, e.g.
256 can become 0.</para>
@ -214,13 +216,13 @@ Example: -DDEBUG=1 -D__cplusplus</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--exitcode-suppressions=[file]</option></term>
<term><option>--exitcode-suppressions=&lt;file&gt;</option></term>
<listitem>
<para>Used when certain messages should be displayed but should not cause a non-zero exitcode.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--file-list=[file]</option></term>
<term><option>--file-list=&lt;file&gt;</option></term>
<listitem>
<para>Specify the files to check in a text file. One filename per line.</para>
</listitem>
@ -241,7 +243,7 @@ default.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-I [dir]</option></term>
<term><option>-I &lt;dir&gt;</option></term>
<listitem>
<para>Give include path. Give several -I parameters to give several paths. First given path is checked first. If paths are relative to source
files, this is not needed.</para>
@ -249,7 +251,7 @@ files, this is not needed.</para>
</varlistentry>
<varlistentry>
<term><option>-i [dir]</option></term>
<term><option>-i &lt;dir&gt;</option></term>
<listitem>
<para>Give path to ignore. Give several -i parameters to ignore several paths. Give directory name or filename with path as parameter.
Directory name is matched to all parts of the path.</para>
@ -264,9 +266,9 @@ Directory name is matched to all parts of the path.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-j [jobs]</option></term>
<term><option>-j &lt;jobs&gt;</option></term>
<listitem>
<para>Start [jobs] threads to do the checking work.</para>
<para>Start &lt;jobs&gt; threads to do the checking work.</para>
</listitem>
</varlistentry>
<varlistentry>
@ -282,6 +284,18 @@ Directory name is matched to all parts of the path.</para>
<para>Report progress when checking a file.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--rule=&lt;rule&gt;</option></term>
<listitem>
<para>Match regular expression to create your own checks. E.g. rule &quot;/ 0&quot; can be used to check division by zero.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--rule-file=&lt;file&gt;</option></term>
<listitem>
<para>Use given rule XML file. See https://sourceforge.net/projects/cppcheck/files/Articles/ for more info about the syntax.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-s</option></term>
<term><option>--style</option></term>
@ -290,14 +304,14 @@ Directory name is matched to all parts of the path.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--suppressions-list=[file]</option></term>
<term><option>--suppressions-list=&lt;file&gt;</option></term>
<listitem>
<para>Suppress warnings listed in the file. Filename and line are optional. The format of the single line in file is: [error id]:[filename]:[line].
You can use --template or --xml to see the error id.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--template '[text]'</option></term>
<term><option>--template '&lt;text&gt;'</option></term>
<listitem>
<para>Format the error messages. E.g. '{file}:{line},{severity},{id},{message}' or '{file}({line}):({severity}) {message}'. Pre-defined templates: gcc, vs</para>
</listitem>
@ -322,7 +336,7 @@ Directory name is matched to all parts of the path.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--xml-version=[version]</option></term>
<term><option>--xml-version=&lt;version&gt;</option></term>
<listitem>
<para>Select the XML file version. Currently versions 1 and 2 are available. The default version is 1.</para>
</listitem>

View File

@ -3,9 +3,9 @@
"/usr/share/xml/docbook/schema/dtd/4.4/docbookx.dtd">
<book>
<bookinfo>
<title>Cppcheck 1.46</title>
<title>Cppcheck 1.47</title>
<date>2010-12-09</date>
<date>2011-02-06</date>
</bookinfo>
<chapter>
@ -94,19 +94,20 @@ Checking path/file2.cpp...
<section>
<title>Excluding a file or folder from checking</title>
<para>There is no command to exclude a file or folder from checking. But
you can exclude a file or folder by being more careful when including
files and folders in the checking.</para>
<para>To exclude a file or folder, there are two options.</para>
<para>Imagine for example that the folder "src" contain the folders "a",
"b" and "c". To exclude "c" this command can be used:</para>
<para>The first option is to only provide the paths and files you want
to check.</para>
<programlisting>cppcheck src/a src/b</programlisting>
<para>All files under "src/a" and "src/b" are then checked.</para>
<para>The flag <literal>--file-list</literal> might also be
useful.</para>
<para>The second option is to use <literal>-i</literal>, with it you
specify files/paths to ignore. With this command no files in "src/c" are
checked:</para>
<programlisting>cppcheck -isrc/c src</programlisting>
</section>
<section>
@ -148,6 +149,15 @@ Checking path/file2.cpp...
<para>suggestions for making the code faster</para>
</listitem>
</varlistentry>
<varlistentry>
<term>information</term>
<listitem>
<para>Informational messages that might be interesting. Ignore
these messages unless you really agree.</para>
</listitem>
</varlistentry>
</variablelist>
<remark>The performance messages are based on 'common knowledge'. It is

View File

@ -16,10 +16,13 @@ Compiling
Any C++ compiler should work.
To build the GUI, you need Qt. The command line tool doesn't have any dependencies.
To build the GUI, you need Qt.
To build the command line tool, PCRE is needed. More information about PCRE is found in
build.txt
There are multiple compilation choices:
* qmake - cross platform build tool - but only the GUI can be built
* qmake - cross platform build tool
* Visual Studio - Windows
* gnu make
* g++

35
scripts/tabs.pl Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/perl
# warn if there are tabs in string constants, it can have surprising effects.
# example usage:
# scripts/tabs.pl lib/checkstl.cpp
sub checkfile
{
my $filename = $_[0];
# parse file
open(FILE, $filename);
my @lines = <FILE>;
close(FILE);
# check comments..
my $linenr = 0;
foreach $line (@lines)
{
$linenr = $linenr + 1;
# is there a tab in a string
if ($line =~ /".*\t.*"/)
{
print "[$filename:$linenr] tab inside string constant\n";
}
}
}
foreach $filename (@ARGV)
{
checkfile($filename)
}

View File

@ -65,9 +65,12 @@ private:
void run()
{
TEST_CASE(testautovar);
TEST_CASE(testautovar_array);
TEST_CASE(testautovar_return);
TEST_CASE(testautovar1);
TEST_CASE(testautovar2);
TEST_CASE(testautovar_array1);
TEST_CASE(testautovar_array2);
TEST_CASE(testautovar_return1);
TEST_CASE(testautovar_return2);
TEST_CASE(testautovar_extern);
TEST_CASE(testinvaliddealloc);
TEST_CASE(testassign); // Ticket #1819
@ -76,15 +79,17 @@ private:
TEST_CASE(returnLocalVariable2);
// return reference..
TEST_CASE(returnReference);
TEST_CASE(returnReference1);
TEST_CASE(returnReference2);
// return c_str()..
TEST_CASE(returncstr);
TEST_CASE(returncstr1);
TEST_CASE(returncstr2);
}
void testautovar()
void testautovar1()
{
check("void func1(int **res)\n"
"{\n"
@ -101,7 +106,30 @@ private:
ASSERT_EQUALS("", errout.str());
}
void testautovar_array()
void testautovar2()
{
check("class Fred {\n"
" void func1(int **res);\n"
"}\n"
"void Fred::func1(int **res)\n"
"{\n"
" int num = 2;\n"
" *res = &num;\n"
"}");
ASSERT_EQUALS("[test.cpp:6]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str());
check("class Fred {\n"
" void func1(int **res);\n"
"}\n"
"void Fred::func1(int **res)\n"
"{\n"
" int num = 2;\n"
" foo.res = &num;\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void testautovar_array1()
{
check("void func1(int* arr[2])\n"
"{\n"
@ -111,15 +139,42 @@ private:
ASSERT_EQUALS("[test.cpp:3]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str());
}
void testautovar_return()
void testautovar_array2()
{
check("class Fred {\n"
" void func1(int* arr[2]);\n"
"}\n"
"void Fred::func1(int* arr[2])\n"
"{\n"
" int num=2;"
" arr[0]=&num;\n"
"}");
ASSERT_EQUALS("[test.cpp:6]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str());
}
void testautovar_return1()
{
check("int* func1()\n"
"{\n"
" int num=2;"
"return &num;}");
" return &num;"
"}");
ASSERT_EQUALS("[test.cpp:3]: (error) Return of the address of an auto-variable\n", errout.str());
}
void testautovar_return2()
{
check("class Fred {\n"
" int* func1()\n"
"}\n"
"int* Fred::func1()\n"
"{\n"
" int num=2;"
" return &num;"
"}");
ASSERT_EQUALS("[test.cpp:6]: (error) Return of the address of an auto-variable\n", errout.str());
}
void testautovar_extern()
{
check("struct foo *f()\n"
@ -169,6 +224,16 @@ private:
" return str;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Returning pointer to local array variable\n", errout.str());
check("class Fred {\n"
" char *foo();\n"
"};\n"
"char *Fred::foo()\n"
"{\n"
" char str[100] = {0};\n"
" return str;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:7]: (error) Returning pointer to local array variable\n", errout.str());
}
void returnLocalVariable2()
@ -179,9 +244,19 @@ private:
" return str;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("class Fred {\n"
" std::string foo();\n"
"};\n"
"std::string Fred::foo()\n"
"{\n"
" char str[100] = {0};\n"
" return str;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void returnReference()
void returnReference1()
{
check("std::string &foo()\n"
"{\n"
@ -216,7 +291,67 @@ private:
ASSERT_EQUALS("[test.cpp:8]: (error) Returning reference to temporary\n", errout.str());
}
void returncstr()
void returnReference2()
{
check("class Fred {\n"
" std::string &foo();\n"
"}\n"
"std::string &Fred::foo()\n"
"{\n"
" std::string s;\n"
" return s;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:7]: (error) Returning reference to auto variable\n", errout.str());
check("class Fred {\n"
" std::vector<int> &foo();\n"
"};\n"
"std::vector<int> &Fred::foo()\n"
"{\n"
" std::vector<int> v;\n"
" return v;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:7]: (error) Returning reference to auto variable\n", errout.str());
check("class Fred {\n"
" std::vector<int> &foo();\n"
"};\n"
"std::vector<int> &Fred::foo()\n"
"{\n"
" static std::vector<int> v;\n"
" return v;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("class Fred {\n"
" std::string &f();\n"
"};\n"
"std::string hello()\n"
"{\n"
" return \"hello\";\n"
"}\n"
"std::string &Fred::f()\n"
"{\n"
" return hello();\n"
"}\n");
ASSERT_EQUALS("[test.cpp:10]: (error) Returning reference to temporary\n", errout.str());
check("class Fred {\n"
" std::string hello();\n"
" std::string &f();\n"
"};\n"
"std::string Fred::hello()\n"
"{\n"
" return \"hello\";\n"
"}\n"
"std::string &Fred::f()\n"
"{\n"
" return hello();\n"
"}\n");
ASSERT_EQUALS("[test.cpp:11]: (error) Returning reference to temporary\n", errout.str());
}
void returncstr1()
{
check("const char *foo()\n"
"{\n"
@ -244,6 +379,43 @@ private:
ASSERT_EQUALS("[test.cpp:8]: (error) Returning pointer to temporary\n", errout.str());
}
void returncstr2()
{
check("class Fred {\n"
" const char *foo();\n"
"};\n"
"const char *Fred::foo()\n"
"{\n"
" std::string s;\n"
" return s.c_str();\n"
"}\n");
ASSERT_EQUALS("[test.cpp:7]: (error) Returning pointer to auto variable\n", errout.str());
check("class Fred {\n"
" const char *foo();\n"
"};\n"
"const char *Foo::f()\n"
"{\n"
" std::string s;\n"
" return s.c_str();\n"
"}\n");
ASSERT_EQUALS("[test.cpp:7]: (error) Returning pointer to auto variable\n", errout.str());
check("class Fred {\n"
" std::string hello();\n"
" const char *f();\n"
"};\n"
"std::string Fred::hello()\n"
"{\n"
" return \"hello\";\n"
"}\n"
"const char *Fred::f()\n"
"{\n"
" return hello().c_str();\n"
"}\n");
ASSERT_EQUALS("[test.cpp:11]: (error) Returning pointer to temporary\n", errout.str());
}
};
REGISTER_TEST(TestAutoVariables)

View File

@ -190,6 +190,7 @@ private:
TEST_CASE(symboldatabase9); // ticket #2525
TEST_CASE(symboldatabase10); // ticket #2537
TEST_CASE(symboldatabase11); // ticket #2539
TEST_CASE(symboldatabase12); // ticket #2547
}
// Check the operator Equal
@ -487,11 +488,11 @@ private:
" UString& operator=( const UString& s );\n"
"};\n"
"UString& UString::assign( const char* c_str ) {\n"
" std::string tmp( c_str );\n"
" return assign( tmp );\n"
" std::string tmp( c_str );\n"
" return assign( tmp );\n"
"}\n"
"UString& UString::operator=( const UString& s ) {\n"
" return assign( s );\n"
" return assign( s );\n"
"}\n");
}
@ -2722,7 +2723,7 @@ private:
" A()\n"
" {\n"
" init();\n"
" }\n"
" }\n"
"\n"
" void init() { init(0); }\n"
"\n"
@ -5451,12 +5452,12 @@ private:
checkConst("template<template<class> class E,class D> class C : E<D>\n"
"{\n"
"public:\n"
" int f();\n"
" int f();\n"
"};\n"
"class E : C<D,int>\n"
"{\n"
"public:\n"
" int f() { return C< ::D,int>::f(); }\n"
" int f() { return C< ::D,int>::f(); }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
@ -5517,6 +5518,16 @@ private:
ASSERT_EQUALS("", errout.str());
}
void symboldatabase12()
{
// ticket #2547 - segmentation fault
checkConst("class foo {\n"
" void bar2 () = __null;\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestClass)

View File

@ -37,6 +37,9 @@ private:
TEST_CASE(destructors);
TEST_CASE(deallocThrow1);
TEST_CASE(deallocThrow2);
TEST_CASE(rethrowCopy1);
TEST_CASE(rethrowCopy2);
TEST_CASE(rethrowCopy3);
}
void check(const std::string &code)
@ -90,6 +93,52 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
}
void rethrowCopy1()
{
check("void f() {\n"
" try\n"
" {\n"
" foo();\n"
" }\n"
" catch(const exception& err)\n"
" {\n"
" throw err;\n"
" }\n"
"}\n");
ASSERT_EQUALS("[test.cpp:8]: (style) Throwing a copy of the caught exception instead of rethrowing the original exception\n", errout.str());
}
void rethrowCopy2()
{
check("void f() {\n"
" try\n"
" {\n"
" foo();\n"
" }\n"
" catch(exception err)\n"
" {\n"
" throw err;\n"
" }\n"
"}\n");
ASSERT_EQUALS("[test.cpp:8]: (style) Throwing a copy of the caught exception instead of rethrowing the original exception\n", errout.str());
}
void rethrowCopy3()
{
check("void f() {\n"
" try\n"
" {\n"
" foo();\n"
" }\n"
" catch(exception err)\n"
" {\n"
" exception err2;\n"
" throw err2;\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestExceptionSafety)

View File

@ -66,20 +66,20 @@ private:
ASSERT_EQUALS("3000" , MathLib::multiply("1.0E3", "3"));
ASSERT_EQUALS("-3000" , MathLib::multiply("-1.0E3", "3"));
ASSERT_EQUALS("-3000" , MathLib::multiply("-1.0E+3", "3"));
ASSERT_EQUALS("0" , MathLib::multiply("-1.0E+3", "0"));
ASSERT_EQUALS("0" , MathLib::multiply("+1.0E+3", "0"));
ASSERT_EQUALS("2147483648" , MathLib::multiply("2","1073741824"));
ASSERT_EQUALS("536870912" , MathLib::multiply("512","1048576"));
ASSERT_EQUALS("0" , MathLib::multiply("-1.0E+3", "0"));
ASSERT_EQUALS("0" , MathLib::multiply("+1.0E+3", "0"));
ASSERT_EQUALS("2147483648" , MathLib::multiply("2","1073741824"));
ASSERT_EQUALS("536870912" , MathLib::multiply("512","1048576"));
// divide
ASSERT_EQUALS("1" , MathLib::divide("1", "1"));
ASSERT_EQUALS("0" , MathLib::divide("0", "1"));
ASSERT_EQUALS("5" , MathLib::divide("-10", "-2"));
ASSERT_EQUALS("1" , MathLib::divide("1", "1"));
ASSERT_EQUALS("0" , MathLib::divide("0", "1"));
ASSERT_EQUALS("5" , MathLib::divide("-10", "-2"));
ASSERT_EQUALS("-2.5", MathLib::divide("-10.", "4"));
ASSERT_EQUALS("2.5" , MathLib::divide("-10.", "-4"));
ASSERT_EQUALS("5" , MathLib::divide("25.5", "5.1"));
ASSERT_EQUALS("7" , MathLib::divide("21.", "3"));
ASSERT_EQUALS("1" , MathLib::divide("3", "2"));
ASSERT_EQUALS("5" , MathLib::divide("25.5", "5.1"));
ASSERT_EQUALS("7" , MathLib::divide("21.", "3"));
ASSERT_EQUALS("1" , MathLib::divide("3", "2"));
}

View File

@ -197,6 +197,7 @@ private:
TEST_CASE(switch2);
TEST_CASE(switch3);
TEST_CASE(switch4); // #2555 - segfault
TEST_CASE(ret5); // Bug 2458436 - return use
TEST_CASE(ret6);
@ -1287,6 +1288,17 @@ private:
ASSERT_EQUALS("[test.cpp:9]: (error) Memory leak: str\n", errout.str());
}
void switch4()
{
check("void f() {\n"
" switch MAKEWORD(1)\n"
" {\n"
" case 0:\n"
" return;\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void ret5()
{

View File

@ -668,7 +668,7 @@ private:
check("void f(int a) {\n"
" const char *p = 0;\n"
" if (a) {\n"
" p = \"abcd\";\n"
" p = \"abcd\";\n"
" }\n"
" for (int i = 0; i < 3; i++) {\n"
" if (a && (p[i] == '1'));\n"

View File

@ -102,6 +102,8 @@ private:
TEST_CASE(sizeofForArrayParameter);
TEST_CASE(clarifyCalculation);
TEST_CASE(incorrectStringCompare);
}
void check(const char code[], const char *filename = NULL)
@ -138,6 +140,7 @@ private:
checkOther.checkCatchExceptionByValue();
checkOther.checkMemsetZeroBytes();
checkOther.clarifyCalculation();
checkOther.checkIncorrectStringCompare();
}
@ -1856,6 +1859,39 @@ private:
ASSERT_EQUALS("[test.cpp:2]: (information) Please clarify precedence: 'a*b?..'\n", errout.str());
}
void incorrectStringCompare()
{
check("int f() {\n"
" return test.substr( 0 , 4 ) == \"Hello\" ? : 0 : 1 ;\n"
"}");
ASSERT_EQUALS("[test.cpp:2]: (warning) String literal \"Hello\" doesn't match length argument for substr(4).\n", errout.str());
check("int f() {\n"
" return test.substr( 0 , 5 ) == \"Hello\" ? : 0 : 1 ;\n"
"}");
ASSERT_EQUALS("", errout.str());
check("int f() {\n"
" return \"Hello\" == test.substr( 0 , 4 ) ? : 0 : 1 ;\n"
"}");
ASSERT_EQUALS("[test.cpp:2]: (warning) String literal \"Hello\" doesn't match length argument for substr(4).\n", errout.str());
check("int f() {\n"
" return \"Hello\" == test.substr( 0 , 5 ) ? : 0 : 1 ;\n"
"}");
ASSERT_EQUALS("", errout.str());
check("int f() {\n"
" return strncmp(\"test\" , \"test\" , 2) ; \n"
"}");
ASSERT_EQUALS("[test.cpp:2]: (warning) String literal \"test\" doesn't match length argument for strncmp(2).\n", errout.str());
check("int f() {\n"
" return strncmp(\"test\" , \"test\" , 4) ; \n"
"}");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestOther)

View File

@ -78,6 +78,11 @@ private:
TEST_CASE(test5);
TEST_CASE(test6);
TEST_CASE(test7);
TEST_CASE(test7a);
TEST_CASE(test7b);
TEST_CASE(test7c);
TEST_CASE(test7d);
TEST_CASE(test7e);
// #error => don't extract any code
TEST_CASE(error1);
@ -429,8 +434,9 @@ private:
preprocessor.preprocess(istr, actual, "file.c");
// Make sure an error message is written..
ASSERT_EQUALS("[file.c:3]: (error) ABC is already guaranteed to be defined\n",
errout.str());
TODO_ASSERT_EQUALS("[file.c:3]: (error) ABC is already guaranteed to be defined\n",
"",
errout.str());
// Compare results..
ASSERT_EQUALS("\n\n\n\n\n\n", actual[""]);
@ -511,8 +517,9 @@ private:
preprocessor.preprocess(istr, actual, "file.c");
// Make sure an error message is written..
ASSERT_EQUALS("[file.c:3]: (error) ABC is already guaranteed to be defined\n",
errout.str());
TODO_ASSERT_EQUALS("[file.c:3]: (error) ABC is already guaranteed to be defined\n",
"",
errout.str());
// Compare results..
ASSERT_EQUALS(2, static_cast<unsigned int>(actual.size()));
@ -536,7 +543,36 @@ private:
preprocessor.preprocess(istr, actual, "file.c");
// Make sure an error message is written..
ASSERT_EQUALS("[file.c:3]: (error) ABC is already guaranteed to be defined\n",
TODO_ASSERT_EQUALS("[file.c:3]: (error) ABC is already guaranteed to be defined\n",
"",
errout.str());
// Compare results..
ASSERT_EQUALS(2, static_cast<unsigned int>(actual.size()));
}
void test7e()
{
const char filedata[] = "#ifdef ABC\n"
"#file \"test.h\"\n"
"#ifndef test_h\n"
"#define test_h\n"
"#ifdef ABC\n"
"#endif\n"
"#endif\n"
"#endfile\n"
"#endif\n";
// Preprocess => actual result..
std::istringstream istr(filedata);
std::map<std::string, std::string> actual;
Settings settings;
Preprocessor preprocessor(&settings, this);
errout.str("");
preprocessor.preprocess(istr, actual, "file.c");
// Make sure an error message is written..
ASSERT_EQUALS("",
errout.str());
// Compare results..

View File

@ -213,6 +213,7 @@ private:
TEST_CASE(simplify_constants);
TEST_CASE(simplify_constants2);
TEST_CASE(simplify_constants3);
TEST_CASE(simplify_null);
TEST_CASE(vardecl1);
TEST_CASE(vardecl2);
@ -3879,6 +3880,16 @@ private:
ASSERT_EQUALS(expected, tokenizeAndStringify(code,true));
}
void simplify_null()
{
const char code[] =
"int * p = NULL;\n"
"int * q = __null;\n";
const char expected[] =
"int * p ; p = 0 ;\nint * q ; q = 0 ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code,true));
}
void vardecl1()
{
const char code[] = "unsigned int a, b;";

View File

@ -736,9 +736,9 @@ private:
checkUninitVar("enum ABCD { A, B, C, D };\n"
"\n"
"static void f(char *str ) {\n"
" enum ABCD i;\n"
" for (i = 0; i < D; i++) {\n"
" str[i] = 0;\n"
" enum ABCD i;\n"
" for (i = 0; i < D; i++) {\n"
" str[i] = 0;\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());

View File

@ -1,138 +0,0 @@
#include "codeeditor.h"
#include <QPainter>
#include <QTextBlock>
CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent)
{
lineNumberArea = new LineNumberArea(this);
connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
connect(this, SIGNAL(updateRequest(const QRect &, int)), this, SLOT(updateLineNumberArea(const QRect &, int)));
//connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
updateLineNumberAreaWidth(0);
//highlightCurrentLine();
}
int CodeEditor::lineNumberAreaWidth()
{
int digits = 1;
int max = qMax(1, blockCount());
while (max >= 10)
{
max /= 10;
++digits;
}
int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;
return space;
}
void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */)
{
setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
}
void CodeEditor::updateLineNumberArea(const QRect &rect, int dy)
{
if (dy)
lineNumberArea->scroll(0, dy);
else
lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height());
if (rect.contains(viewport()->rect()))
updateLineNumberAreaWidth(0);
}
void CodeEditor::resizeEvent(QResizeEvent *e)
{
QPlainTextEdit::resizeEvent(e);
QRect cr = contentsRect();
lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
}
/*
void CodeEditor::highlightCurrentLine()
{
QList<QTextEdit::ExtraSelection> extraSelections;
if (!isReadOnly())
{
QTextEdit::ExtraSelection selection;
QColor lineColor = QColor(Qt::yellow).lighter(160);
selection.format.setBackground(lineColor);
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
selection.cursor = textCursor();
selection.cursor.clearSelection();
extraSelections.append(selection);
}
setExtraSelections(extraSelections);
}
*/
void CodeEditor::highlightErrors(const QList<int> &errorLines)
{
QList<QTextEdit::ExtraSelection> extraSelections;
for (int i = 0; i < errorLines.size(); ++i)
{
QTextEdit::ExtraSelection selection;
QColor lineColor = QColor(Qt::red).lighter(160);
selection.format.setBackground(lineColor);
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
selection.cursor = textCursor();
selection.cursor.clearSelection();
selection.cursor.movePosition(QTextCursor::Start);
selection.cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, errorLines[i] - 1);
extraSelections.append(selection);
}
setExtraSelections(extraSelections);
}
void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
{
QPainter painter(lineNumberArea);
painter.fillRect(event->rect(), Qt::lightGray);
QTextBlock block = firstVisibleBlock();
int blockNumber = block.blockNumber();
int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top();
int bottom = top + (int) blockBoundingRect(block).height();
while (block.isValid() && top <= event->rect().bottom())
{
if (block.isVisible() && bottom >= event->rect().top())
{
QString number = QString::number(blockNumber + 1);
painter.setPen(Qt::black);
painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(),
Qt::AlignRight, number);
}
block = block.next();
top = bottom;
bottom = top + (int) blockBoundingRect(block).height();
++blockNumber;
}
}

View File

@ -1,63 +0,0 @@
#ifndef CODEEDITOR_H
#define CODEEDITOR_H
#include <QPlainTextEdit>
#include <QObject>
#include <QList>
class QPaintEvent;
class QResizeEvent;
class QSize;
class QWidget;
class LineNumberArea;
class CodeEditor : public QPlainTextEdit
{
Q_OBJECT
public:
CodeEditor(QWidget *parent = 0);
void lineNumberAreaPaintEvent(QPaintEvent *event);
int lineNumberAreaWidth();
void highlightErrors(const QList<int> &errorLines);
protected:
void resizeEvent(QResizeEvent *event);
private slots:
void updateLineNumberAreaWidth(int newBlockCount);
//void highlightCurrentLine();
void updateLineNumberArea(const QRect &, int);
private:
QWidget *lineNumberArea;
};
class LineNumberArea : public QWidget
{
public:
LineNumberArea(CodeEditor *editor) : QWidget(editor)
{
codeEditor = editor;
}
QSize sizeHint() const
{
return QSize(codeEditor->lineNumberAreaWidth(), 0);
}
protected:
void paintEvent(QPaintEvent *event)
{
codeEditor->lineNumberAreaPaintEvent(event);
}
private:
CodeEditor *codeEditor;
};
#endif // CODEEDITOR_H

View File

@ -1,29 +0,0 @@
TARGET = cppcheck-verify
TEMPLATE = app
INCLUDEPATH += ../lib
SOURCES += main.cpp \
mainwindow.cpp \
../lib/tokenize.cpp \
../lib/token.cpp \
../lib/settings.cpp \
../lib/preprocessor.cpp \
../lib/path.cpp \
../lib/mathlib.cpp \
../lib/filelister_win32.cpp \
../lib/filelister_unix.cpp \
../lib/filelister.cpp \
../lib/errorlogger.cpp \
codeeditor.cpp
HEADERS += mainwindow.h \
../lib/tokenize.h \
../lib/token.h \
../lib/settings.h \
../lib/preprocessor.h \
../lib/path.h \
../lib/mathlib.h \
../lib/filelister_win32.h \
../lib/filelister_unix.h \
../lib/filelister.h \
../lib/errorlogger.h \
codeeditor.h
FORMS += mainwindow.ui

View File

@ -1,28 +0,0 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2010 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 <http://www.gnu.org/licenses/>.
*/
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

View File

@ -1,148 +0,0 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2010 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 <http://www.gnu.org/licenses/>.
*/
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "preprocessor.h"
#include "tokenize.h"
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <set>
#include <QFileDialog>
static void arrayIndex(const Tokenizer &tokenizer, std::set<unsigned int> &errorlines);
static unsigned char readChar(std::istream &istr)
{
unsigned char ch = (unsigned char)istr.get();
// Handling of newlines..
if (ch == '\r')
{
ch = '\n';
if ((char)istr.peek() == '\n')
(void)istr.get();
}
return ch;
}
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::open()
{
const std::string fileName = QFileDialog::getOpenFileName(this,
tr("Open File"),
"",
"cpp files (*.cpp)").toStdString();
if (fileName.empty())
return;
setWindowTitle(fileName.c_str());
Tokenizer tokenizer;
{
// Preprocess the file..
Preprocessor preprocessor;
std::ifstream fin(fileName.c_str());
std::string filedata;
std::list<std::string> configurations;
std::list<std::string> includePaths;
preprocessor.preprocess(fin,
filedata,
configurations,
fileName,
includePaths);
filedata = Preprocessor::getcode(filedata, "", fileName, NULL, NULL);
// Tokenize the preprocessed code..
std::istringstream istr(filedata);
tokenizer.tokenize(istr, fileName.c_str(), "");
}
// Check the tokens..
std::set<unsigned int> errorlines;
arrayIndex(tokenizer, errorlines);
// show report..
{
std::ostringstream report;
std::ifstream fin(fileName.c_str());
for (unsigned char c = readChar(fin); fin.good(); c = readChar(fin))
{
if (c & 0x80)
continue;
report << c;
}
ui->codeEditor->setPlainText(QString::fromStdString(report.str()));
QList<int> errorLines;
for (std::set<unsigned int>::const_iterator it = errorlines.begin(); it != errorlines.end(); ++it)
errorLines.push_back(*it);
ui->codeEditor->highlightErrors(errorLines);
}
}
/**
* Check that array indexes are within bounds
* 1. Locate array access through: [ .. ]
* 2. Try to determine if index is within bounds.
* 3. If it fails to determine that the index is within bounds then write warning
* \param tokenizer The tokenizer
* \param errout output stream to write warnings to
*/
static void arrayIndex(const Tokenizer &tokenizer, std::set<unsigned int> &errorlines)
{
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
{
// 1. Locate array access through: [ .. ]
if (tok->fileIndex() == 0 && tok->str() == "[")
{
// 2. try to determine if the array index is within bounds
// array declaration
if (Token::simpleMatch(tok, "[ ]"))
continue;
if (Token::Match(tok->tokAt(-2), "%type% %var% [ %num% ] ;|="))
continue;
// 3. If it fails to determine that the index is within bounds then write warning
errorlines.insert(tok->linenr());
}
}
}

View File

@ -1,43 +0,0 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2010 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 <http://www.gnu.org/licenses/>.
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtGui/QMainWindow>
namespace Ui
{
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void open();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

View File

@ -1,75 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>Cppcheck-Verify</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="CodeEditor" name="codeEditor">
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="tabStopWidth">
<number>4</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionOpen"/>
</widget>
<addaction name="menuFile"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionOpen">
<property name="text">
<string>Open..</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>CodeEditor</class>
<extends>QPlainTextEdit</extends>
<header>codeeditor.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,11 +0,0 @@
cppcheck-verify
===============
Experimental subproject for Cppcheck.
The goal is no false negatives.
Just use 'make' to build.

View File

@ -4,7 +4,7 @@
<?define Platform = "x86" ?>
<?endif ?>
<?define CliBuildDir = "..\Build\release" ?>
<?define CliBuildDir = "..\cli\release" ?>
<?define GuiBuildDir = "..\Build\gui" ?>
<?define TranslationsDir = "..\gui" ?>
<?define HelpDir = "..\gui\help" ?>

View File

@ -43,6 +43,7 @@
<File Id='cppcheck_de.qm' Name='cppcheck_de.qm' Source='$(var.TranslationsDir)\cppcheck_de.qm' />
<File Id='cppcheck_en.qm' Name='cppcheck_en.qm' Source='$(var.TranslationsDir)\cppcheck_en.qm' />
<File Id='cppcheck_fi.qm' Name='cppcheck_fi.qm' Source='$(var.TranslationsDir)\cppcheck_fi.qm' />
<File Id='cppcheck_fr.qm' Name='cppcheck_fr.qm' Source='$(var.TranslationsDir)\cppcheck_fr.qm' />
<File Id='cppcheck_ja.qm' Name='cppcheck_ja.qm' Source='$(var.TranslationsDir)\cppcheck_ja.qm' />
<File Id='cppcheck_nl.qm' Name='cppcheck_nl.qm' Source='$(var.TranslationsDir)\cppcheck_nl.qm' />
<File Id='cppcheck_pl.qm' Name='cppcheck_pl.qm' Source='$(var.TranslationsDir)\cppcheck_pl.qm' />

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Include>
<?define ProductName = "Cppcheck 1.46" ?>
<?define ProductName = "Cppcheck 1.47" ?>
<?define ProductNameShort = "Cppcheck" ?>
<?define ProductVersion = "1.46.0" ?>
<?define ProductVersion = "1.47.0" ?>
<?define ProductManufacturer = "The Cppcheck team" ?>
<?define ProductDescription = "Cppcheck is a tool for static analysis of C/C++ code" ?>