diff --git a/.gitignore b/.gitignore index e62fe2dbf..2a43f4cd9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ tools/dmake dmake tools/errmsg # VS generated files +*.obj *.ncb *.suo *.user diff --git a/Changelog b/Changelog index d63f42e53..040c6997b 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,2693 @@ +2011-02-06 Daniel Marjamäki + + * cli/cppcheck.rc, cli/main.cpp, lib/cppcheck.cpp, + win_installer/productInfo.wxi: 1.47: Updated versions + +2011-02-06 Daniel Marjamäki + + * man/manual.docbook: manual: updated for 1.47 release + +2011-02-06 Daniel Marjamäki + + * readme.txt: readme: tweaked the 'compiling cppcheck' section + +2011-02-06 Zachary Blair + + * lib/checkexceptionsafety.cpp, lib/checkexceptionsafety.h: Ticket + #2388. Added more detail to the 'exceptRethrowCopy' error message. + +2011-02-06 Zachary Blair + + * : commit 2506c7db5cac7a04a143ca2f0d8fecbe0d9c22ba Author: Daniel + Marjamäki Date: Sun Feb 6 10:04:28 2011 + +0100 + +2011-02-06 Daniel Marjamäki + + * lib/tokenize.cpp: Tokenizer: Added a comment about sizeof for + struct/class. We always assume that the size is 100 + +2011-02-05 Kimmo Varis + + * .gitignore: Add .obj files to gitignore. + +2011-02-05 Kimmo Varis + + * gui/cppcheck_de.ts, gui/cppcheck_en.ts, gui/cppcheck_fi.ts, + gui/cppcheck_fr.ts, gui/cppcheck_ja.ts, gui/cppcheck_nl.ts, + gui/cppcheck_pl.ts, gui/cppcheck_ru.ts, gui/cppcheck_se.ts, + gui/cppcheck_sr.ts: GUI: Update translation files. + +2011-02-05 Kimmo Varis + + * win_installer/config.wxi: Installer: Update CLI build directory. + +2011-02-05 Kimmo Varis + + * win_installer/cppcheck.wxs: Installer: Add French translation to + installer. + +2011-02-05 Kimmo Varis + + * gui/gui.pro: GUI: Add French translation to project file. + +2011-02-05 Reijo Tomperi + + * cli/cmdlineparser.cpp: Improve --help listing by removing + duplicate options list and using lt and gt characters for option + arguments. + +2011-02-05 Reijo Tomperi + + * man/cppcheck.1.xml: Update man page to contain more info about + --rule options. + +2011-02-05 Reijo Tomperi + + * man/cppcheck.1.xml: Update man page + +2011-02-05 Daniel Marjamäki + + * cli/cmdlineparser.cpp: Cppcheck: Added short info about --rule and + --rule-file to --help output + +2011-02-05 Kimmo Varis + + * gui/cppcheck_de.ts, gui/cppcheck_en.ts, gui/cppcheck_fi.ts, + gui/cppcheck_ja.ts, gui/cppcheck_nl.ts, gui/cppcheck_pl.ts, + gui/cppcheck_ru.ts, gui/cppcheck_se.ts, gui/cppcheck_sr.ts: GUI: + Update translation files. + +2011-02-05 Kimmo Varis + + * gui/xmlreportv2.cpp, gui/xmlreportv2.h: GUI: Fix reading multiple + error locations from XML. + +2011-02-05 Kimmo Varis + + * : commit f279fcd351e5331551b34ab0f7c26730eb0af068 Author: Kimmo + Varis Date: Sat Feb 5 16:07:59 2011 +0200 + +2011-02-05 Kimmo Varis + + * gui/xmlreportv2.cpp, gui/xmlreportv2.h: GUI: Read XML format + version 2 files. Implement the parsing of XML format v2 error data. + +2011-02-05 Daniel Marjamäki + + * scripts/tabs.pl, test/testclass.cpp, test/testmathlib.cpp, + test/testnullpointer.cpp, test/testuninitvar.cpp: scripts: added + tabs.pl - in my opinion it is bad to use tabs inside string + constants. spaces or \t should be used instead. + +2011-02-05 Kimmo Varis + + * gui/resultsview.cpp, gui/xmlreport.h, gui/xmlreportv1.cpp, + gui/xmlreportv1.h, gui/xmlreportv2.cpp, gui/xmlreportv2.h: GUI: Read + ErrorItems instead of ErrorLines from XML report. XML report format 1 only had error "lines" that we promoted to + "items" when adding to GUI. XML report format 2 contains error + "items" so change the code to read items and do the promotion + directly when reading and parsing the data. + +2011-02-05 Kimmo Varis + + * gui/resultsview.cpp, gui/xmlreport.cpp, gui/xmlreport.h, + gui/xmlreportv2.cpp, gui/xmlreportv2.h: GUI: Determine the XML + report format before reading report. + +2011-02-05 Zachary Blair + + * lib/checkexceptionsafety.cpp, lib/checkexceptionsafety.h, + test/testexceptionsafety.cpp: Fixed #2388 (Use throw without + argument to rethrow exceptions) + +2011-02-05 Robert Reif + + * lib/tokenize.cpp, test/testtokenize.cpp: Tokenizer: Replace __null + with 0 (gcc constant) + +2011-02-05 Robert Reif + + * lib/symboldatabase.cpp, test/testclass.cpp: Fixed #2547 + (segmentation fault of cppcheck) + +2011-02-05 Reijo Tomperi + + * man/cppcheck.1.xml: Update man page + +2011-02-05 Kimmo Varis + + * gui/xmlreport.cpp, gui/xmlreport.h, gui/xmlreportv1.cpp, + gui/xmlreportv2.cpp: GUI: Quote special chars in the XML output. Fixes ticket #2543 (GUI: Xml report does not quote special + characters) + +2011-02-04 Kimmo Varis + + * gui/gui.pro, gui/resultsview.cpp, gui/xmlreport.cpp, + gui/xmlreport.h, gui/xmlreportv1.cpp, gui/xmlreportv1.h, + gui/xmlreportv2.cpp, gui/xmlreportv2.h: GUI: Add base class for XML + report classes. A base class is needed for e.g. some common routines that can be + shared between the formats. + +2011-02-04 Daniel Marjamäki + + * gui/cppcheck_se.ts: GUI: Updated the swedish translation + +2011-02-03 Kimmo Varis + + * gui/gui.pro, gui/mainwindow.cpp, gui/report.h, + gui/resultsview.cpp, gui/xmlreportv2.cpp, gui/xmlreportv2.h: GUI: + Write XML version 2. Ticket #2521 (GUI: Add XML format 2 support) + +2011-02-04 Daniel Marjamäki + + * lib/checkother.cpp, test/testother.cpp: Fixed #2498 (False + positive: redundant assignment) + +2011-02-04 Stefan Weil + + * cli/cmdlineparser.cpp: Add missing \n in CLI help. + +2011-02-04 Daniel Marjamäki + + * lib/checkother.h: Fixed #2531 (False positive: Redudant assignment + to itself) + +2011-02-04 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #2503 (false + positive: memory leak (struct member, address is taken)) + +2011-02-04 Robert Reif + + * lib/symboldatabase.cpp, test/testclass.cpp: Fixed #2539 + (segmentation fault of cppcheck) + +2011-02-04 Robert Reif + + * lib/checkmemoryleak.cpp: Fixed #2546 (make CheckMemoryLeakInClass + also check structures) + +2011-02-04 Daniel Marjamäki + + * lib/errorlogger.cpp, test/testerrorlogger.cpp: Fixed #2544 (XML + output does not specify encoding used) + +2011-02-04 Kimmo Varis + + * lib/checkother.cpp, lib/checkpostfixoperator.cpp, + lib/checkstl.cpp: Clarify few verbose messages. Dan pointed out to me earlier that he wants both short- and verbose + messages to be independently understandable. So modifying some + verbose messages to be easier to understand without the short + message. + +2011-02-03 Daniel Marjamäki + + * lib/checknullpointer.cpp, test/testuninitvar.cpp: Fixed #2533 + (false positive: (error) Uninitialized variable: cBuffer) + +2011-02-03 Daniel Marjamäki + + * lib/check.h, test/testcppcheck.cpp: astyle formatting + +2011-02-03 Tim Gerundt + + * : commit 53492209fc892557a82bd30d72ec555bc21b44cb Author: Tim + Gerundt Date: Thu Feb 3 21:23:03 2011 +0100 + +2011-02-03 Tim Gerundt + + * htdocs/devinfo/index.php: Web: Add 'View all commits' link to + devinfo page + +2011-02-03 Tim Gerundt + + * htdocs/devinfo/index.php: Web: Add last Trac timeline items to + devinfo page + +2011-02-03 Tim Gerundt + + * htdocs/devinfo/index.php: Web: Add RSS link to Trac Timeline + +2011-02-03 Kimmo Varis + + * test/test.vcproj, test/test.vcxproj, test/test.vcxproj.filters: + Update VS 2008/2010 project files for tests. + +2011-02-03 Kimmo Varis + + * cli/cmdlineparser.cpp, cli/pathmatch.cpp, + test/testcmdlineparser.cpp, test/testpathmatch.cpp: Allow to exclude + filenames (with paths). This expands the CLI exclude feature to also allow excluding + filenames (with paths). When filename with recognized extension is + given to -i option then matching filenames (with paths) are ignored + when checking. Ticket #2538 (Allow excluding files from the checking) + +2011-02-03 Kimmo Varis + + * cli/filelister.h, cli/filelister_unix.cpp: Make + FileLister::acceptFile() a static method. We don't need different acceptFile() implementations per platform so + it is better to have one static method. + +2011-02-03 Kimmo Varis + + * test/testerrorlogger.cpp: Add test for XML format version 2. + +2011-02-03 Kimmo Varis + + * cli/pathmatch.cpp, test/testpathmatch.cpp: Tighten the directory + name mathing with -i. Only match full directory names as parts of whole paths. So -isrc + matches src/file.cpp and proj/src/file.cpp. But does not match + mysrc/file.cpp or proj/srcfiles/file.cpp. + +2011-02-03 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #2536 + (cppcheck hangs with 100% cpu load) + +2011-02-03 Robert Reif + + * lib/symboldatabase.cpp, lib/symboldatabase.h, test/testclass.cpp: + Fixed #2537 (segmentation fault of cppcheck) + +2011-02-02 Raphael Geissert + + * rules/error-reporting.xml, rules/stl.xml: Add a few more rules + +2011-02-02 Raphael Geissert + + * rules/token-matching.xml: Add rules for tokAt(0) and strAt(0), + suggested by reif + +2011-02-02 Kimmo Varis + + * test/test.pro: Add testsymboldatabase.cpp to test.pro. Also add comment explaining omitting testfilelister_unix.cpp. + +2011-02-02 Raphael Geissert + + * lib/tokenize.cpp: A few more Token::Match -> ::simpleMatch + replacements + +2011-02-02 Raphael Geissert + + * rules/token-matching.xml: Yet another tweak to the regex, use + ungreedy mode + +2011-02-02 Raphael Geissert + + * lib/checkbufferoverrun.cpp, lib/checkclass.cpp, + lib/checkmemoryleak.cpp, lib/checknullpointer.cpp, + lib/checkother.cpp, lib/checkstl.cpp, lib/symboldatabase.cpp, + lib/tokenize.cpp: Use Token::simpleMatch where no special patterns + are needed + +2011-02-02 Raphael Geissert + + * lib/cppcheck.cpp: Try to match custom rules as many times as + possible, not just once + +2011-02-02 Raphael Geissert + + * lib/cppcheck.cpp: Remove uneeded indentation + +2011-02-02 Raphael Geissert + + * lib/checkautovariables.cpp, lib/checkbufferoverrun.cpp, + lib/checkclass.cpp, lib/checkmemoryleak.cpp, + lib/checknullpointer.cpp, lib/checkother.cpp, lib/checkstl.cpp, + lib/executionpath.cpp, lib/preprocessor.cpp, lib/tokenize.cpp: Use + Token::simpleMatch where no patterns are used + +2011-02-02 Raphael Geissert + + * lib/checkbufferoverrun.cpp, lib/checkclass.cpp, + lib/checkother.cpp, lib/checkstl.cpp, lib/symboldatabase.cpp, + lib/tokenize.cpp: Remove useless spacing at the end of *Match + strings + +2011-02-02 Raphael Geissert + + * rules/token-matching.xml: Also detect useless spacing at the end + of *Match calls + +2011-02-02 Raphael Geissert + + * cli/cmdlineparser.cpp: Support multiple rules in a single XML file + +2011-02-02 Raphael Geissert + + * rules/token-matching.xml: Introduce some rules for checking + cppcheck's use of Token::*Match + +2011-02-02 Kimmo Varis + + * : commit d592250284cdf3f1ded17814c29ea4bae06b3126 Author: Raphael + Geissert Date: Wed Feb 2 10:56:02 2011 -0600 + +2011-02-02 Daniel Marjamäki + + * cli/cppcheckexecutor.cpp, lib/errorlogger.cpp, lib/errorlogger.h, + test/testerrorlogger.cpp: xml2: added element + +2011-02-02 Daniel Marjamäki + + * : commit 1a83e3ef8124cffaa43d900dc4c71b79f7772def Author: Kimmo + Varis Date: Tue Feb 1 23:02:07 2011 +0200 + +2011-02-01 Kimmo Varis + + * cli/pathmatch.cpp: Don't check empty paths for path ignore. + +2011-02-01 Kimmo Varis + + * cli/cppcheck.vcproj, cli/cppcheck.vcxproj, + cli/cppcheck.vcxproj.filters, test/test.vcproj, test/test.vcxproj, + test/test.vcxproj.filters: Update VS2008/VS2010 project files. + +2011-02-01 Kimmo Varis + + * Makefile, test/testpathmatch.cpp, tools/dmake.cpp: Run dmake to + update Makefile. + +2011-01-31 Kimmo Varis + + * cli/cli.pro, cli/cmdlineparser.cpp, cli/cmdlineparser.h, + cli/cppcheckexecutor.cpp, cli/pathmatch.cpp, cli/pathmatch.h, + test/test.pro, test/testcmdlineparser.cpp, test/testpathmatch.cpp: + Add CLI support for ignoring paths. Add support for giving list of ignored paths from CLI. This way user + can define paths one doesn't want to check (like generated code). + This first simple implementation only does exact matching, no + support for wildcards etc. And matching is always agains dir names. If the filtered dir name is part of the checked filename then the + file is ignored. Ticket #1690 (Ability to exclude files and directories from checks) + +2011-02-02 Kimmo Varis + + * cli/cmdlineparser.cpp, test/testcmdlineparser.cpp: Imrove + --xml-version option parsing. Allow --xml-version parsing to recognize also version 1 and print + errors about invalid values. + +2011-02-02 Kimmo Varis + + * test/testcmdlineparser.cpp: Add couple of tests for xml-version + cmd line option. + +2011-02-02 Kimmo Varis + + * cli/cmdlineparser.cpp: Expose --xml-version=version cmd line + option. Make the --xml-version=version command line option public by adding + it to the command line help. + +2011-02-02 Greg Hewgill + + * lib/check.h: use instances of less to compare pointers + for list::sort() + +2011-02-02 Greg Hewgill + + * lib/check.h, lib/checkautovariables.h, lib/checkbufferoverrun.h, + lib/checkclass.cpp, lib/checkclass.h, lib/checkexceptionsafety.h, + lib/checkmemoryleak.h, lib/checknullpointer.h, + lib/checkobsoletefunctions.h, lib/checkother.h, + lib/checkpostfixoperator.h, lib/checkstl.h, lib/checkuninitvar.h, + lib/checkunusedfunctions.h: initialise Check::_name in constructor + rather than relying on virtual Check::name() + +2011-02-02 Greg Hewgill + + * test/testcppcheck.cpp: test case to check whether instances are + sorted + +2011-02-02 Robert Reif + + * lib/tokenize.cpp, lib/tokenize.h, test/testsimplifytokens.cpp: + Fixed #2530 (Tokenizer: Remove redundant 'MyClass::' inside MyClass + class declaration) + +2011-02-01 Daniel Marjamäki + + * lib/checkother.cpp, lib/tokenize.cpp, test/testtokenize.cpp: Fixed + #2529 (False positive: array 'req[3]' index 4 out of bounds) + +2011-02-01 Tim Gerundt + + * .gitignore: Drop htdocs/ from gitignore + +2011-02-01 Tim Gerundt + + * readme.txt: Switch website URL in readme.txt + +2011-02-01 Tim Gerundt + + * : commit b7494d51150360e3dee1fbd0f6105cfb162c1135 Merge: 3ce8aaf + c2de1a8 Author: Tim Gerundt Date: Tue Feb 1 + 19:23:20 2011 +0100 + +2011-01-31 Kimmo Varis + + * lib/cppcheck.cpp: Convert "too many configurations" message to + information message. The "too many configurations"-message is currently only printed to + the log. So it won't be seen by users integrating Cppcheck using XML + error file. It is also easily missed in the GUI as it only shows up + in the checking log. Making it a information message it shows up + with the other errors and tells user that file was not completely + checked. Ticket #2527 (Make "too many configurations" message an error + message) + +2011-02-01 Pete Johns + + * cli/filelister_win32.cpp: Astyle formatting. + +2011-02-01 Pete Johns + + * test/testother.cpp: Turned failing ASSERT_EQUALS into + TODO_ASSERT_EQUALS. + +2011-02-01 Pete Johns + + * : Merge https://github.com/ghewgill/cppcheck + +2011-01-31 Robert Reif + + * cppcheck.cppcheck, gui/gui.cppcheck: Ticket #2522 (update project + files to fix missing include messages) + +2011-02-01 Greg Hewgill + + * test/testother.cpp: check that misused scope object does not pick + nested class + +2011-01-31 Daniel Marjamäki + + * lib/checknullpointer.cpp, test/testnullpointer.cpp: Fixed #2525 + (False positive 'Possible null pointer dereference') + +2011-01-31 Daniel Marjamäki + + * cli/filelister_win32.cpp, test/testbufferoverrun.cpp, + test/testpreprocessor.cpp: astyle formatting + +2011-01-31 Ettl Martin + + * : commit f3111b541ee117c09bafd62f8333718e5ddf5bd8 Author: Ettl + Martin Date: Mon Jan 31 13:46:51 2011 +0100 + +2011-01-31 Kimmo Varis + + * gui/cppcheck_de.ts, gui/cppcheck_en.ts, gui/cppcheck_fi.ts, + gui/cppcheck_ja.ts, gui/cppcheck_nl.ts, gui/cppcheck_pl.ts, + gui/cppcheck_ru.ts, gui/cppcheck_se.ts, gui/cppcheck_sr.ts: GUI: + Update translation files. + +2011-01-31 Kimmo Varis + + * gui/settings.ui: GUI: Reword the option for checking all #ifdefs. The current wording was confusing (espcially related to CLI) since + it said the option will make Cppcheck to check all #ifdef configs. + But this really is case only when there is excessive amount of those + configs and without the option some would be ignored. So format the + option text in line of CLI switch and say it is forcing not enabling + checking of all configurations. + +2011-01-31 Kimmo Varis + + * gui/csvreport.cpp, gui/txtreport.cpp: GUI: Write error summary to + CSV and TXT reports. It makes more sense to write the one-line summary to TXT and + especially to CSV reports. Long multi-line verbose messages ruin the + layout these files. + +2011-01-31 Kimmo Varis + + * gui/xmlreport.cpp: GUI: Fill summary data when reading XML file. When reading XML file there is no summary data stored so we must + dublicate the message data to summary. Since message can be long try + to find full stop from the message and cut summary to it. Ticket: #2402 ([GUI] Summary is not shown for loaded .xml file) + +2011-01-31 Kimmo Varis + + * Makefile, tools/dmake.cpp: Cleanup makefile a bit. Align object file lists first line. Remove excessive use of tabs. + +2011-01-30 Raphael Geissert + + * lib/preprocessor.cpp: Formatting, sorry + +2011-01-30 Raphael Geissert + + * lib/preprocessor.cpp: Minor optimisations to the preprocessor + +2011-01-30 Raphael Geissert + + * lib/preprocessor.cpp: Reduce std::string::find() abuse + +2011-01-30 Raphael Geissert + + * lib/preprocessor.cpp, test/testpreprocessor.cpp: Handle "#endif + !defined" conditionals + +2011-01-30 Raphael Geissert + + * lib/preprocessor.cpp, test/testpreprocessor.cpp: Check for cpp + conditionals where a define is already guaranteed + +2011-01-30 Pete Johns + + * test/testbufferoverrun.cpp, test/testclass.cpp, + test/testdivision.cpp, test/testmemleak.cpp, + test/testnullpointer.cpp, test/testobsoletefunctions.cpp, + test/testother.cpp, test/testpostfixoperator.cpp, + test/testpreprocessor.cpp, test/testsimplifytokens.cpp, + test/teststl.cpp, test/testsuite.cpp, test/testsuite.h, + test/testtokenize.cpp, test/testuninitvar.cpp, + test/testunusedvar.cpp: Fixed #2526 (Make TODO_ASSERT_EQUALS take + three arguments (value, to_be, as_is)?... Removed replaced EXPECTED with... WANTED (to-be): The future expected value. CURRENT (as-is): + Documenting how cppcheck behaves now. This removes the need for an ASSERT_EQUALS but enforces the check + for every TODO_ASSERT_EQUALS. + +2011-01-30 Pete Johns + + * cli/filelister_win32.cpp: astyle formatting. + +2011-01-30 Raphael Geissert + + * lib/checknullpointer.cpp: Detect null pointer dereferences for + many FILE-related functions Ticket #1415: check for calling f{eof,read,close,...} with NULL + +2011-01-30 Raphael Geissert + + * lib/preprocessor.cpp, test/testpreprocessor.cpp: Remove duplicated + defines After simplifying define(A) conditionals, the final list of + configurations could end up containing duplicate items. Ticket #1468 + +2011-01-30 Robert Reif + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Memory leaks: less + conservative checking of classes. ticket: #2517 + +2011-01-30 Daniel Marjamäki + + * lib/tokenize.cpp, lib/tokenize.h, test/testtokenize.cpp: + Tokenizer: remove some unhandled macros in the global scope. ticket: + #2523 + +2011-01-29 Daniel Marjamäki + + * lib/checkmemoryleak.cpp: Memory leaks: bug fix. don't skip '}' by + accident + +2011-01-29 Kimmo Varis + + * test/testcmdlineparser.cpp: Several fixes to cmd line tests. There were several tests handling two parameters as one string. Eg. + "-I path" which doesn't work correctly. Fixed these problematic + tests. + +2011-01-29 Kimmo Varis + + * cli/cmdlineparser.cpp, test/testcmdlineparser.cpp: Make + --exitcode-suppressions option consistent. The --exitcode-suppressions option was inconsistent with other long + options by taking the filename as separate argument. Now it expects + format --exitcode-suppressions=filename.txt like other long options. Ticket: #1837 (--suppresions file.txt inconsistent) + +2011-01-29 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Tokenizer: Better + simplifications of static constants + +2011-01-28 Kimmo Varis + + * cli/cmdlineparser.cpp, test/testcmdlineparser.cpp: Rename + --suppressions-list CLI option. The option --suppressions-list was inconsistent with other options + so renaming it to --suppressions-list. Ticket: #1837 (--suppresions file.txt inconsistent) + +2011-01-28 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #2505 (Check + processing of a preprocessor macro 'FREE') + +2011-01-28 Robert Reif + + * lib/symboldatabase.cpp, lib/symboldatabase.h, + test/testsymboldatabase.cpp: Symbol database: better unit testing. + ticket: #2468 + +2011-01-28 Kimmo Varis + + * cli/cmdlineparser.cpp: Add --errorlist to CLI help. Fixes ticket #2253 (Make CLI error listing documented and public + switch) + +2011-01-27 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #2518 (Crash when + checking rockbox's firmwire) + +2011-01-27 Daniel Marjamäki + + * lib/checkclass.cpp, lib/symboldatabase.cpp, lib/tokenize.cpp, + lib/tokenize.h, test/testclass.cpp, test/testsimplifytokens.cpp, + test/testtokenize.cpp, test/testunusedprivfunc.cpp: Tokenizer: + collapse operator function names into a single token. ticket: #2519 + +2011-01-27 Kimmo Varis + + * test/testcmdlineparser.cpp: Add cmd line parser tests for XML ver + 2 options. + +2011-01-27 Kimmo Varis + + * gui/aboutdialog.cpp: GUI: Update homepage URL to About-dialog. + +2011-01-27 Kimmo Varis + + * cli/cmdlineparser.cpp, cli/cppcheckexecutor.cpp, + test/testcmdlineparser.cpp: Don't stop processing cmd line after + --errorlist. Ticket #2441 (Parsing of command line arguments breaks after + --errorlist) Instead of stopping processing command line options after + --errorlist process them all. This way e.g. --verbose can be given + also after the --errorlist. + +2011-01-27 Kimmo Varis + + * cli/cmdlineparser.cpp, cli/cmdlineparser.h, + cli/cppcheckexecutor.cpp: Don't print "files not found" after + showing help. Fix ticket #2496 (Is error reporting for an unneeded parameter + wrong?) There are several command line options / commands after which we + don't want Cppcheck to even try to open any files. Eg. printing help + or listing errors. So add new attribute for CmdLineParser to track + use of these options and exit before checking files when the + attribute is set. + +2011-01-27 Kimmo Varis + + * gui/erroritem.cpp: Fix formatting of debug messages to log view. Ticket #2513 (GUI: Garbage printed to log after missing include + warning) The linenumber was not properly converted to the QString so there + were garbage printed to the log. + +2011-01-26 Kimmo Varis + + * gui/mainwindow.cpp: GUI: Enable warnings about missing include + files. + +2011-01-26 Sébastien Debrard + + * lib/checkother.cpp: runastyle + +2011-01-26 Sébastien Debrard + + * lib/checkother.cpp, test/testother.cpp: fix #2510 Improve check + 'sizeof for array given as function argument' + +2011-01-26 Sébastien Debrard + + * lib/checkother.cpp: typo: message + +2011-01-25 Tim Gerundt + + * htdocs/index.php, htdocs/site/css/all.css: Web: Add "Download + Now!" link + +2011-01-25 Sébastien Debrard + + * : commit 4cf56dac2b421a2034fe37618fbf81a6f5e903b7 Author: + Sébastien Debrard Date: Tue Jan 25 + 09:57:58 2011 +0100 + +2011-01-24 Daniel Marjamäki + + * lib/checkother.cpp, lib/checkother.h, test/testother.cpp: Fixed + #2494 (New check: clarify calculation when using ?: operator) + +2011-01-24 Sébastien Debrard + + * lib/checkother.cpp, test/testother.cpp: fix ticket 155 - char + array + +2011-01-24 Daniel Marjamäki + + * cli/cmdlineparser.cpp: cleanup old ifdefs in cmdlineparser + +2011-01-23 Robert Reif + + * lib/symboldatabase.cpp: Symbol database: better handling of + functions returning function pointer. ticket: #2468 + +2011-01-23 Daniel Marjamäki + + * test/testuninitvar.cpp: when using TODO_ASSERT_EQUALS it's a good + idea to pair it with a ASSERT_EQUALS + +2011-01-23 Daniel Marjamäki + + * lib/tokenize.cpp: Tokenizer: Upon createLinks error, report error + and bailout + +2011-01-23 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #2376 + (simplifyTypedef: upx-ucl) + +2011-01-23 Robert Reif + + * lib/symboldatabase.cpp: Symbol database: fixed corruptions. + ticket: #2468 + +2011-01-23 Daniel Marjamäki + + * lib/checknullpointer.cpp, test/testnullpointer.cpp: Fixed #2493 + (false positive: (error) Possible null pointer dereference: pExpr) + +2011-01-22 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, lib/checkbufferoverrun.h, + test/testbufferoverrun.cpp: Fixed #1952 (false negative: buffer + acces out of bounds with memcpy) + +2011-01-22 Debrard Sébastien + + * lib/checkother.cpp, lib/checkother.h, test/testother.cpp: Fixed + #155 (check size of a variable whose type is a sized array) + +2011-01-22 Tim Gerundt + + * htdocs/site/js/github.js: Web: Tweak recent commits entries + +2011-01-22 Robert Reif + + * lib/symboldatabase.cpp, test/testconstructors.cpp: Symbol + database: match copy-constructor better. ticket: #2484 + +2011-01-22 Daniel Marjamäki + + * lib/checkclass.cpp: Class: better check if there are friends. + ticket: #2459 + +2011-01-22 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #2492 (False + positive: memory leak 'return &self->foo;') + +2011-01-22 Daniel Marjamäki + + * lib/checkclass.cpp, test/testunusedprivfunc.cpp: Fixed #2459 + (False positive with unused private function and friend) + +2011-01-22 Daniel Marjamäki + + * lib/tokenize.cpp: Fixed #2484 (false positive because template is + not instantiated properly) + +2011-01-22 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #2491 + (Tokenizer::setVarId : wrong handling of function call: 'a(b * c, + 1);') + +2011-01-22 Robert Reif + + * lib/symboldatabase.cpp: Symbol database: Fixed memory leak. + ticket: #2468 + +2011-01-22 Robert Reif + + * lib/tokenize.cpp: Tokenizer: Only create 1 symbol database. + ticket: #2468 + +2011-01-21 Ettl Martin + + * test/testsymboldatabase.cpp: fixed uninitialized members in tests + +2011-01-21 Daniel Marjamäki + + * Makefile, tools/dmake.cpp: dmake and Makefile updates + +2011-01-21 Robert Reif + + * lib/checkclass.cpp, test/testclass.cpp: Fixed #2478 (Crash when + trying to analyze files (CheckClass::checkReturnPtrThis)) + +2011-01-21 Daniel Marjamäki + + * Makefile: Makefile: updated with dmake + +2011-01-21 Robert Reif + + * lib/checkclass.cpp, lib/checkmemoryleak.cpp, lib/checkother.cpp, + lib/symboldatabase.cpp, lib/symboldatabase.h, lib/tokenize.cpp: + Symbol database: rename variables. ticket: #2468 + +2011-01-20 Daniel Marjamäki + + * lib/checkstl.cpp, test/teststl.cpp: Fixed #2488 (false positive + with updating iterator in a for loop) + +2011-01-20 Daniel Marjamäki + + * cli/cmdlineparser.cpp: CLI: updated help text for --inline-suppr. + Thanks rubicon_hdr for the suggestion + +2011-01-20 Daniel Marjamäki + + * lib/checkstl.cpp, test/teststl.cpp: Fixed #2481 (false positive + with break: After insert, the iterator '*' may be invalid) + +2011-01-20 Robert Reif + + * lib/symboldatabase.cpp: Symbol database: refactoring of + classAndStructTypes parsing. ticket: #2468 + +2011-01-19 Daniel Marjamäki + + * lib/checkstl.cpp, test/teststl.cpp: Fixed #2481 (false positive + with 'break;': After insert, the iterator '*' may be invalid) + +2011-01-19 Daniel Marjamäki + + * test/testincompletestatement.cpp: added unit test for #2482 + +2011-01-19 Daniel Marjamäki + + * lib/checkother.cpp, test/testincompletestatement.cpp: Fixed #2462 + (false positive: (warning) Redundant code: Found a statement that + begins with numeric constant) + +2011-01-19 Pete Johns + + * lib/checkclass.cpp, test/testunusedprivfunc.cpp: Fixed #2480 + (false positive on unused private function) + +2011-01-19 Daniel Marjamäki + + * lib/symboldatabase.h: Fixed #2483 (SymbolDatabase compiler warning + (VS2008/VS2010)) + +2011-01-18 Kimmo Varis + + * cli/cppcheck.vcproj, cli/cppcheck.vcxproj, + cli/cppcheck.vcxproj.filters, test/test.vcproj, test/test.vcxproj, + test/test.vcxproj.filters: Update Visual Studio project files. Update Visual Studio 2008/2010 project files after moving + filelister* files from lib/ to cli/. + +2011-01-18 Kimmo Varis + + * Makefile, cli/cli.pro, cli/filelister.cpp, cli/filelister.h, + cli/filelister_unix.cpp, cli/filelister_unix.h, + cli/filelister_win32.cpp, cli/filelister_win32.h, lib/cppcheck.cpp, + lib/filelister.cpp, lib/filelister.h, lib/filelister_unix.cpp, + lib/filelister_unix.h, lib/filelister_win32.cpp, + lib/filelister_win32.h, lib/lib.pri, lib/tokenize.cpp, + test/test.pro, tools/Makefile, tools/dmake.cpp: Move filelister* to + cli. Ticket #2445 (Move FileLister classes from LIB to CLI). + +2011-01-18 Kimmo Varis + + * lib/filelister.h, lib/filelister_unix.cpp, lib/filelister_unix.h, + lib/filelister_win32.cpp, lib/filelister_win32.h, lib/path.cpp, + lib/path.h, lib/tokenize.cpp: Move sameFileName() method to Path + class. Ticket #2445 (Move FileLister classes from LIB to CLI). Moving + sameFileName() to Path allows moving FileLister* classes to CLI. + +2011-01-18 Pete Johns + + * test/testunusedprivfunc.cpp: Added testDoesNotIdentifyCallback for + #2480 TODO + +2011-01-18 Pete Johns + + * : commit ea01c04108052921e29b81b84b6497c8670f2107 Author: Pete + Johns Date: Tue Jan 18 21:07:33 2011 +1100 + +2011-01-18 Pete Johns + + * lib/symboldatabase.cpp: Refactored to remove code duplication. + +2011-01-18 Pete Johns + + * lib/symboldatabase.cpp, test/testsymboldatabase.cpp: Made + isVariableDeclarationIdentifiesTemplatedPointerToPointerVariable() + pass. And added isVariableDeclarationIdentifiesTemplatedArrayVariable() + (passing) into the bargain. + +2011-01-18 Pete Johns + + * test/testsymboldatabase.cpp: Added TODO test cases for template + variables with multiple levels of pointer indirection Following email from Robert Reif + +2011-01-18 Robert Reif + + * lib/checkclass.cpp, lib/checkclass.h, test/testconstructors.cpp: + Fixed #2474 (false positive: Member variable 'A::m_SemVar' is not + initialised in the constructor.) + +2011-01-18 Robert Reif + + * lib/checkclass.cpp, lib/checkmemoryleak.cpp, + lib/symboldatabase.cpp, lib/symboldatabase.h: Symbol database: + Refactor the variables API. ticket: #2468 + +2011-01-17 Daniel Marjamäki + + * lib/checkother.cpp, test/testother.cpp: Fixed #2475 (False + positive in structure initialisation: The scope of the variable bits + can be reduced) + +2011-01-17 Kimmo Varis + + * cli/cmdlineparser.cpp, test/testcmdlineparser.cpp: Improve + checking -D arguments for command line. + +2011-01-17 Kimmo Varis + + * cli/cmdlineparser.cpp, test/testcmdlineparser.cpp: Fix crash when + giving -D without argument. Fixes ticket #2476 (Crash when -D used without parameters.) + +2011-01-17 Daniel Marjamäki + + * lib/checknullpointer.cpp, lib/checknullpointer.h, + lib/checkuninitvar.cpp, test/testnullpointer.cpp: Fixed #2467 (false + positive: possible nullptr dereference) + +2011-01-17 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #2473 (False + positive: Memory leak when there is local struct) + +2011-01-17 Robert Reif + + * lib/checkclass.cpp, lib/checkclass.h, lib/checkmemoryleak.cpp, + lib/checkmemoryleak.h, lib/checkother.cpp, lib/symboldatabase.cpp, + lib/symboldatabase.h, lib/tokenize.cpp, test/testsymboldatabase.cpp: + Symbol database: renamed classes. ticket: #2468 + +2011-01-17 Robert Reif + + * lib/checkclass.cpp, lib/checkclass.h, lib/checkmemoryleak.cpp, + lib/checkmemoryleak.h, lib/checkother.cpp, lib/symboldatabase.cpp, + lib/symboldatabase.h, lib/tokenize.cpp, test/testsymboldatabase.cpp: + Symbol database: pulled out classes into global scope. ticket: #2468 + +2011-01-16 Zachary Blair + + * lib/checkother.cpp: Fixed #2457 + (CheckOther::checkIncorrectLogicOperator: hang if variable id is 0) + +2011-01-17 Pete Johns + + * lib/preprocessor.cpp: Fixed gcc warning. + +2011-01-02 Pete Johns + + * lib/symboldatabase.cpp, lib/symboldatabase.h, + test/testsymboldatabase.cpp: isVariableDeclaration() now detects + template variables. + +2011-01-01 Pete Johns + + * lib/symboldatabase.cpp, lib/symboldatabase.h, test/testclass.cpp, + test/testsymboldatabase.cpp: Moved array declaration detection into + isVariableDeclaration() + +2011-01-16 Daniel Marjamäki + + * lib/checkautovariables.cpp, lib/checkother.cpp, + lib/symboldatabase.cpp, lib/symboldatabase.h: Refactoring: Check if + type is class/struct through symbol database + +2011-01-16 Daniel Marjamäki + + * lib/checkother.cpp, test/testcppcheck.cpp: Fixed #2302 (Duplicate + id 'unusedVariable') + +2011-01-16 Robert Reif + + * lib/checkclass.cpp, lib/checkclass.h, lib/checkmemoryleak.cpp, + lib/checkmemoryleak.h, lib/checkother.cpp, lib/tokenize.cpp, + lib/tokenize.h: Symbol database: increased constness. ticket: #2468 + +2011-01-16 Daniel Marjamäki + + * cli/cppcheckexecutor.cpp, cli/cppcheckexecutor.h, + lib/cppcheck.cpp: cppcheck: output errorlist to stdout + +2011-01-16 Daniel Marjamäki + + * test/testcppcheck.cpp: testcppcheck: check that + Cppcheck::getErrorMessages output is not empty + +2011-01-16 Daniel Marjamäki + + * test/testcppcheck.cpp: testcppcheck: test + Cppcheck::getErrorMessages + +2011-01-16 Daniel Marjamäki + + * test/testcppcheck.cpp: testcppcheck: cleanup + +2011-01-16 Robert Reif + + * lib/checkclass.cpp, lib/checkclass.h, lib/symboldatabase.cpp, + lib/symboldatabase.h: Symbol database: Refactorings. Move + check-specific code to check. Ticket: #2468 + +2011-01-16 Daniel Marjamäki + + * test/testcppcheck.cpp: testcppcheck: removed 'parseArgsAndCheck' + and 'parseOutputtingArgs'. Such tests belong to testcmdlineparser + +2011-01-16 Daniel Marjamäki + + * test/testcppcheck.cpp: testcppcheck: removed nonexistingpath and + include tests. The Cppcheck class doesn't handle this. + +2011-01-16 Daniel Marjamäki + + * test/testcppcheck.cpp: testcppcheck: the xml and template output + is tested in testerrorlogger instead + +2011-01-16 Daniel Marjamäki + + * test/testcppcheck.cpp: testcppcheck: the testcmdlineparser tests + invalid command line arguments + +2011-01-16 Daniel Marjamäki + + * test/testcppcheck.cpp: testcppcheck: linenumbers are tested in the + other tests + +2011-01-16 Daniel Marjamäki + + * test/testcppcheck.cpp: testcppcheck: command line parsing of -D is + tested in testcmdlineparser.cpp + +2011-01-16 Daniel Marjamäki + + * test/testcppcheck.cpp: testcppcheck: parsing templates is tested + in testcmdlineparser.cpp + +2011-01-16 Tim Gerundt + + * htdocs/devinfo/index.php, htdocs/site/js/github.js: Web: Add + recent commits to devinfo page + +2011-01-16 Daniel Marjamäki + + * lib/checkclass.cpp, test/testunusedprivfunc.cpp: Fixed #2407 + (False positive: unused private function) + +2011-01-16 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #2449 (segfault in + tokenize.cpp, incorrect parsing) + +2011-01-16 Raphael Geissert + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Tokenizer: simplify + restrict + +2011-01-16 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #980 (false + negative: division by zero when using enum) + +2011-01-16 Robert Reif + + * lib/checkclass.cpp, lib/checkclass.h, lib/symboldatabase.cpp, + lib/symboldatabase.h, test/testclass.cpp: Symbol database: + Refactorings + +2011-01-16 Daniel Marjamäki + + * lib/checkmemoryleak.cpp: astyle formatting + +2011-01-16 Daniel Marjamäki + + * lib/checkmemoryleak.cpp: Memory leaks: Optimised and refactored + +2011-01-15 Daniel Marjamäki + + * lib/checkstl.cpp: STL: Optimised checking + +2011-01-15 Daniel Marjamäki + + * lib/checkother.cpp: fixed unit test + +2011-01-15 Daniel Marjamäki + + * lib/checkother.cpp, lib/checkother.h: Optimising: about 5% + improvement with Visual Studio executable + +2011-01-15 Daniel Marjamäki + + * lib/checknullpointer.cpp, test/testnullpointer.cpp: Fixed #2463 + (false positive: possible nullpointer dereference) + +2011-01-15 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #2454 + (Tokenizer::simplifyKnownVariables: problem with float/double + variables) + +2011-01-15 Daniel Marjamäki + + * test/testtokenize.cpp: removed old comment + +2011-01-15 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #2466 + (Tokenizer: simplification of enum) + +2011-01-15 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #2464 (False + positive: not initialised/not assigned Static variable in copy + constructors.) + +2011-01-15 Robert Reif + + * lib/symboldatabase.cpp, lib/symboldatabase.h, test/testclass.cpp: + Fixed #2465 (False positive: not initialised variable, but there is + default constructor for it.) + +2011-01-14 Tim Gerundt + + * htdocs/index.php, htdocs/site/css/all.css, + htdocs/site/simplepie/LICENSE.txt, + htdocs/site/simplepie/README.txt, + htdocs/site/simplepie/cache/dummy.txt, + htdocs/site/simplepie/simplepie.inc: Web: Add News to homepage + +2011-01-14 Daniel Marjamäki + + * lib/checkstl.cpp, test/teststl.cpp: Fixed #2451 (False positive + when incrementing map value via iterator) + +2011-01-14 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #2452 (syntax + error when 'void f(typedef int x)' is used. causes segmentation + fault.) + +2011-01-13 Kimmo Varis + + * gui/settingsdialog.cpp: GUI: Fix compiler warning from GCC. Thanks for vBm for reporting this! + +2011-01-13 Kimmo Varis + + * lib/cppcheck.h: Fix doxgen comment. + +2011-01-13 Kimmo Varis + + * cli/cmdlineparser.cpp, cli/cppcheckexecutor.cpp: Add couple of + missing path separator conversions. + +2011-01-13 Kimmo Varis + + * lib/cppcheck.cpp, lib/cppcheck.h: Modify Cppcheck::addFile() only + take one file as a parameter. CLI and GUI already do the directory walking for us and we have list + of files to check. So we were duplicating this directory walking. + Practically doing check again for each file if it is a directory. + Which can take some time with large amount of files. + +2011-01-13 Daniel Marjamäki + + * lib/checkstl.cpp, test/teststl.cpp: Fixed #2450 (False positive + when iterator reused) + +2011-01-13 Daniel Marjamäki + + * lib/checkother.cpp, test/testincompletestatement.cpp: Fixed #2458 + (false positive: (warning) Redundant code: Found a statement that + begins with numeric constant) + +2011-01-12 Zachary Blair + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #2434 (FP + memleakOnRealloc) + +2011-01-11 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, lib/checkmemoryleak.h, + test/testmemleak.cpp: Fixed #2440 (False negative: basic memory + leak) + +2011-01-11 Kimmo Varis + + * cli/cmdlineparser.cpp, cli/cppcheckexecutor.cpp, + lib/preprocessor.cpp, test/testcmdlineparser.cpp: Accept include + paths ending with backslash. Convert include path to use internal path separators when parsing + command line. Convert back to native separators when using paths. Ticket #2448 (Error in handling -I command line parameter) + +2011-01-11 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #2296 (Tokenizer: + simplifyKnownVariable doesn't simplify pointer properly 'delete [] + p;') + +2011-01-11 Tim Gerundt + + * htdocs/devinfo/index.php: Web: Add Atom link to Recent Commits to + cppcheck:master + +2011-01-10 Daniel Marjamäki + + * scripts/define.pl: scripts: Added define.pl that warns if #define + is used. Related with ticket #689 + +2011-01-10 Daniel Marjamäki + + * htdocs/build.bat: removed unused htdocs/build.bat + +2011-01-10 Daniel Marjamäki + + * lib/checknullpointer.cpp, test/testnullpointer.cpp: Fixed #2443 + (Possible null pointer dereference: xxx - otherwise it is redundant + to check if xxx is null at line) + +2011-01-10 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #2442 (False + positive: Memory leak when function returns in 'if' instead of 'else + if') + +2011-01-10 Kimmo Varis + + * gui/cppcheck_de.ts, gui/cppcheck_en.ts, gui/cppcheck_fi.ts, + gui/cppcheck_ja.ts, gui/cppcheck_nl.ts, gui/cppcheck_pl.ts, + gui/cppcheck_ru.ts, gui/cppcheck_se.ts, gui/cppcheck_sr.ts: GUI: + Update translation files. + +2011-01-10 Kimmo Varis + + * gui/main.ui, gui/mainwindow.cpp, gui/mainwindow.h: GUI: Remove + Language-menu. We now have language selection in Settings-dialog. + +2011-01-10 Kimmo Varis + + * gui/mainwindow.cpp, gui/settings.ui, gui/settingsdialog.cpp, + gui/settingsdialog.h, gui/translationhandler.cpp: GUI: Add language + selection panel to settings-dialog. Settings-dialog is more natural place for language selection than + the main menu. We also have more space and freedom there to have + longer text etc to make the selection easier (menus are quite + limited controls). + +2011-01-09 Reijo Tomperi + + * cli/cmdlineparser.cpp, cli/cmdlineparser.h, + cli/cppcheckexecutor.cpp, cli/cppcheckexecutor.h, cli/main.cpp, + cli/threadexecutor.cpp, cli/threadexecutor.h, gui/aboutdialog.cpp, + gui/aboutdialog.h, gui/applicationdialog.cpp, + gui/applicationdialog.h, gui/applicationlist.cpp, + gui/applicationlist.h, gui/checkstatistics.cpp, + gui/checkstatistics.h, gui/checkthread.cpp, gui/checkthread.h, + gui/common.h, gui/csvreport.cpp, gui/csvreport.h, + gui/erroritem.cpp, gui/erroritem.h, gui/filelist.cpp, + gui/filelist.h, gui/fileviewdialog.cpp, gui/fileviewdialog.h, + gui/helpwindow.cpp, gui/helpwindow.h, gui/logview.cpp, + gui/logview.h, gui/main.cpp, gui/mainwindow.cpp, gui/mainwindow.h, + gui/project.cpp, gui/project.h, gui/projectfile.cpp, + gui/projectfile.h, gui/projectfiledialog.cpp, + gui/projectfiledialog.h, gui/report.cpp, gui/report.h, + gui/resultstree.cpp, gui/resultstree.h, gui/resultsview.cpp, + gui/resultsview.h, gui/settingsdialog.cpp, gui/settingsdialog.h, + gui/statsdialog.cpp, gui/statsdialog.h, gui/threadhandler.cpp, + gui/threadhandler.h, gui/threadresult.cpp, gui/threadresult.h, + gui/translationhandler.cpp, gui/translationhandler.h, + gui/txtreport.cpp, gui/txtreport.h, gui/xmlreport.cpp, + gui/xmlreport.h, lib/check.h, lib/checkautovariables.cpp, + lib/checkautovariables.h, lib/checkbufferoverrun.cpp, + lib/checkbufferoverrun.h, lib/checkclass.cpp, lib/checkclass.h, + lib/checkexceptionsafety.cpp, lib/checkexceptionsafety.h, + lib/checkmemoryleak.cpp, lib/checkmemoryleak.h, + lib/checknullpointer.cpp, lib/checknullpointer.h, + lib/checkobsoletefunctions.cpp, lib/checkobsoletefunctions.h, + lib/checkother.cpp, lib/checkother.h, lib/checkpostfixoperator.cpp, + lib/checkpostfixoperator.h, lib/checkstl.cpp, lib/checkstl.h, + lib/checkuninitvar.cpp, lib/checkuninitvar.h, + lib/checkunusedfunctions.cpp, lib/checkunusedfunctions.h, + lib/cppcheck.cpp, lib/cppcheck.h, lib/errorlogger.cpp, + lib/errorlogger.h, lib/executionpath.cpp, lib/executionpath.h, + lib/filelister.cpp, lib/filelister.h, lib/filelister_unix.cpp, + lib/filelister_unix.h, lib/filelister_win32.cpp, + lib/filelister_win32.h, lib/mathlib.cpp, lib/mathlib.h, + lib/path.cpp, lib/path.h, lib/preprocessor.cpp, lib/preprocessor.h, + lib/settings.cpp, lib/settings.h, lib/symboldatabase.cpp, + lib/symboldatabase.h, lib/timer.cpp, lib/timer.h, lib/token.cpp, + lib/token.h, lib/tokenize.cpp, lib/tokenize.h, man/cppcheck.1.xml, + test/testautovariables.cpp, test/testbufferoverrun.cpp, + test/testcharvar.cpp, test/testclass.cpp, + test/testcmdlineparser.cpp, test/testconstructors.cpp, + test/testcppcheck.cpp, test/testdivision.cpp, + test/testerrorlogger.cpp, test/testexceptionsafety.cpp, + test/testfilelister_unix.cpp, test/testincompletestatement.cpp, + test/testmathlib.cpp, test/testmemleak.cpp, + test/testnullpointer.cpp, test/testobsoletefunctions.cpp, + test/testother.cpp, test/testpath.cpp, + test/testpostfixoperator.cpp, test/testpreprocessor.cpp, + test/testrunner.cpp, test/testsettings.cpp, + test/testsimplifytokens.cpp, test/teststl.cpp, test/testsuite.cpp, + test/testsuite.h, test/testsymboldatabase.cpp, + test/testthreadexecutor.cpp, test/testtoken.cpp, + test/testtokenize.cpp, test/testuninitvar.cpp, + test/testunusedfunctions.cpp, test/testunusedprivfunc.cpp, + test/testunusedvar.cpp, test/testutils.h, tools/dmake.cpp: Change + year 2010 -> 2011 in license texts. + +2011-01-09 Daniel Marjamäki + + * lib/checknullpointer.cpp, test/testnullpointer.cpp: Fixed #1219 + (improve check: null pointer not detected 'if (p) return; *p = 0;') + +2011-01-09 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, test/testbufferoverrun.cpp: Fixed + #2211 (false negative: buffer access out of bounds for(int i=0; i + !=6;i++)) + +2011-01-09 Daniel Marjamäki + + * test/testtokenize.cpp: astyle formatting + +2011-01-09 Tim Gerundt + + * htdocs/devinfo/index.php: Web: Change title from devinfo page + +2011-01-09 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #2429 (Tokenizer: + Wrong simplification of 'sizeof .1250E+04') + +2011-01-09 Daniel Marjamäki + + * cli/cmdlineparser.cpp, cli/cppcheckexecutor.cpp, + lib/filelister.h, lib/filelister_unix.cpp, lib/filelister_unix.h, + lib/filelister_win32.cpp, lib/filelister_win32.h: Fixed #2409 (print + a warning if provided path (commandline option -I [PATH]) does not + exist) + +2011-01-08 Tim Gerundt + + * htdocs/index.php: Web: Add RSS link to project news + +2011-01-08 Tim Gerundt + + * htdocs/site/css/all.css: Web: Tweak style sheets for printing + +2011-01-08 Tim Gerundt + + * htdocs/index.php: Web: Add meta description to homepage + +2011-01-08 Daniel Marjamäki + + * lib/checknullpointer.cpp, test/testnullpointer.cpp: Fixed #2437 + (false positive: possible null pointer dereference: tok2) + +2011-01-08 Tim Gerundt + + * htdocs/devinfo/index.php: Web: Add "Source Code" paragraph to + devinfo page + +2011-01-08 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Error message: + Replace " with ' around variable name + +2011-01-08 Daniel Marjamäki + + * man/buildman.sh: buildman: build writing-rules-3.pdf + +2011-01-08 Daniel Marjamäki + + * man/writing-rules-3.docbook: Writing rules: minor tweak for the + C++ intro + +2011-01-08 Daniel Marjamäki + + * man/writing-rules-3.docbook: Writing rules: Added one more example + for the C++ intro + +2011-01-08 Daniel Marjamäki + + * lib/checkother.cpp: Fixed #2433 (strtol: false positive when + strtol isn't used in function call) + +2011-01-07 Daniel Marjamäki + + * gui/erroritem.h, lib/filelister_win32.cpp, lib/preprocessor.cpp: + astyle formatting + +2011-01-07 Daniel Marjamäki + + * lib/checkexceptionsafety.cpp, test/testexceptionsafety.cpp: Fixed + #2428 (false alarm with code containing a throw clause) + +2011-01-07 Daniel Marjamäki + + * lib/preprocessor.cpp: Preprocessor: fix bug when determining + location when there is a missing include. ticket: #2326 + +2011-01-07 Robert Reif + + * test/testclass.cpp: Fixed #2425 (segmentation fault of cppcheck) + +2011-01-07 Tim Gerundt + + * : commit 9fbbb910901ba2df61b79799024efeae34a8d415 Author: Tim + Gerundt Date: Fri Jan 7 16:04:01 2011 +0100 + +2011-01-07 Tim Gerundt + + * htdocs/.htaccess, htdocs/devinfo/index.php, htdocs/index.php: Web: + Move devinfo.html to a new place + +2011-01-07 Tim Gerundt + + * htdocs/site/css/all.css: Web: Add separator to tab items + +2011-01-07 Tim Gerundt + + * htdocs/index.php, htdocs/site/css/all.css: Web: Move style sheets + to own file + +2011-01-07 Ettl Martin + + * lib/filelister_win32.cpp, test/testmathlib.cpp: #ticket 2429: + added a test to the mathlib to ensure the used floating point number + is recognized correctly + +2011-01-07 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #2426 (### + Internal error in Cppcheck. Please report it.) + +2011-01-07 Robert Reif + + * lib/symboldatabase.cpp: Fixed #2425 (segmentation fault of + cppcheck) + +2011-01-06 Daniel Marjamäki + + * scripts/comment.pl: scripts: update 'comment.pl' so it understand + /* + +2011-01-06 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Tokenizer: simplify NULL + to 0 in the normal token list + +2011-01-06 Daniel Marjamäki + + * lib/preprocessor.cpp, lib/preprocessor.h: Preprocessor: Reverted + fix for #2131, it didn't work well so a better fix is needed + +2011-01-06 Kimmo Varis + + * gui/erroritem.h: GUI: Add comment about storing paths. + +2011-01-06 Kimmo Varis + + * gui/resultstree.cpp: GUI: Convert path to native separators before + copying it. Ticket #2424 (Windows GUI: "Copy full path" doesn't copy the visible + full path if it has been changed in preferences) We keep paths internally with / separator and only convert to native + separators (for Windows) when showing them. Conversion was missing + from path copying function. + +2011-01-06 Daniel Marjamäki + + * lib/checkother.cpp, test/testother.cpp: memsetZeroBytes: improved + error message. ticket: #2421 + +2011-01-06 Tim Gerundt + + * : commit 70a29ccb8a5e5a40435b5c00c3755aaaa9ad21d2 Author: Tim + Gerundt Date: Thu Jan 6 13:32:04 2011 +0100 + +2011-01-06 Daniel Marjamäki + + * lib/checknullpointer.cpp: Null pointers: Added comments + +2011-01-06 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp: Buffer overrun: Added comments + +2011-01-06 Daniel Marjamäki + + * scripts/comment.pl: scripts: reduced false positives given by + 'comments.pl'. given when declaring operator= + +2011-01-06 Daniel Marjamäki + + * lib/checkstl.cpp: CheckStl: Added comments + +2011-01-06 Daniel Marjamäki + + * lib/tokenize.cpp: Tokenizer: simple refactorings. and added a few + comments + +2011-01-06 Daniel Marjamäki + + * test/testother.cpp: astyle formatting + +2011-01-06 Raphael Geissert + + * lib/checkother.cpp, lib/checkother.h, test/testother.cpp: [PATCH] + Check for calls to memset() where 0 bytes are to be filled Inspired + by Silvio Cesare's work + +2011-01-06 Daniel Marjamäki + + * scripts/magic-numbers.pl: scripts: improved the 'magic-numbers.pl' + script + +2011-01-06 Daniel Marjamäki + + * lib/checknullpointer.cpp, test/testnullpointer.cpp: Fixed #2413 + (fflush() with NULL argument is valid.) + +2011-01-06 Robert Reif + + * lib/symboldatabase.cpp, test/testclass.cpp: Fixed #2415 (false + positive: Member variable not initialized in constructor calling + assignment operator) + +2011-01-06 Robert Reif + + * test/testsimplifytokens.cpp: typedef: fixed problem. ticket: #2414 + +2011-01-05 Kimmo Varis + + * gui/mainwindow.cpp: GUI: Enable information messages. Dan added new enable-flag for information messages in commit + 033e759. Enable that flag for GUI so that the information messages + are visible in the GUI. + +2011-01-05 Daniel Marjamäki + + * lib/checknullpointer.cpp, test/testnullpointer.cpp: Fixed #2411 + (possible null pointer dereference (aborting via function pointer + not detected)) + +2011-01-05 Daniel Marjamäki + + * cli/cmdlineparser.cpp, lib/checkclass.cpp, lib/checkother.cpp, + lib/settings.cpp, test/testclass.cpp, test/testother.cpp: command + line: added 'information' id to enable + +2011-01-05 Daniel Marjamäki + + * lib/checkuninitvar.cpp, test/testuninitvar.cpp: Fixed #2401 (false + positive: Uninitialized variable: result) + +2011-01-05 Daniel Marjamäki + + * lib/executionpath.cpp, test/teststl.cpp, test/testuninitvar.cpp: + Uninitialized variables. Fixed false positive when there are + multiple related conditions. ticket: #2399 + +2011-01-05 Tim Gerundt + + * : commit a0d62e041f426e2c4ce14c5e2880f96dcfb2d4f6 Author: Daniel + Marjamäki Date: Wed Jan 5 19:38:22 2011 + +0100 + +2011-01-05 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #2412 + (typedef: struct with inheritance) + +2011-01-05 Robert Reif + + * lib/tokenize.cpp: typedef: better handling. ticket: #2414 + +2011-01-05 Zachary Blair + + * lib/checkobsoletefunctions.h: Removed an unnecessary newline in + the message. Ticket #2343 + +2011-01-04 Zachary Blair + + * lib/checkobsoletefunctions.h: Fixed #2343 (The ftime obsolete + function warning seems wrong) + +2011-01-05 Tim Gerundt + + * htdocs/index.php: Web: Add a first version of a website + +2011-01-04 Kimmo Varis + + * lib/checkstl.cpp, test/teststl.cpp: Improve suspicious condition + (string::find) message. See forum thread: + https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192 + +2011-01-04 Kimmo Varis + + * lib/checkstl.cpp, test/teststl.cpp: Improve dangerous iterator + usage (after erase()) message. See forum thread: + https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192 + +2011-01-03 Kimmo Varis + + * lib/checkbufferoverrun.cpp, test/testbufferoverrun.cpp: Improve + strncat 3rd parameter usage warning message. See forum thread: + https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192 + +2011-01-04 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp, + test/testtokenize.cpp: Fixed #2399 + (Tokenizer::simplifyKnownVariables: variables in conditions) + +2011-01-04 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #2398 (false + positive: Uninitialized variable) + +2011-01-04 Daniel Marjamäki + + * scripts/comment.pl, scripts/magic-numbers.pl, scripts/readme.txt: + scripts: added a two simple perl scripts for checking code. + +2011-01-04 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp: Fixed #2393 (Token::Match called with + varid 0) + +2011-01-04 Daniel Marjamäki + + * : commit 85897c3991cacbceab2d121b989d6de9664f9f76 Merge: 45b6d09 + 2b1ec9a Author: Daniel Marjamäki + Date: Tue Jan 4 18:17:39 2011 +0100 + +2011-01-04 Daniel Marjamäki + + * man/writing-rules-3.docbook: Writing rules: Added part 3. + Introduction to writing rules with C++. + +2011-01-04 Robert Reif + + * lib/tokenize.cpp, lib/tokenize.h, test/testsimplifytokens.cpp: + typedef: delete unhandled typedefs. ticket: #2348 + +2011-01-04 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: typedef: fix + testcase 4. ticket: #2375 + +2011-01-04 Robert Reif + + * lib/tokenize.cpp: Fixed #2400 (Tests crashing in Windows) + +2011-01-03 Raphael Geissert + + * lib/checkmemoryleak.cpp: Mention the name of the variable in the + inconclusive leak msg + +2011-01-03 Markus Elfring + + * lib/checkclass.cpp, test/testclass.cpp, test/testconstructors.cpp: + Fixed #2389 (mistakable warning from 'CheckClass::uninitVarError') + +2011-01-02 Raphael Geissert + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Simplify "x = + realloc (0, n);" to "x = malloc(n);" + +2011-01-02 Raphael Geissert + + * lib/tokenize.cpp: Move simplification of realloc after + simplification of math ops + +2011-01-02 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: typedef: Fixed + testcase. ticket: #2375 + +2011-01-02 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp: Buffer overruns: Added comments + +2011-01-02 Daniel Marjamäki + + * lib/preprocessor.cpp, test/testpreprocessor.cpp: Fixed #2392 + (Preprocessor: Wrong simplification of __VA_ARGS__) + +2011-01-02 Daniel Marjamäki + + * test/testpreprocessor.cpp: Added TODO testcase for ticket #2392 + (Preprocessor: Wrong simplification of __VA_ARGS__) + +2011-01-02 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #2391 + (cstdlib file and memory function check misbehavior) + +2011-01-02 Daniel Marjamäki + + * test/testsimplifytokens.cpp: typedef: added more tests. ticket: + #2375 + +2011-01-01 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, lib/checkbufferoverrun.h, + test/testbufferoverrun.cpp: Fixed #2215 (Improve check: Writing + outside malloc bounds not detected) + +2011-01-01 Daniel Marjamäki + + * lib/tokenize.cpp: typedef: don't simplify typedef after 'case'. it + means that there is a typedef and constant with the same names. + Ticket: #2386 + +2011-01-01 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #2246 + (Improve check: Memory leak, function is not noreturn if return + value is taken) + +2011-01-01 Daniel Marjamäki + + * lib/checkuninitvar.cpp: uninitialized variables: Added some + comments + +2011-01-01 Daniel Marjamäki + + * lib/checkclass.cpp, test/testclass.cpp: Fixed TODO testcase. Use + symbol database instead of token list. Ticket: #2375 + +2011-01-01 Daniel Marjamäki + + * lib/checkmemoryleak.cpp: Added comments in the memory leaks + checking + +2011-01-01 Daniel Marjamäki + + * lib/checkmemoryleak.cpp: Memory leaks: localized variables + +2011-01-01 Daniel Marjamäki + + * lib/tokenize.cpp: Tokenizer: Added more comments + +2011-01-01 Daniel Marjamäki + + * lib/tokenize.h: Tokenizer: Added doxygen comments + +2011-01-01 Daniel Marjamäki + + * lib/tokenize.h: Tokenizer: added doxygen comments + +2011-01-01 Daniel Marjamäki + + * Makefile, test/testcmdlineparser.cpp, test/testerrorlogger.cpp, + test/testfilelister_unix.cpp, test/testpreprocessor.cpp, + test/testtoken.cpp, tools/dmake.cpp: gcc: disabled -Wconversion + again - too many warnings + +2010-12-31 Zachary Blair + + * lib/checkother.cpp: Fixed #2382 (Catching exceptions by value + instead of reference) + +2010-12-31 Daniel Marjamäki + + * lib/executionpath.cpp, lib/tokenize.cpp, + test/testbufferoverrun.cpp: Fixed #2386 (segmentation fault occurs + in the checking when typedef has same name as an enum constant) + +2010-12-31 Daniel Marjamäki + + * lib/checknullpointer.cpp, lib/checknullpointer.h: Null Pointer: + Refactoring - broke out CheckNullPointer::isPointer + +2010-12-31 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, test/testbufferoverrun.cpp: Fixed + #2378 (Refactoring: create utility function that skips redundant + if/for/while) + +2010-12-31 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, test/testbufferoverrun.cpp: Fixed + #2385 (False positive: array index out of bounds) + +2010-12-31 Daniel Marjamäki + + * lib/checknullpointer.cpp: astyle formatting + +2010-12-31 Daniel Marjamäki + + * lib/checknullpointer.cpp: added more comments + +2010-12-31 Daniel Marjamäki + + * lib/checknullpointer.cpp: Added comments for + CheckNullPointer::nullPointerLinkedList + +2010-12-31 Daniel Marjamäki + + * lib/checknullpointer.cpp: Remove redundant condition + +2010-12-31 Daniel Marjamäki + + * lib/checknullpointer.cpp: gcc: fixed compiler warning (suggest + parantheses around assignment) + +2010-12-31 Daniel Marjamäki + + * lib/checknullpointer.cpp: Refactoring and commenting + CheckNullPointer::nullPointerAfterLoop + +2010-12-31 Daniel Marjamäki + + * lib/checknullpointer.h: added doxygen comments + +2010-12-31 Daniel Marjamäki + + * lib/checkexceptionsafety.cpp, lib/checkexceptionsafety.h: added + some comments + +2010-12-31 Pete Johns + + * lib/symboldatabase.cpp, lib/symboldatabase.h, test/testclass.cpp, + test/testsymboldatabase.cpp: Fixed #2384 ("The function 's::f' can + be const" reported for pointer-to-pointer) Moved check for pointer variables into isVariableDeclaration() Can now handle multiple scopes and multiple levels of indirection. + Simplified check for strucs and unions, too, reducing the size of + getVarList(). skipScopeIdentifiers() and skipPointers() should probably be methods + on class Token. + +2010-12-31 Daniel Marjamäki + + * cli/threadexecutor.cpp: testrunner: fix runtime problems with + TestThreadExecutor + +2010-12-31 Zachary Blair + + * lib/checkother.cpp, lib/checkother.h, test/testother.cpp: Fixed + #2382 (Catching exceptions by value instead of reference) + +2010-12-31 Daniel Marjamäki + + * cppcheck.cbproj, cppcheck.sln, lib/cppcheck.cpp, + lib/symboldatabase.h, lib/tokenize.cpp: Borland C++: Fixed compiler + errors + +2010-12-31 Daniel Marjamäki + + * cli/threadexecutor.cpp, lib/checkbufferoverrun.cpp, + lib/checkuninitvar.cpp, lib/tokenize.cpp: gcc: fixed -Wconversion + errors + +2010-12-31 Daniel Marjamäki + + * lib/symboldatabase.h: gcc: Fixed -Wconversion warnings in symbol + database + +2010-12-31 Daniel Marjamäki + + * lib/tokenize.cpp: gcc: fixed -Wconversion warnings in tokenizer + +2010-12-31 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, lib/checkbufferoverrun.h: gcc: fixed + -Wconversion warnings + +2010-12-30 Daniel Marjamäki + + * Makefile, test/testmathlib.cpp, test/testsuite.cpp, + test/testsuite.h, tools/dmake.cpp: Added -Wconversion compiler flag. + The ASSERT_EQUALS_DOUBLE was added that can be used when comparing + double values. + +2010-12-30 Daniel Marjamäki + + * lib/checkstl.cpp: improved TODO comments + +2010-12-30 Daniel Marjamäki + + * lib/checkstl.cpp: CheckStl: Added comments + +2010-12-30 Daniel Marjamäki + + * lib/settings.h, lib/tokenize.h: fixed doxygen warnings + +2010-12-30 Daniel Marjamäki + + * lib/cppcheck.cpp: gcc: fixed compiler warning + +2010-12-30 Daniel Marjamäki + + * lib/errorlogger.cpp: Added comments + +2010-12-30 Daniel Marjamäki + + * cli/threadexecutor.cpp: usleep: use nanosleep instead of usleep as + the usleep is obsolete. Ticket: #2283 + +2010-12-30 Daniel Marjamäki + + * lib/checkuninitvar.cpp, test/testuninitvar.cpp: Uninitialized + variables: typeof doesn't dereference. Ticket: #2367 + +2010-12-30 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Tokenizer: Better + handling of duplicate enums. Ticket: #2381 + +2010-12-30 Daniel Marjamäki + + * man/writing-rules-2.docbook: writing rules #2: tweaks. published + +2010-12-30 Daniel Marjamäki + + * lib/checkpostfixoperator.cpp, test/testpostfixoperator.cpp: Fixed + #2321 (false positive: (performance) Prefer prefix ++/-- operators + for non-primitive types.) + +2010-12-30 Daniel Marjamäki + + * man/cppcheck-design.docbook: Cppcheck design: more tweaks + +2010-12-30 Daniel Marjamäki + + * man/writing-rules-1.docbook, man/writing-rules-2.docbook: writing + rules: more tweaks + +2010-12-30 Pete Johns + + * Makefile, lib/symboldatabase.cpp, lib/symboldatabase.h, + test/testsymboldatabase.cpp, test/testtoken.cpp, test/testutils.h: + Refactoring following #2377 (Technically the member function xxx can + be const) symboldatabase now recognises variables with arbitrarily many + scopes. Extracted method isVariableDeclaration() Added unit tests for isVariableDeclaration in new file + testsymboldatabase.cpp Extracted givenACodeSampleToTokenize helper class into testutils.h + to reduce duplication. + +2010-12-30 Pete Johns + + * lib/symboldatabase.cpp, test/testclass.cpp: Fixed #2377 + (Technically the member function xxx can be const) TODO: Add unit test for getVarList() and refactor variable check. [Removed my testcase for #2377 and removed two TODOs.] + +2010-12-30 Ettl Martin + + * test/testclass.cpp: const correctness: added further testcases for + increment/decrement member functions + +2010-12-30 Ettl Martin + + * test/testclass.cpp: ticket 2377: added further testcases + +2010-12-30 Ettl Martin + + * : commit c29824fc4936e100057d37393fcccdfd6bec8f5f Author: Ettl + Martin Date: Thu Dec 30 01:29:09 2010 +0100 + +2010-12-30 Pete Johns + + * build.txt: Added Mac OSX build instructins for PCRE. + +2010-12-29 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #2374 (False + 'memory leak' report (assigning to map in subfunction)) + +2010-12-29 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: simplifyTypedef: + Better handling of 'typedef int RexxFunctionHandler();'. Ticket: + #2348 + +2010-12-29 Robert Reif + + * lib/symboldatabase.cpp, lib/tokenize.cpp, test/testclass.cpp: + simplifyTypedef: operator typedef. Ticket: #2375 + +2010-12-29 Daniel Marjamäki + + * man/cppcheck-design.docbook: Cppcheck Design: some more tweaks + +2010-12-29 Daniel Marjamäki + + * cli/cmdlineparser.cpp, cli/cppcheckexecutor.cpp, lib/check.h, + lib/checkautovariables.h, lib/checkbufferoverrun.h, + lib/checkclass.h, lib/checkexceptionsafety.h, + lib/checkmemoryleak.h, lib/checknullpointer.h, + lib/checkobsoletefunctions.h, lib/checkother.h, + lib/checkpostfixoperator.h, lib/checkstl.h, lib/checkuninitvar.h, + lib/checkunusedfunctions.h, lib/cppcheck.cpp, lib/preprocessor.cpp, + lib/preprocessor.h, lib/tokenize.cpp, lib/tokenize.h, + test/testbufferoverrun.cpp: Fixed #2373 (Using XML2 in --errorlist + output) + +2010-12-29 Daniel Marjamäki + + * lib/checkother.cpp: Fixed #2372 (internal error in logicaloperator + check (varid=0)) + +2010-12-29 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: typedef: fixed + problem with 'typedef int pread_f(int);'. ticket: #2348 + +2010-12-28 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: typedef: fix + typedef simplification. ticket: #2348 + +2010-12-28 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, test/testbufferoverrun.cpp: Fixed + #2370 (false negative: Buffer access out-of-bounds (for with if, no + break)) + +2010-12-28 Daniel Marjamäki + + * man/buildman.sh, man/cppcheck-design-overview.docbook, + man/cppcheck-design.docbook: Cppcheck Design: updated article + +2010-12-28 Daniel Marjamäki + + * man/cppcheck-design-overview.docbook: Cppcheck Design Overview: + Added article + +2010-12-28 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #2355 + (simplifyTypedef: wrong simplification of 'typedef FMAC1 void + (*a)();') + +2010-12-28 Daniel Marjamäki + + * man/writing-rules-1.docbook, man/writing-rules-2.docbook, + man/writing-rules.docbook: Writing Rules: Added a second article + about writing rules that discuss the data representation + +2010-12-28 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #2354 + (simplifyTypedef: function pointers are not simplified into valid + code) + +2010-12-28 Pete Johns + + * test/testsuite.cpp, test/testsuite.h: Fixed #2360 (testrunner + fails to build in Mac OS X Leopard (10.5) - assert macro vs assert + method) Renamed assert to assert_. Tested with gcc v4.0.1 on Snow Leopard. + +2010-12-27 Daniel Marjamäki + + * lib/checkuninitvar.cpp, test/testuninitvar.cpp: Fixed #2367 (false + positive: (error) Uninitialized variable: s) + +2010-12-27 Daniel Marjamäki + + * lib/checkuninitvar.cpp, test/testuninitvar.cpp: Fixed #2367 (false + positive: (error) Uninitialized variable: s) + +2010-12-27 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp, test/testunusedvar.cpp: + Fixed #2368 (assigned a value that is never used) + +2010-12-27 Kimmo Varis + + * gui/settings.ui, gui/settingsdialog.cpp: GUI: Show ideal thread + count next to current thread count. Ideal thread count is determined by Qt as number of available cores. + Ticket: #2194 (Automatically match thread count to available cores) + +2010-12-27 Kimmo Varis + + * lib/checkother.cpp, test/testother.cpp: Change 'Scope of + variable'-message to information message. + +2010-12-27 Ettl Martin + + * test/testunusedvar.cpp: Created to testcase (#2368) for assigned a + value that is never used false positive + +2010-12-27 Daniel Marjamäki + + * lib/checkother.cpp: Fixed #2365 (Internal error: Token::Match + called with varid 0) + +2010-12-27 Kimmo Varis + + * gui/cppcheck_de.ts, gui/cppcheck_en.ts, gui/cppcheck_fi.ts, + gui/cppcheck_ja.ts, gui/cppcheck_nl.ts, gui/cppcheck_pl.ts, + gui/cppcheck_ru.ts, gui/cppcheck_se.ts, gui/cppcheck_sr.ts: GUI: + Update translation files. + +2010-12-27 Kimmo Varis + + * gui/main.ui: GUI: Use simple "Errors" instead of "Common errors". We have only one "error" category nowadays so we don't need to + separate different error categories anymore. + +2010-12-27 Kimmo Varis + + * gui/main.ui: GUI: Improve toolbar button tooltips. + +2010-12-27 Kimmo Varis + + * gui/stats.ui: GUI: Fix EOL style of stats.ui. + +2010-12-27 Kimmo Varis + + * gui/stats.ui, gui/statsdialog.cpp: GUI: Add 'portability' warnings + to statistics-dialog. + +2010-12-27 Kimmo Varis + + * gui/common.h, gui/gui.qrc, gui/main.ui, gui/mainwindow.cpp, + gui/mainwindow.h, gui/resultstree.cpp: GUI: Add GUI for showing + 'portability' warnings. Add menuitem, icon and toolbar button for portability warnings. + Ticket #2359 (Gui: Show portability warnings). + +2010-12-27 Daniel Marjamäki + + * test/testclass.cpp: TestClass: addon for 12f28507, fix a few more + error messages. + +2010-12-27 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #2361 (false + positive on t[0X10]) + +2010-12-26 Kimmo Varis + + * gui/settings.ui: GUI: Fix building with Qt < 4.7.0. I accidentally added the 'placeholderText' attribute to settings.ui + when editing it with Qt Creator. That attribute was added in Qt + 4.7.0 and we are not using it for anything. So removing it to fix + building with older Qt versions. + +2010-12-26 Kimmo Varis + + * lib/checkclass.cpp, test/testclass.cpp: Improve the message about + const function. See discussion thread: + https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192 + +2010-12-26 Kimmo Varis + + * lib/checkstl.cpp, test/teststl.cpp: Improve message for container + type range check. See thread: + + https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192&start=0 + +2010-12-26 Kimmo Varis + + * lib/checkother.cpp, test/testother.cpp: Improve error message + about overlapping buffers for s[n]printf(). See forum thread: + + https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192&start=0 + +2010-12-26 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, lib/checkbufferoverrun.h, + test/testbufferoverrun.cpp: Buffer overrun: UB when pointer + arithmetic result points out of bounds. Ticket #1774 + +2010-12-26 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #2304 + (Tokenizer::simplifyKnownVariables: known strcpy parameter) + +2010-12-26 Daniel Marjamäki + + * lib/checknullpointer.cpp, test/testnullpointer.cpp: Fixed #2090 + (False negative: null pointer dereference 's=0; strcpy(s,p);') + +2010-12-26 Kimmo Varis + + * gui/settings.ui: GUI: Improve Preferences-dialog layout. Make threads-textfield smaller as it can contain only three numbers. + Also set the input mask so that three numbers at max are accepted. + +2010-12-26 Peter Pentchev + + * Makefile, tools/dmake.cpp: Makefile: honor the C preprocessor + flags in CPPFLAGS. Ticket: #2254 + +2010-12-26 Kimmo Varis + + * gui/mainwindow.cpp: GUI: zero is not valid value for bool type. + +2010-12-26 Kimmo Varis + + * gui/common.h: GUI: Reorder settings-constants in common.h It is easier to manage those constants when there is even some basic + ordering and organization. + +2010-12-26 Kimmo Varis + + * gui/common.h, gui/mainwindow.cpp, gui/settings.ui, + gui/settingsdialog.cpp: GUI: Allow enabling inline suppressions from + the GUI. Ticket #2342 (inline suppressions not available from the GUI) + +2010-12-26 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Tokenizer: Bailout if @ + is encountered in the code + +2010-12-26 Kimmo Varis + + * gui/stats.ui, gui/statsdialog.cpp: GUI: Show information messages + count in stats dialog. + +2010-12-26 Kimmo Varis + + * gui/main.ui, gui/mainwindow.cpp, gui/mainwindow.h, + gui/resultstree.cpp: GUI: Add "Information" errors items to menu and + toolbar. + +2010-12-26 Kimmo Varis + + * gui/gui.qrc, gui/main.ui, gui/resultstree.cpp: GUI: Change + Style-warnings icon. I want to use the current Style-warning icon for Information + messages. So change the Style-warning icon first to new icon. + +2010-12-26 Kimmo Varis + + * gui/checkstatistics.cpp, gui/checkstatistics.h, gui/common.h, + gui/mainwindow.cpp, gui/resultstree.cpp: GUI: Add + Information-severity support. + +2010-12-26 Daniel Marjamäki + + * lib/executionpath.cpp, test/testnullpointer.cpp: Fixed #2350 + (false positive: possible null pointer dereference) + +2010-12-26 Daniel Marjamäki + + * test/testfilelister_unix.cpp: astyle formatting + +2010-12-26 Pete Johns + + * lib/filelister_unix.cpp: Fixed Linux build. OSX built without limits.h + +2010-12-26 Pete Johns + + * Makefile, lib/filelister_unix.cpp, test/testfilelister_unix.cpp: + Fixed #2358 (Compilation fail on Mac) Added test case to prove it works. Not a true unit-test as it + accesses the file-system. + +2010-12-26 Daniel Marjamäki + + * lib/preprocessor.cpp: Fixed #2326 (Preprocessor: inline-suppr does + not work for id=missingInclude) + +2010-12-26 Pete Johns + + * lib/filelister_unix.cpp: canonicalize_file_name() is a + GNU-extension. Replaced with call to realpath() to build on non-Linux systems, such + as Mac OSX. + +2010-12-25 Daniel Marjamäki + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #2346 (False + positive: pointer is assigned value that is never used. used here: + 'pCol = pCol->GetNext()') + +2010-12-25 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #2339 + (Tokenizer::setVarId : Wrong handling of 'int gr = id - + (TLFPressProperties::OIL_FLUID * nb);') + +2010-12-25 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp, + test/testtokenize.cpp: Fixed #2353 + (Tokenizer::simplifyKnownVariables: wrong simplification after + return) + +2010-12-25 Daniel Marjamäki + + * lib/checkother.cpp, test/testother.cpp: Misused scope objects: + Don't use this check if the checked file is a pure C file. Ticket: + #2352 + +2010-12-24 Daniel Marjamäki + + * lib/errorlogger.cpp: Fixed #2349 (Empty 'msg' in output when using + '-j') + +2010-12-24 Daniel Marjamäki + + * lib/checkstl.cpp, lib/checkstl.h, test/teststl.cpp: Fixed #2356 + (False positive reported with iterator deletion) + +2010-12-23 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: + Tokenizer::simplifyGoto: Don't simplify 'goto' inside unhandled + macro calls. Ticket: #2348 + +2010-12-23 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Tokenizer: Fixed + calculation simplification of '0*(*p)'. Ticket: #2348 + +2010-12-23 Daniel Marjamäki + + * lib/checkuninitvar.cpp, test/testuninitvar.cpp: Fixed #2345 (False + positive: uninitialized variable (in sub-condition in if inside a + loop)) + +2010-12-22 Daniel Marjamäki + + * lib/filelister_unix.cpp, lib/filelister_unix.h: Fixed #2344 + (FileLister Unix: Don't convert to absolute paths) + +2010-12-22 Daniel Marjamäki + + * lib/checkclass.cpp, lib/errorlogger.h, lib/preprocessor.cpp, + test/testclass.cpp: Information: Added new severity + +2010-12-22 Daniel Marjamäki + + * lib/errorlogger.cpp: xml2: changed the format of the + cppcheck-version info + +2010-12-22 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #2341 (false + positive for function pointer returning typedef) + +2010-12-22 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #2337 (False + Positive: memory leak) + +2010-12-22 Daniel Marjamäki + + * lib/errorlogger.cpp, lib/errorlogger.h: xml2: Added + cppcheck-version + +2010-12-22 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #2338 (False + positive: Deallocating a deallocated pointer) + +2010-12-21 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #2336 (False + positive: memory leak (passing pointer to subfunction)) + +2010-12-21 Daniel Marjamäki + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #2330 + (unreadVariable error for a fstream object when only extraction + operator (>>) is used) + +2010-12-21 Robert Reif + + * lib/checkother.cpp, lib/symboldatabase.cpp, lib/symboldatabase.h, + test/testunusedvar.cpp: unused variables: fixed false negatives with + the help of the symbol database. ticket: #2317 + +2010-12-20 Daniel Marjamäki + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #2317 ((style) + Variable is allocated memory that is never used) + +2010-12-20 Daniel Marjamäki + + * lib/checkobsoletefunctions.h, test/testobsoletefunctions.cpp: + Fixed #2334 (Internal class index function (no need to 'strchr')) + +2010-12-19 Daniel Marjamäki + + * lib/checknullpointer.cpp: Fixed #2331 (Token::Match is called with + varid 0) + +2010-12-19 Daniel Marjamäki + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #2286 (Variable + 'ownKilled' is assigned a value that is never used) + +2010-12-19 Daniel Marjamäki + + * lib/filelister_unix.cpp: Fixed #2322 (cppcheck follows recursive + symlinks) + +2010-12-19 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, test/testbufferoverrun.cpp: Fixed + #2328 (false positive: buffer overrun (for loop with a break => the + end value is not reached)) + +2010-12-19 Daniel Marjamäki + + * cli/cppcheck.vcproj, cli/cppcheck.vcxproj, test/test.vcproj, + test/test.vcxproj, test/test.vcxproj.filters: Visual Studio: updated + project files with qmake + +2010-12-18 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #2325 + (Tokenizer: Remove for-loop if condition is false) + +2010-12-18 Robert Reif + + * lib/checkother.cpp: CheckOther: Use SymbolDatabase. Ticket: #2318 + +2010-12-18 Kimmo Varis + + * Makefile: Update Makefile. + +2010-12-18 Kimmo Varis + + * tools/dmake.cpp: Update dmake to use basepath in lib.pri. + +2010-12-18 Kimmo Varis + + * test/test.pro: Update test.pro for using base path for included + pri files. + +2010-12-18 Kimmo Varis + + * cli/cli.pro, gui/gui.pro, lib/lib.pri: Don't use relative paths in + lib.pri. Using relative path in included file binds it to be usable only + included from one directory. Instead use variable for giving the + base path for files. + +2010-12-18 Kimmo Varis + + * cli/cli.pro, externals/tinyxml/tinyxml.pri: Don't use relative + paths in tinyxml.pri. Using relative path in included file binds it to be usable only + included from one directory. Instead use variable for giving the + base path for files. + +2010-12-18 Kimmo Varis + + * externals/tinyxml/tinyxml.pri: Reformat tinyxml qmake file. Have one filename at one line. + +2010-12-18 Daniel Marjamäki + + * lib/preprocessor.cpp: Preprocessor: Report 'missing system + include' with debug severity. temporary solution until the handling + of system includes is better. + +2010-12-18 Daniel Marjamäki + + * test/test.pro: QMake: added test/test.pro + +2010-12-18 Kimmo Varis + + * cli/cli.pro: Add _CRT_SECURE_NO_WARNINGS for Windows CLI build. + +2010-12-18 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Tokenizer: better + handling for switch/break in the simplifyKnownVariables. Ticket: + #2324 + +2010-12-18 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, test/testbufferoverrun.cpp: Fixed + #2323 (false positive: Buffer access out of bounds) + +2010-12-18 Daniel Marjamäki + + * lib/checkuninitvar.cpp, test/testuninitvar.cpp: Fixed #2320 (false + positive: Uninitialized variable: kbuf) + +2010-12-18 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Tokenizer: Remove + redundant parantheses in rhs. Ticket: #2320 + +2010-12-17 Daniel Marjamäki + + * cli/cppcheck.vcproj, cli/cppcheck.vcxproj, + cli/cppcheck.vcxproj.filters, externals/tinyxml/tinyxml.pri, + lib/lib.pri: QMake: auto-generate the visual studio project files + with qmake + +2010-12-17 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #2313 (False + Positive: memory leak) + +2010-12-17 Daniel Marjamäki + + * test/testmemleak.cpp: checkmemoryleaks: added assertion for todo + assertion + +2010-12-17 Daniel Marjamäki + + * lib/checkuninitvar.cpp, test/testuninitvar.cpp: Fixed #2306 (False + positive: array of std::string is reported as uninitialized) + +2010-12-17 Daniel Marjamäki + + * lib/checknullpointer.cpp, test/testnullpointer.cpp: Fixed #2299 + (false positive: possible nullpointer dereference) + +2010-12-17 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #2307 (No + constructor defined false positive when class is enclosed in + namespace) + +2010-12-16 Daniel Marjamäki + + * lib/mathlib.h: removed the NOLONGLONG handling. it seems unlikely + it is needed + +2010-12-16 Daniel Marjamäki + + * lib/checknullpointer.cpp, test/testnullpointer.cpp: Fixed #2300 + (false positive: possible nullpointer dereference) + +2010-12-16 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #2301 (false + positive: The given size 3 is mismatching) + +2010-12-16 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #2311 (False + positive: Index out of bounds) + +2010-12-16 Daniel Marjamäki + + * test/testbufferoverrun.cpp: astyle formatting + +2010-12-16 Daniel Marjamäki + + * build.txt: build.txt: some updated instructions + +2010-12-16 Robert Reif + + * lib/checkother.cpp, lib/symboldatabase.cpp: Symbol database: reuse + in CheckOther. Ticket: #2318 + +2010-12-16 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #2314 (False + positive: (style) Template instantiation 'Foo' hides typedef with + same name) + +2010-12-15 Kimmo Varis + + * : commit ac8eb30d681c38f3951af77f410f18077b76b80b Author: Kimmo + Varis Date: Wed Dec 15 22:39:46 2010 +0200 + +2010-12-15 Ettl Martin + + * test/testpreprocessor.cpp: test:testpreprocessor.cpp; fixed broken + unit test due to wrong charcter encoding + +2010-12-15 Kimmo Varis + + * cli/cppcheck.vcxproj, cli/cppcheck.vcxproj.filters, + test/test.vcxproj, test/test.vcxproj.filters: Update VS2010 project + files for new TinyXml location. + +2010-12-15 Kimmo Varis + + * cli/cppcheck.vcproj, test/test.vcproj: Update VS2008 project files + for new TinyXml location. + +2010-12-15 Daniel Marjamäki + + * : Merge commit 'vBm/master' + +2010-12-15 Kimmo Varis + + * win_installer/cppcheck.wxs: Installer: Fix typo 'IntallationPath' + to 'InstallationPath'. + +2010-12-15 Kimmo Varis + + * win_installer/cppcheck.wxs: Installer: Add Japanese and Serbian + translation files. I forgot to add Japanese and Serbian translation files to the + Windows installer when adding them. + +2010-12-15 vBm + + * : commit 500c0a19c39ec8fdd434a0d6f97363f4db9b5275 Author: Zachary + Blair Date: Tue Dec 14 23:51:21 2010 + -0800 + +2010-12-14 vBm + + * : commit 05ebf120c3fd254ea1c896e48017f3202d6ddcfb Author: Zachary + Blair Date: Tue Dec 14 00:16:26 2010 + -0800 + +2010-12-13 Daniel Marjamäki + + * createrelease: createrelease: Added comment to test 'cppcheck + --errorlist'. Ticket: #2292 + +2010-12-13 vBm + + * : commit 5ce63a1df0616e3d4e03841f45cb14caad361773 Author: Daniel + Marjamäki Date: Mon Dec 13 18:17:33 2010 + +0100 + +2010-12-13 vBm + + * man/manual.docbook: Change case for some standardized words + +2010-12-13 Ettl Martin + + * tools/dmake.cpp: fixed mistake from previous commit. changes path + from test/tinyxml to external/tinyxml; Thanks to kimmov. + +2010-12-13 Ettl Martin + + * tools/dmake.cpp: dmake: added test/tinyxml path to make clean + +2010-12-13 Kimmo Varis + + * gui/checkstatistics.cpp, gui/checkstatistics.h, gui/common.h, + gui/resultstree.cpp: GUI: Add partial support for portability + severity. Add 'backend' support for the new 'portability' severity. The new + severity is handled, converted to new SHOW_PORTABILITY and added + with correct type to the result view. There is no menuitem/toolbar button to show/hide portability items. + Likewise there is no line for portability issues in stats- dialog. Ticket #2106 (More severities and new xml format) + +2010-12-12 Daniel Marjamäki + + * cli/cli.pro, lib/lib.pri, tools/dmake.cpp: dmake: add include path + '../externals' to lib.pri in case the pcre.h is placed there. + +2010-12-12 Daniel Marjamäki + + * Makefile, build.txt, cli/cli.pro, cli/cmdlineparser.cpp, + externals/tinyxml/changes.txt, externals/tinyxml/tinystr.cpp, + externals/tinyxml/tinystr.h, externals/tinyxml/tinyxml.cpp, + externals/tinyxml/tinyxml.h, externals/tinyxml/tinyxml.pri, + externals/tinyxml/tinyxmlerror.cpp, + externals/tinyxml/tinyxmlparser.cpp, gui/gui.pro, lib/cppcheck.cpp, + lib/lib.pri, lib/settings.h, test/tinyxml/changes.txt, + test/tinyxml/tinystr.cpp, test/tinyxml/tinystr.h, + test/tinyxml/tinyxml.cpp, test/tinyxml/tinyxml.h, + test/tinyxml/tinyxmlerror.cpp, test/tinyxml/tinyxmlparser.cpp, + tools/dmake.cpp: Add support for user defined rules + +2010-12-12 Daniel Marjamäki + + * Makefile: Makefile: switch back to debug mode + +2010-12-12 Daniel Marjamäki + + * Makefile: 1.46: updated Makefile for release + +2010-12-12 Daniel Marjamäki + + * Changelog: 1.46: Updated Changelog + 2010-12-12 Daniel Marjamäki * cli/cppcheck.rc, cli/main.cpp, lib/cppcheck.cpp, @@ -1909,16 +4599,15 @@ 2010-10-14 Debrard Sebastien - * : commit fb928b67781e57348f62104b49d94099c825cc9c Merge: - d062980... 6c582f9... Author: Debrard Sebastien - Date: Thu Oct 14 19:08:31 2010 - +0200 + * : commit fb928b67781e57348f62104b49d94099c825cc9c Merge: d062980 + 6c582f9 Author: Debrard Sebastien + Date: Thu Oct 14 19:08:31 2010 +0200 2010-10-14 Debrard Sebastien - * : commit 6c582f9362ca13da701aa3b6b1ed6808ec78db01 Merge: - e199e31... b6c995e... Author: Kimmo Varis Date: - Wed Oct 13 22:16:17 2010 +0300 + * : commit 6c582f9362ca13da701aa3b6b1ed6808ec78db01 Merge: e199e31 + b6c995e Author: Kimmo Varis Date: Wed Oct 13 + 22:16:17 2010 +0300 2010-10-13 Kimmo Varis @@ -16094,10 +18783,9 @@ 2009-06-19 Kimmo Varis - * : commit d5d96d2535c6bcb0581e63818e0cbcf440e2d703 Merge: - 12f3ac5... e8d1905... Author: Daniel Marjamäki - Date: Thu Jun 18 23:10:16 2009 - +0200 + * : commit d5d96d2535c6bcb0581e63818e0cbcf440e2d703 Merge: 12f3ac5 + e8d1905 Author: Daniel Marjamäki + Date: Thu Jun 18 23:10:16 2009 +0200 2009-06-19 Kimmo Varis diff --git a/Makefile b/Makefile index 5391b67ea..794e7c5d1 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 39c6eb916..0b5da1128 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -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] [--enable=] [--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= This allows you to provide information about\n" " functions by providing an implementation for these.\n" " -D 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= 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= 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=\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= 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 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 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 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= Match regular expression.\n" + " --rule-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=\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 '' 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=\n" " Select the XML file version. Currently versions 1 and 2\n" " are available. The default version is 1." "\n" diff --git a/cli/cppcheck.rc b/cli/cppcheck.rc index e28e20d81..69f53fb7a 100644 --- a/cli/cppcheck.rc +++ b/cli/cppcheck.rc @@ -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 Marjamki and Cppcheck team." VALUE "OriginalFilename", "cppcheck.exe" VALUE "ProductName", "cppcheck Application" - VALUE "ProductVersion", "1.46" + VALUE "ProductVersion", "1.47" END END BLOCK "VarFileInfo" diff --git a/cli/main.cpp b/cli/main.cpp index 1f1a31b0a..33868983b 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -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. diff --git a/createrelease b/createrelease index 663d8563b..afcda579e 100755 --- a/createrelease +++ b/createrelease @@ -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 diff --git a/gui/cppcheck_de.ts b/gui/cppcheck_de.ts index 3c7b047a7..99899b8ae 100644 --- a/gui/cppcheck_de.ts +++ b/gui/cppcheck_de.ts @@ -223,9 +223,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -563,8 +563,9 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - XML-Dateien (*.xml);;Textdateien (*.txt);;CSV-Dateien (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML-Dateien (*.xml);;Textdateien (*.txt);;CSV-Dateien (*.csv) @@ -573,7 +574,6 @@ kate -l(line) (file) - XML files (*.xml) XML-Dateien (*.xml) @@ -584,8 +584,8 @@ kate -l(line) (file) - - + + Project: @@ -601,23 +601,33 @@ kate -l(line) (file) Do you want to stop the checking and exit Cppcheck?. + + + XML files version 1 (*.xml) + + + XML files version 2 (*.xml) + + + + Text files (*.txt) Textdateien (*.txt) - + CSV files (*.csv) CSV-Dateien (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -633,39 +643,39 @@ Do you want to stop the checking and exit Cppcheck?. - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File - + Select Project Filename - + No project file loaded @@ -929,18 +939,18 @@ Please select the directory where file is located. ResultsView - - + + Cppcheck Cppcheck - + No errors found. Keine Fehler gefunden. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. 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 - + + Failed to read the report. - + Summary - + Message - + No errors found, nothing to save. Keine Fehler gefunden, nichts zu speichern. - - + + Failed to save the report. Der Bericht konnte nicht speichern werden. diff --git a/gui/cppcheck_en.ts b/gui/cppcheck_en.ts index 9ee278852..4621571d1 100644 --- a/gui/cppcheck_en.ts +++ b/gui/cppcheck_en.ts @@ -225,9 +225,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -565,8 +565,9 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) @@ -575,7 +576,6 @@ kate -l(line) (file) - XML files (*.xml) XML files (*.xml) @@ -586,8 +586,8 @@ kate -l(line) (file) - - + + Project: @@ -603,23 +603,33 @@ kate -l(line) (file) Do you want to stop the checking and exit Cppcheck?. + + + XML files version 1 (*.xml) + + + XML files version 2 (*.xml) + + + + Text files (*.txt) Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -633,39 +643,39 @@ Do you want to stop the checking and exit Cppcheck?. %1 - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File - + Select Project Filename - + No project file loaded @@ -929,18 +939,18 @@ Please select the directory where file is located. ResultsView - - + + Cppcheck Cppcheck - + No errors found. No errors found. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. 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. - + + Failed to read the report. - + Summary - + Message - + No errors found, nothing to save. No errors found, nothing to save. - - + + Failed to save the report. Failed to save the report. diff --git a/gui/cppcheck_fi.ts b/gui/cppcheck_fi.ts index 303d349e6..f336f63c2 100644 --- a/gui/cppcheck_fi.ts +++ b/gui/cppcheck_fi.ts @@ -227,9 +227,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -567,8 +567,9 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - XML-tiedostot (*.xml);;Tekstitiedostot (*.txt);;CSV-tiedostot (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML-tiedostot (*.xml);;Tekstitiedostot (*.txt);;CSV-tiedostot (*.csv) @@ -577,7 +578,6 @@ kate -l(line) (file) - XML files (*.xml) XML-tiedostot (*xml) @@ -588,8 +588,8 @@ kate -l(line) (file) - - + + Project: @@ -605,23 +605,33 @@ kate -l(line) (file) Do you want to stop the checking and exit Cppcheck?. + + + XML files version 1 (*.xml) + + + XML files version 2 (*.xml) + + + + Text files (*.txt) Tekstitiedostot (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -637,39 +647,39 @@ Do you want to stop the checking and exit Cppcheck?. - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File - + Select Project Filename - + No project file loaded @@ -933,18 +943,18 @@ Please select the directory where file is located. ResultsView - - + + Cppcheck Cppcheck - + No errors found. Virheitä ei löytynyt. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. 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 - + + Failed to read the report. - + Summary - + Message - + No errors found, nothing to save. Virheitä ei löytynyt, ei mitään tallennettavaa. - - + + Failed to save the report. Raportin tallentaminen epäonnistui. diff --git a/gui/cppcheck_fr.ts b/gui/cppcheck_fr.ts index 223830438..bd9e29e7e 100644 --- a/gui/cppcheck_fr.ts +++ b/gui/cppcheck_fr.ts @@ -15,10 +15,6 @@ Cppcheck - A tool for static C/C++ code analysis. Cppcheck - Un outil d'analyse statique de code C/C++. - - Copyright (C) 2007-2010 Daniel Marjamäki and cppcheck team. - Copyright (C) 2007-2010 Daniel Marjamäki et cppcheck team. - This program is licensed under the terms of the GNU General Public License version 3 @@ -29,6 +25,10 @@ General Public License version 3 Visit Cppcheck homepage at %1 Visitez le site Cppcheck : %1 + + Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. + + ApplicationDialog @@ -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'affichage sur la bonne ligne: kate -l(ligne) (fichier) - - Application's name - Nom de l'application - - - Application to execute - Application à exécuter - Browse Parcourir @@ -89,6 +81,14 @@ kate -l(ligne) (fichier) You must specify a name and a path for the application! Vous devez spécifier un nom et un chemin d'accès pour l'application ! + + Application's name: + + + + Command to execute: + + FileViewDialog @@ -106,10 +106,69 @@ kate -l(ligne) (fichier) - Fileview + HelpWindow - Fileview - Visualisateur de fichier + Cppcheck Help + + + + Go back + + + + Back + + + + Go forward + + + + Forward + + + + Start + + + + Home + + + + + LogView + + Checking Log + + + + &Save + + + + Clear + + + + Close + + + + Save Log + + + + Text files (*.txt *.log);;All files (*.*) + + + + Cppcheck + + + + Could not open file for writing: "%1" + @@ -126,10 +185,6 @@ kate -l(ligne) (fichier) &View &Affichage - - &Language - &Langue - &Help &Aide @@ -210,26 +265,6 @@ kate -l(ligne) (fichier) &Preferences &Préférences - - Show possible false positives - Afficher les possibles faux positifs - - - Show security errors - Afficher les erreurs de sécurité - - - Show style errors - Afficher les erreurs de style - - - Show possible style errors - Afficher les erreurs possibles de style - - - Show common errors - Afficher les erreurs - &Check all Tout &cocher @@ -246,10 +281,6 @@ kate -l(ligne) (fichier) &Expand all Tout &afficher - - &Toolbar - &Barre d'outil - &Contents &Contenu @@ -274,14 +305,6 @@ kate -l(ligne) (fichier) Select directory to check Sélectionner le répertoire à vérifier - - Cannot exit while checking. - -Stop the checking before exiting. - Ne peut pas quitter pendant une vérification. - -Arrêter la vérification avant de quitter. - License Licence @@ -290,10 +313,6 @@ Arrêter la vérification avant de quitter. Authors Auteur - - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - Fichier XML (*.xml);;Fichier Texte (*.txt);;Fichier CSV (*.csv) - Save the report file Sauvegarder le rapport @@ -354,6 +373,253 @@ Arrêter la vérification avant de quitter. Polish Polonais + + &Toolbars + + + + Categories + + + + Check files + + + + Check directory + + + + Stop checking + + + + Style warnings + + + + Show style warnings + + + + Errors + + + + Show errors + + + + &Standard + + + + Standard items + + + + Toolbar + + + + &Categories + + + + Error categories + + + + &Open XML... + + + + Open P&roject File... + + + + &New Project File... + + + + &Log View + + + + Log View + + + + C&lose Project File + + + + &Edit Project File... + + + + &Statistics + + + + Warnings + + + + Show warnings + + + + Performance warnings + + + + Show performance warnings + + + + Show &hidden + + + + Information + + + + Show information messages + + + + Portability + + + + Show portability warnings + + + + You must close the project file before selecting new files or directories! + + + + Project: + + + + Open the report file + + + + Checking is running. + +Do you want to stop the checking and exit Cppcheck?. + + + + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + + + + XML files version 1 (*.xml) + + + + XML files version 2 (*.xml) + + + + Cppcheck Help + + + + Failed to load help file (not found) + + + + Failed to load help file + + + + Project files (*.cppcheck);;All files(*.*) + + + + Select Project File + + + + Select Project Filename + + + + No project file loaded + + + + Japanese + + + + Serbian + + + + + Project + + Cppcheck + + + + Could not read the project file. + + + + Could not write the project file. + + + + + ProjectFile + + Project File + + + + Project: + + + + Paths: + + + + Browse... + + + + Include paths: + + + + Defines: + + + + + ProjectFileDialog + + Project file: %1 + + + + Select include directory + + + + Select directory to check + Sélectionner le répertoire à vérifier + QObject @@ -384,10 +650,6 @@ Arrêter la vérification avant de quitter. Line Ligne - - Message - Message - Undefined file Fichier indéterminé @@ -420,22 +682,52 @@ Please check the application path and parameters are correct. Merci de vérifier que le chemin de l'application et que les paramètres sont corrects. - - possible error - erreur possible - style erreur de style - - possible style - erreur de style possible - error erreur + + Summary + + + + Hide + + + + Could not find the file! + + + + Could not find file: +%1 +Please select the directory where file is located. + + + + Select Directory + + + + warning + + + + performance + + + + portability + + + + information + + ResultsView @@ -465,6 +757,18 @@ Pour configurer les erreurs affichées, ouvrez le menu d'affichage.Failed to save the report. Erreur lors de la sauvegarde du rapport. + + Failed to read the report. + + + + Summary + + + + Message + Message + Settings @@ -480,10 +784,6 @@ Pour configurer les erreurs affichées, ouvrez le menu d'affichage.Number of threads: Nombre de processus : - - Check all #ifdef configurations - Vérifier toutes les configurations #ifdef - Show full path of files Montrer le chemin complet des fichiers @@ -524,6 +824,38 @@ Pour configurer les erreurs affichées, ouvrez le menu d'affichage.Save full path to files in reports Sauvegarder le chemin complet des fichiers dans les rapports + + Include paths: + + + + Add... + + + + Ideal count: + + + + TextLabel + + + + Force checking all #ifdef configurations + + + + Show internal warnings in log + + + + Enable inline suppressions + + + + Language + + SettingsDialog @@ -535,5 +867,173 @@ Pour configurer les erreurs affichées, ouvrez le menu d'affichage.Modify an application Modifier une application + + N/A + + + + Select include directory + + + + + StatsDialog + + Statistics + + + + Project + + + + Project: + + + + Paths: + + + + Include paths: + + + + Defines: + + + + Previous Scan + + + + Path Selected: + + + + Number of Files Scanned: + + + + Scan Duration: + + + + Errors: + + + + Warnings: + + + + Stylistic warnings: + + + + Portability warnings: + + + + TextLabel + + + + Performance issues: + + + + Information messages: + + + + Copy to Clipboard + + + + 1 day + + + + %1 days + + + + 1 hour + + + + %1 hours + + + + 1 minute + + + + %1 minutes + + + + 1 second + + + + %1 seconds + + + + 0.%1 seconds + + + + and + + + + 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 + + + + + <h3>Project Settings<h3> +<table> + <tr><th>Project:</th><td>%1</td></tr> + <tr><th>Paths:</th><td>%2</td></tr> + <tr><th>Include paths:</th><td>%3</td></tr> + <tr><th>Defines:</th><td>%4</td></tr> +</table> +<h3>Previous Scan</h3> +<table> + <tr><th>Path selected:</th><td>%5</td></tr> + <tr><th>Number of files scanned:</th><td>%6</td></tr> + <tr><th>Scan duration:</th><td>%7</td></tr> +</table> +<h3>Statistics</h3> + <tr><th>Errors:</th><td>%8</td></tr> + <tr><th>Warnings:</th><td>%9</td></tr> + <tr><th>Style warnings:</th><td>%10</td></tr> + <tr><th>Portability warnings:</th><td>%11</td></tr> + <tr><th>Performance warnings:</th><td>%12</td></tr> + <tr><th>Information messages:</th><td>%13</td></tr> +</table> + + + diff --git a/gui/cppcheck_ja.ts b/gui/cppcheck_ja.ts index 222900f08..12d8c80ca 100644 --- a/gui/cppcheck_ja.ts +++ b/gui/cppcheck_ja.ts @@ -211,9 +211,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -546,14 +546,13 @@ kate -l(line) (file) - - + + Project: プロジェクト: - XML files (*.xml) XML ファイル (*.xml) @@ -583,31 +582,42 @@ Do you want to stop the checking and exit Cppcheck?. - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - XML ファイル (*.xml);;テキストファイル (*.txt);;CSV形式ファイル (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML ファイル (*.xml);;テキストファイル (*.txt);;CSV形式ファイル (*.csv) Save the report file レポートを保存 + + + XML files version 1 (*.xml) + + + XML files version 2 (*.xml) + + + + Text files (*.txt) テキストファイル (*.txt) - + CSV files (*.csv) CSV形式ファイル (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -620,39 +630,39 @@ Do you want to stop the checking and exit Cppcheck?. - - + + Cppcheck Help Cppcheck ヘルプ - + Failed to load help file (not found) ヘルプファイルが見つかりませんでした - + Failed to load help file ヘルプファイルの読み込みに失敗しました - - + + Project files (*.cppcheck);;All files(*.*) プロジェクトファイル (*.cppcheck);;All files(*.*) - + Select Project File プロジェクトファイルを選択 - + Select Project Filename プロジェクトファイル名を選択 - + No project file loaded プロジェクトファイルが読み込まれていません @@ -920,46 +930,47 @@ Please select the directory where file is located. 結果 - + No errors found, nothing to save. 警告/エラーが見つからなかったため、保存しません。 - - + + Failed to save the report. レポートの保存に失敗しました。 - - + + Cppcheck Cppcheck - + No errors found. 警告/エラーは見つかりませんでした。 - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. 警告/エラーが見つかりましたが、非表示設定になっています。 - + + Failed to read the report. レポートの読み込みに失敗. - + Summary 内容 - + Message メッセージ diff --git a/gui/cppcheck_nl.ts b/gui/cppcheck_nl.ts index a5ac7b33f..e34529164 100644 --- a/gui/cppcheck_nl.ts +++ b/gui/cppcheck_nl.ts @@ -225,9 +225,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -565,8 +565,9 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - XML bestanden (*.xml);;Tekst bestanden (*.txt);;CSV bestanden (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML bestanden (*.xml);;Tekst bestanden (*.txt);;CSV bestanden (*.csv) @@ -575,7 +576,6 @@ kate -l(line) (file) - XML files (*.xml) XML bestanden (*.xml) @@ -586,8 +586,8 @@ kate -l(line) (file) - - + + Project: @@ -603,23 +603,33 @@ kate -l(line) (file) Do you want to stop the checking and exit Cppcheck?. + + + XML files version 1 (*.xml) + + + XML files version 2 (*.xml) + + + + Text files (*.txt) Tekst bestanden (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -633,39 +643,39 @@ Do you want to stop the checking and exit Cppcheck?. %1 - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File - + Select Project Filename - + No project file loaded @@ -929,18 +939,18 @@ Please select the directory where file is located. ResultsView - - + + Cppcheck Cppcheck - + No errors found. Geen fouten gevonden. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. 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. - + + Failed to read the report. - + Summary - + Message - + No errors found, nothing to save. Geen fouten gevonden; geen data om op te slaan. - - + + Failed to save the report. Kon het rapport niet opslaan. diff --git a/gui/cppcheck_pl.ts b/gui/cppcheck_pl.ts index 79013cad9..f80b37956 100644 --- a/gui/cppcheck_pl.ts +++ b/gui/cppcheck_pl.ts @@ -212,9 +212,9 @@ kate -l(line) (file) - - - + + + Cppcheck @@ -547,8 +547,8 @@ kate -l(line) (file) - - + + Project: @@ -569,7 +569,8 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) @@ -578,34 +579,43 @@ kate -l(line) (file) - - + + XML files version 1 (*.xml) + + + + + XML files version 2 (*.xml) + + + + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - + Select Project Filename - + No project file loaded - XML files (*.xml) @@ -617,22 +627,22 @@ Do you want to stop the checking and exit Cppcheck?. - + Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 - + Failed to change the language: %1 @@ -641,13 +651,13 @@ Do you want to stop the checking and exit Cppcheck?. - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File @@ -906,46 +916,47 @@ Please select the directory where file is located. ResultsView - - + + Cppcheck - + No errors found. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. - + + Failed to read the report. - + Summary - + Message - + No errors found, nothing to save. - - + + Failed to save the report. diff --git a/gui/cppcheck_ru.ts b/gui/cppcheck_ru.ts index 56e10c928..9bc1aecb2 100644 --- a/gui/cppcheck_ru.ts +++ b/gui/cppcheck_ru.ts @@ -215,9 +215,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -555,7 +555,8 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) @@ -565,7 +566,6 @@ kate -l(line) (file) - XML files (*.xml) @@ -576,8 +576,8 @@ kate -l(line) (file) - - + + Project: @@ -593,23 +593,33 @@ kate -l(line) (file) Do you want to stop the checking and exit Cppcheck?. + + + XML files version 1 (*.xml) + + + XML files version 2 (*.xml) + + + + Text files (*.txt) Текстовые файлы (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -625,39 +635,39 @@ Do you want to stop the checking and exit Cppcheck?. - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File - + Select Project Filename - + No project file loaded @@ -919,46 +929,47 @@ Please select the directory where file is located. ResultsView - - + + Cppcheck Cppcheck - + No errors found. Ошибок не найдено. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. - + + Failed to read the report. - + Summary - + Message - + No errors found, nothing to save. - - + + Failed to save the report. diff --git a/gui/cppcheck_se.ts b/gui/cppcheck_se.ts index 624f1abc6..593a59fa7 100644 --- a/gui/cppcheck_se.ts +++ b/gui/cppcheck_se.ts @@ -225,9 +225,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -566,8 +566,9 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - XML filer (*.xml);;Text filer (*.txt);;CSV filer (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML filer (*.xml);;Text filer (*.txt);;CSV filer (*.csv) @@ -576,7 +577,6 @@ kate -l(line) (file) - XML files (*.xml) XML filer (*.xml) @@ -587,8 +587,8 @@ kate -l(line) (file) - - + + Project: Projekt. @@ -606,23 +606,33 @@ Do you want to stop the checking and exit Cppcheck?. Vill du stoppa analysen och avsluta Cppcheck? + + + XML files version 1 (*.xml) + + + XML files version 2 (*.xml) + + + + Text files (*.txt) Text filer (*.txt) - + CSV files (*.csv) CSV filer (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -638,39 +648,39 @@ Vill du stoppa analysen och avsluta Cppcheck? - - + + Cppcheck Help Cppcheck Hjälp - + Failed to load help file (not found) Misslyckades att öppna hjälpfilen (hittades ej) - + Failed to load help file Misslykades att öppna hjälpfilen - - + + Project files (*.cppcheck);;All files(*.*) Projektfiler (*.cppcheck);;Alla filer(*.*) - + Select Project File Välj projektfil - + Select Project Filename Välj Projektfil - + No project file loaded Inget projekt laddat @@ -936,18 +946,18 @@ Välj mappen där filen finns. ResultsView - - + + Cppcheck Cppcheck - + No errors found. Inga fel hittades. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. 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. - + + Failed to read the report. Misslyckades att läsa rapporten. - + Summary Sammanfattning - + Message Meddelande - + No errors found, nothing to save. Inga fel hittades, ingenting att spara. - - + + Failed to save the report. Misslyckades med att spara rapporten. diff --git a/gui/cppcheck_sr.ts b/gui/cppcheck_sr.ts index 8710dd855..91eb79c7a 100644 --- a/gui/cppcheck_sr.ts +++ b/gui/cppcheck_sr.ts @@ -225,9 +225,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -565,8 +565,9 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) @@ -575,7 +576,6 @@ kate -l(line) (file) - XML files (*.xml) XML files (*.xml) @@ -586,8 +586,8 @@ kate -l(line) (file) - - + + Project: @@ -603,23 +603,33 @@ kate -l(line) (file) Do you want to stop the checking and exit Cppcheck?. + + + XML files version 1 (*.xml) + + + XML files version 2 (*.xml) + + + + Text files (*.txt) Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -633,39 +643,39 @@ Do you want to stop the checking and exit Cppcheck?. %1 - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File - + Select Project Filename - + No project file loaded @@ -929,18 +939,18 @@ Please select the directory where file is located. ResultsView - - + + Cppcheck Cppcheck - + No errors found. No errors found. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. 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. - + + Failed to read the report. - + Summary - + Message - + No errors found, nothing to save. No errors found, nothing to save. - - + + Failed to save the report. Failed to save the report. diff --git a/gui/gui.pro b/gui/gui.pro index 54952ac6c..26428b4ed 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -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 \ diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 72cd10091..bd32a1334 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -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 actions = mLanguages->actions(); - - if (languages.size() <= actions.size()) - { - for (int i = 0; i < languages.size(); i++) - { - actions[i]->setText(tr(languages[i].toLatin1())); - } - } } } diff --git a/gui/mainwindow.h b/gui/mainwindow.h index e40f3ec51..ea844a287 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -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. */ diff --git a/gui/report.h b/gui/report.h index 681bdecf6..ace33c4b6 100644 --- a/gui/report.h +++ b/gui/report.h @@ -39,6 +39,7 @@ public: { TXT, XML, + XMLV2, CSV, }; diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index ab1234f46..1d4f90568 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -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 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 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(""); diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index 28fcf4773..2301950fa 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -91,13 +91,17 @@ SettingsDialog::~SettingsDialog() void SettingsDialog::InitTranslationsList() { - QStringList languages = mTranslator->GetNames(); - foreach(const QString lang, languages) + const QString current = mTranslator->GetCurrentLanguage(); + QList 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) diff --git a/gui/settingsdialog.h b/gui/settingsdialog.h index b99b5c294..d2a9e11ad 100644 --- a/gui/settingsdialog.h +++ b/gui/settingsdialog.h @@ -201,6 +201,7 @@ protected: */ Ui::Settings mUI; private: + static const int LangCodeRole = Qt::UserRole; }; /// @} #endif // SETTINGSDIALOG_H diff --git a/gui/translationhandler.cpp b/gui/translationhandler.cpp index d6b8e9dba..6a1cb1d9a 100644 --- a/gui/translationhandler.cpp +++ b/gui/translationhandler.cpp @@ -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"< #include #include +#include /// @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 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 mTranslations; + + /** + * @brief Translator class instance. + * + */ + QTranslator *mTranslator; }; + /// @} #endif // TRANSLATIONHANDLER_H diff --git a/gui/xmlreport.cpp b/gui/xmlreport.cpp index f481f3615..dc8f4be30 100644 --- a/gui/xmlreport.cpp +++ b/gui/xmlreport.cpp @@ -18,122 +18,70 @@ #include #include -#include -#include #include -#include -#include +#include #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("&", "&"); + quotedMessage.replace("\"", """); + quotedMessage.replace("'", "'"); + quotedMessage.replace("<", "<"); + quotedMessage.replace(">", ">"); + return quotedMessage; } -bool XmlReport::Create() +QString XmlReport::unquoteMessage(const QString &message) { - bool success = false; - if (Report::Create()) + QString quotedMessage(message); + quotedMessage.replace("&", "&"); + quotedMessage.replace(""", "\""); + quotedMessage.replace("'", "'"); + quotedMessage.replace("<", "<"); + quotedMessage.replace(">", ">"); + 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 - - 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 XmlReport::Read() -{ - QList 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 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; } diff --git a/gui/xmlreport.h b/gui/xmlreport.h index 0c8058dd0..74d2107d8 100644 --- a/gui/xmlreport.h +++ b/gui/xmlreport.h @@ -19,78 +19,51 @@ #ifndef XML_REPORT_H #define XML_REPORT_H -#include #include -#include -#include -#include -#include +#include #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 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 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 diff --git a/gui/xmlreportv1.cpp b/gui/xmlreportv1.cpp new file mode 100644 index 000000000..1062de07f --- /dev/null +++ b/gui/xmlreportv1.cpp @@ -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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#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 + + 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 XmlReportV1::Read() +{ + QList 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; +} diff --git a/gui/xmlreportv1.h b/gui/xmlreportv1.h new file mode 100644 index 000000000..181b21e4b --- /dev/null +++ b/gui/xmlreportv1.h @@ -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 . + */ + +#ifndef XML_REPORTV1_H +#define XML_REPORTV1_H + +#include +#include +#include +#include +#include +#include +#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 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 diff --git a/gui/xmlreportv2.cpp b/gui/xmlreportv2.cpp new file mode 100644 index 000000000..381d7d9c0 --- /dev/null +++ b/gui/xmlreportv2.cpp @@ -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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#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 + + + + + */ + + 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 XmlReportV2::Read() +{ + QList 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 + + + + + */ + + 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; +} diff --git a/gui/xmlreportv2.h b/gui/xmlreportv2.h new file mode 100644 index 000000000..6b1a2841c --- /dev/null +++ b/gui/xmlreportv2.h @@ -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 . + */ + +#ifndef XML_REPORTV2_H +#define XML_REPORTV2_H + +#include +#include +#include +#include +#include +#include +#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 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 diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index f33a9a8ae..10b53cd2b 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -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 unknown_type; + std::list::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 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 arrayVar; - for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) + const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); + + std::list::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 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::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 localvar; // local variables in function + for (; tok2; tok2 = tok2->next()) { - unsigned int indentlevel = 0; - std::set 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::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 localvar; // local variables in function + for (; tok2; tok2 = tok2->next()) { - unsigned int indentlevel = 0; - std::set 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"); } - - - diff --git a/lib/checkexceptionsafety.cpp b/lib/checkexceptionsafety.cpp index 0c3757dee..f4bccfec3 100644 --- a/lib/checkexceptionsafety.cpp +++ b/lib/checkexceptionsafety.cpp @@ -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); + } +} diff --git a/lib/checkexceptionsafety.h b/lib/checkexceptionsafety.h index af92597f5..a984bf5f3 100644 --- a/lib/checkexceptionsafety.h +++ b/lib/checkexceptionsafety.h @@ -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"; } }; /// @} diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 409381a25..4dd122d1a 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1250,7 +1250,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::liststr() == "else") || (tok->str() == "switch")) { addtoken(&rettail, tok, tok->str()); - if (tok->str() == "switch") + if (Token::simpleMatch(tok, "switch (")) tok = tok->next()->link(); continue; } diff --git a/lib/checkother.cpp b/lib/checkother.cpp index dff996088..891502d6e 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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 + ")."); +} diff --git a/lib/checkother.h b/lib/checkother.h index 0ca251491..07df64867 100644 --- a/lib/checkother.h +++ b/lib/checkother.h @@ -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" diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 8364e379e..7530498a7 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -73,7 +73,7 @@ void CppCheck::clearFiles() const char * CppCheck::version() { - return "1.46"; + return "1.47"; } unsigned int CppCheck::check() diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 5aa45a0ee..f3ab9e231 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -908,6 +908,8 @@ std::list 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 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) { diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index af0dd6818..3ee0d272d 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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(); diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 5c7cfaf2d..b74eb6793 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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; } } diff --git a/man/cppcheck.1.xml b/man/cppcheck.1.xml index 7c86354cd..3344d02b3 100644 --- a/man/cppcheck.1.xml +++ b/man/cppcheck.1.xml @@ -102,28 +102,30 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ &dhpackage; - - - - + + + + - - + + - - + + - + + + - - + + - + @@ -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. --> - + This allows you to provide information about functions by providing an implementation for these. - + 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 - + Enable additional checks. The available ids are: @@ -199,9 +201,9 @@ Example: -DDEBUG=1 -D__cplusplus - + - If errors are found, integer [n] is returned instead of default 0. + If errors are found, integer <n> 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. @@ -214,13 +216,13 @@ Example: -DDEBUG=1 -D__cplusplus - + Used when certain messages should be displayed but should not cause a non-zero exitcode. - + Specify the files to check in a text file. One filename per line. @@ -241,7 +243,7 @@ default. - + 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. @@ -249,7 +251,7 @@ files, this is not needed. - + 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. @@ -264,9 +266,9 @@ Directory name is matched to all parts of the path. - + - Start [jobs] threads to do the checking work. + Start <jobs> threads to do the checking work. @@ -282,6 +284,18 @@ Directory name is matched to all parts of the path. Report progress when checking a file. + + + + Match regular expression to create your own checks. E.g. rule "/ 0" can be used to check division by zero. + + + + + + Use given rule XML file. See https://sourceforge.net/projects/cppcheck/files/Articles/ for more info about the syntax. + + @@ -290,14 +304,14 @@ Directory name is matched to all parts of the path. - + 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. - + Format the error messages. E.g. '{file}:{line},{severity},{id},{message}' or '{file}({line}):({severity}) {message}'. Pre-defined templates: gcc, vs @@ -322,7 +336,7 @@ Directory name is matched to all parts of the path. - + Select the XML file version. Currently versions 1 and 2 are available. The default version is 1. diff --git a/man/manual.docbook b/man/manual.docbook index 125ac9acd..02a25bf73 100644 --- a/man/manual.docbook +++ b/man/manual.docbook @@ -3,9 +3,9 @@ "/usr/share/xml/docbook/schema/dtd/4.4/docbookx.dtd"> - Cppcheck 1.46 + Cppcheck 1.47 - 2010-12-09 + 2011-02-06 @@ -94,19 +94,20 @@ Checking path/file2.cpp...
Excluding a file or folder from checking - 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. + To exclude a file or folder, there are two options. - Imagine for example that the folder "src" contain the folders "a", - "b" and "c". To exclude "c" this command can be used: + The first option is to only provide the paths and files you want + to check. cppcheck src/a src/b All files under "src/a" and "src/b" are then checked. - The flag --file-list might also be - useful. + The second option is to use -i, with it you + specify files/paths to ignore. With this command no files in "src/c" are + checked: + + cppcheck -isrc/c src
@@ -148,6 +149,15 @@ Checking path/file2.cpp... suggestions for making the code faster + + + information + + + Informational messages that might be interesting. Ignore + these messages unless you really agree. + + The performance messages are based on 'common knowledge'. It is diff --git a/readme.txt b/readme.txt index 5487fa574..bb5e677c3 100644 --- a/readme.txt +++ b/readme.txt @@ -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++ diff --git a/scripts/tabs.pl b/scripts/tabs.pl new file mode 100755 index 000000000..bf58359ae --- /dev/null +++ b/scripts/tabs.pl @@ -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 = ; + 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) +} + + diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 1c0824526..221258cc1 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -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 = #\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 = #\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]=#\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 #}"); + " return #" + "}"); 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 #" + "}"); + 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 &foo();\n" + "};\n" + "std::vector &Fred::foo()\n" + "{\n" + " std::vector 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 &foo();\n" + "};\n" + "std::vector &Fred::foo()\n" + "{\n" + " static std::vector 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) diff --git a/test/testclass.cpp b/test/testclass.cpp index 0fd7f6fcd..fd284f8fb 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -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 class E,class D> class C : E\n" "{\n" "public:\n" - " int f();\n" + " int f();\n" "};\n" "class E : C\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) diff --git a/test/testexceptionsafety.cpp b/test/testexceptionsafety.cpp index a94f9b5b0..6a926e5ae 100644 --- a/test/testexceptionsafety.cpp +++ b/test/testexceptionsafety.cpp @@ -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) diff --git a/test/testmathlib.cpp b/test/testmathlib.cpp index f05a029bc..cd3637da3 100644 --- a/test/testmathlib.cpp +++ b/test/testmathlib.cpp @@ -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")); } diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 713179a00..4fbf3832b 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -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() { diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 0c9e09a1f..35b239974 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -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" diff --git a/test/testother.cpp b/test/testother.cpp index 864cf25a1..f5adf548d 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -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) diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 2d9486d49..7163b3af2 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -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(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(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 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.. diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 77f464776..ae11bd0ed 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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;"; diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 9c24fe6a5..3dc598f83 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -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()); diff --git a/verify/codeeditor.cpp b/verify/codeeditor.cpp deleted file mode 100644 index 5692172ca..000000000 --- a/verify/codeeditor.cpp +++ /dev/null @@ -1,138 +0,0 @@ -#include "codeeditor.h" -#include -#include - - -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 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 &errorLines) -{ - QList 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; - } -} diff --git a/verify/codeeditor.h b/verify/codeeditor.h deleted file mode 100644 index be5b25511..000000000 --- a/verify/codeeditor.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef CODEEDITOR_H -#define CODEEDITOR_H - -#include -#include -#include - -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 &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 diff --git a/verify/cppcheck-verify.pro b/verify/cppcheck-verify.pro deleted file mode 100644 index 15373457b..000000000 --- a/verify/cppcheck-verify.pro +++ /dev/null @@ -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 diff --git a/verify/main.cpp b/verify/main.cpp deleted file mode 100644 index 16ea79c93..000000000 --- a/verify/main.cpp +++ /dev/null @@ -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 . - */ - -#include -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/verify/mainwindow.cpp b/verify/mainwindow.cpp deleted file mode 100644 index 77e0d49d1..000000000 --- a/verify/mainwindow.cpp +++ /dev/null @@ -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 . - */ - -#include "mainwindow.h" -#include "ui_mainwindow.h" - -#include "preprocessor.h" -#include "tokenize.h" - -#include -#include -#include -#include -#include - -#include - -static void arrayIndex(const Tokenizer &tokenizer, std::set &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 configurations; - std::list 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 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 errorLines; - for (std::set::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 &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()); - } - } -} diff --git a/verify/mainwindow.h b/verify/mainwindow.h deleted file mode 100644 index 4866421cf..000000000 --- a/verify/mainwindow.h +++ /dev/null @@ -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 . - */ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -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 diff --git a/verify/mainwindow.ui b/verify/mainwindow.ui deleted file mode 100644 index c639257e7..000000000 --- a/verify/mainwindow.ui +++ /dev/null @@ -1,75 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 600 - 400 - - - - Cppcheck-Verify - - - - - - - QPlainTextEdit::NoWrap - - - true - - - 4 - - - - - - - - - 0 - 0 - 600 - 25 - - - - - File - - - - - - - - TopToolBarArea - - - false - - - - - - Open.. - - - - - - - CodeEditor - QPlainTextEdit -
codeeditor.h
-
-
- - -
diff --git a/verify/readme.txt b/verify/readme.txt deleted file mode 100644 index fc9e726ae..000000000 --- a/verify/readme.txt +++ /dev/null @@ -1,11 +0,0 @@ - -cppcheck-verify -=============== - -Experimental subproject for Cppcheck. - -The goal is no false negatives. - -Just use 'make' to build. - - diff --git a/win_installer/config.wxi b/win_installer/config.wxi index 47c568ef5..c3f1934f5 100644 --- a/win_installer/config.wxi +++ b/win_installer/config.wxi @@ -4,7 +4,7 @@ - + diff --git a/win_installer/cppcheck.wxs b/win_installer/cppcheck.wxs index de310aaae..1b7e438a1 100755 --- a/win_installer/cppcheck.wxs +++ b/win_installer/cppcheck.wxs @@ -43,6 +43,7 @@ + diff --git a/win_installer/productInfo.wxi b/win_installer/productInfo.wxi index c03e2f282..7f1da88ff 100755 --- a/win_installer/productInfo.wxi +++ b/win_installer/productInfo.wxi @@ -1,8 +1,8 @@ - + - +