diff --git a/gui/cppcheck_de.ts b/gui/cppcheck_de.ts
index d0a75d01a..683491e2e 100644
--- a/gui/cppcheck_de.ts
+++ b/gui/cppcheck_de.ts
@@ -18,7 +18,7 @@
-
+
@@ -117,9 +117,9 @@ kate -l(line) (file)
-
-
-
+
+
+
@@ -299,84 +299,69 @@ kate -l(line) (file)
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+ Failed to change language:
+
+%1
QObject
-
- English
-
-
-
-
- Finnish
-
-
-
-
- Swedish
-
-
-
-
- German
-
-
-
-
- Russian
-
-
-
-
+
Incorrect language specified!
-
+
+ Language file %1.qm not found!
+
+
+
+
Failed to load language from file %1
@@ -429,7 +414,8 @@ Stop the checking before exiting.
- You can open this error by specifying applications in program's settings.
+ Configure the text file viewer program in Cppcheck preferences/Applications.
+ You can open this error by specifying applications in program's settings.
diff --git a/gui/cppcheck_en.ts b/gui/cppcheck_en.ts
index ebf21f0be..71843de9b 100644
--- a/gui/cppcheck_en.ts
+++ b/gui/cppcheck_en.ts
@@ -18,7 +18,7 @@
Cppcheck - A tool for static C/C++ code analysis.
Cppcheck - A tool for static C/C++ code analysis.
-
+
Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team.
Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team.
@@ -130,9 +130,9 @@ kate -l(line) (file)
-
-
-
+
+
+
Cppcheck
Cppcheck
@@ -312,7 +312,7 @@ kate -l(line) (file)
No suitable files found to check!
-
+
Cannot exit while checking.
Stop the checking before exiting.
@@ -321,41 +321,46 @@ Stop the checking before exiting.
Stop the checking before exiting.
-
+
License
License
-
+
Authors
Authors
-
+
XML files (*.xml);;Text files (*.txt)
XML files (*.xml);;Text files (*.txt)
-
+
Save the report file
Save the report file
-
+
XML files (*.xml)
XML files (*.xml)
-
+
Cppcheck - %1
Cppcheck - %1
-
- Failed to change language:
+
+ Failed to change the language:
-%1
- Failed to change language:
+%1
+
+
+ Failed to change language:
+
+%1
+ Failed to change language:
%1
@@ -363,37 +368,37 @@ Stop the checking before exiting.
QObject
-
English
- English
+ English
-
Finnish
- Finnish
+ Finnish
-
Swedish
- Swedish
+ Swedish
-
German
- German
+ German
-
Russian
- Russian
+ Russian
-
+
Incorrect language specified!
Incorrect language specified!
-
+
+ Language file %1.qm not found!
+
+
+
+
Failed to load language from file %1
Failed to load language from file %1
@@ -446,8 +451,9 @@ Stop the checking before exiting.
- You can open this error by specifying applications in program's settings.
- You can open this error by specifying applications in program's settings.
+ Configure the text file viewer program in Cppcheck preferences/Applications.
+ You can open this error by specifying applications in program's settings.
+ You can open this error by specifying applications in program's settings.
diff --git a/gui/cppcheck_fi.ts b/gui/cppcheck_fi.ts
index fbf65112a..1f327b6f1 100644
--- a/gui/cppcheck_fi.ts
+++ b/gui/cppcheck_fi.ts
@@ -18,7 +18,7 @@
Cppcheck - A tool for static C/C++ code analysis.
Cppcheck - Työkalu C/C++ koodin staattiseen analysointiin.
-
+
Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team.
Copyright (C) 2007-2009 Daniel Marjamäki ja cppcheck tiimi.
@@ -132,9 +132,9 @@ kate -l(line) (file)
-
-
-
+
+
+
Cppcheck
Cppcheck
@@ -314,7 +314,7 @@ kate -l(line) (file)
Tarkistettavaksi sopivia tiedostoja ei löytynyt!
-
+
Cannot exit while checking.
Stop the checking before exiting.
@@ -323,77 +323,82 @@ Stop the checking before exiting.
Lopeta tarkistus ennen ohjelman sammuttamista.
-
+
License
Lisenssi
-
+
Authors
Tekijät
-
+
XML files (*.xml);;Text files (*.txt)
XML-tiedostot (*.xml);;Tekstitiedostot (*.txt)
-
+
Save the report file
Tallenna raportti
-
+
XML files (*.xml)
XML-tiedostot (*xml)
-
+
Cppcheck - %1
Cppcheck - %1
-
- Failed to change language:
+
+ Failed to change the language:
-%1
- Kielen %1 vaihto epäonnistui
+%1
+
+
+ Failed to change language:
+
+%1
+ Kielen %1 vaihto epäonnistui
QObject
-
English
- Englanti
+ Englanti
-
Finnish
- Suomi
+ Suomi
-
Swedish
- Ruotsi
+ Ruotsi
-
German
- Saksa
+ Saksa
-
Russian
- Venäjä
+ Venäjä
-
+
Incorrect language specified!
Virheellinen kieli valittu!
-
+
+ Language file %1.qm not found!
+
+
+
+
Failed to load language from file %1
Kielen lataaminen tiedostosta %1 epäonnistui
@@ -446,8 +451,9 @@ Lopeta tarkistus ennen ohjelman sammuttamista.
- You can open this error by specifying applications in program's settings.
- Voit asetuksista määritellä muita ohjelmia joilla avata tämän virheen sisältävän tiedoston.
+ Configure the text file viewer program in Cppcheck preferences/Applications.
+ You can open this error by specifying applications in program's settings.
+ Voit asetuksista määritellä muita ohjelmia joilla avata tämän virheen sisältävän tiedoston.
diff --git a/gui/cppcheck_ru.ts b/gui/cppcheck_ru.ts
index 2b0e02a14..58d74a3c7 100644
--- a/gui/cppcheck_ru.ts
+++ b/gui/cppcheck_ru.ts
@@ -18,7 +18,7 @@
Cppcheck - A tool for static C/C++ code analysis.
-
+
Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team.
@@ -119,9 +119,9 @@ kate -l(line) (file)
-
-
-
+
+
+
Cppcheck
@@ -301,84 +301,69 @@ kate -l(line) (file)
-
+
Cannot exit while checking.
Stop the checking before exiting.
-
+
License
-
+
Authors
-
+
XML files (*.xml);;Text files (*.txt)
-
+
Save the report file
-
+
XML files (*.xml)
-
+
Cppcheck - %1
-
- Failed to change language:
+
+ Failed to change the language:
-%1
+%1
+
+
+ Failed to change language:
+
+%1
QObject
-
- English
-
-
-
-
- Finnish
-
-
-
-
- Swedish
-
-
-
-
- German
-
-
-
-
- Russian
-
-
-
-
+
Incorrect language specified!
-
+
+ Language file %1.qm not found!
+
+
+
+
Failed to load language from file %1
@@ -431,7 +416,8 @@ Stop the checking before exiting.
- You can open this error by specifying applications in program's settings.
+ Configure the text file viewer program in Cppcheck preferences/Applications.
+ You can open this error by specifying applications in program's settings.
diff --git a/gui/cppcheck_se.ts b/gui/cppcheck_se.ts
index 2b0e02a14..58d74a3c7 100644
--- a/gui/cppcheck_se.ts
+++ b/gui/cppcheck_se.ts
@@ -18,7 +18,7 @@
Cppcheck - A tool for static C/C++ code analysis.
-
+
Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team.
@@ -119,9 +119,9 @@ kate -l(line) (file)
-
-
-
+
+
+
Cppcheck
@@ -301,84 +301,69 @@ kate -l(line) (file)
-
+
Cannot exit while checking.
Stop the checking before exiting.
-
+
License
-
+
Authors
-
+
XML files (*.xml);;Text files (*.txt)
-
+
Save the report file
-
+
XML files (*.xml)
-
+
Cppcheck - %1
-
- Failed to change language:
+
+ Failed to change the language:
-%1
+%1
+
+
+ Failed to change language:
+
+%1
QObject
-
- English
-
-
-
-
- Finnish
-
-
-
-
- Swedish
-
-
-
-
- German
-
-
-
-
- Russian
-
-
-
-
+
Incorrect language specified!
-
+
+ Language file %1.qm not found!
+
+
+
+
Failed to load language from file %1
@@ -431,7 +416,8 @@ Stop the checking before exiting.
- You can open this error by specifying applications in program's settings.
+ Configure the text file viewer program in Cppcheck preferences/Applications.
+ You can open this error by specifying applications in program's settings.
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index d58afda7c..8d0505d1a 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -161,11 +161,8 @@ void MainWindow::LoadSettings()
mUI.mActionToolbar->setChecked(mSettings->value(SETTINGS_TOOLBARS_SHOW, true).toBool());
mUI.mToolBar->setVisible(mSettings->value(SETTINGS_TOOLBARS_SHOW, true).toBool());
-
mApplications->LoadSettings(mSettings);
- QString error = "";
-
SetLanguage(mSettings->value(SETTINGS_LANGUAGE, mTranslation->SuggestLanguage()).toInt());
}
@@ -295,6 +292,13 @@ Settings MainWindow::GetCppcheckSettings()
{
result.addAutoAllocClass(classname.toStdString());
}
+
+ QStringList dirs = pfile.GetIncludeDirs();
+ QString dir;
+ foreach(dir, dirs)
+ {
+ result._includePaths.push_back(dir.toStdString());
+ }
}
}
@@ -564,9 +568,9 @@ void MainWindow::SetLanguage(int index)
QString error;
if (!mTranslation->SetLanguage(index, error))
{
- QMessageBox msg(QMessageBox::Warning,
+ QMessageBox msg(QMessageBox::Critical,
tr("Cppcheck"),
- QString(tr("Failed to change language:\n\n%1")).arg(error),
+ QString(tr("Failed to change the language:\n\n%1\n\n")).arg(error),
QMessageBox::Ok,
this);
@@ -582,7 +586,7 @@ void MainWindow::SetLanguage(int index)
if (languages.size() <= actions.size())
{
- for (int i = 0;i < languages.size();i++)
+ for (int i = 0; i < languages.size(); i++)
{
actions[i]->setText(tr(languages[i].toLatin1()));
}
diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp
index d9711a6dc..bee7723b3 100644
--- a/gui/projectfile.cpp
+++ b/gui/projectfile.cpp
@@ -26,6 +26,9 @@ static const char ProjectElementName[] = "project";
static const char AllocElementName[] = "autodealloc";
static const char ClassElementName[] = "class";
static const char ClassNameAttrib[] = "name";
+static const char IncludDirElementName[] = "includedir";
+static const char DirElementName[] = "dir";
+static const char DirNameAttrib[] = "name";
ProjectFile::ProjectFile(QObject *parent) :
QObject(parent)
@@ -60,6 +63,9 @@ bool ProjectFile::Read(const QString &filename)
// Find allocelement from inside project element
if (insideProject && xmlReader.name() == AllocElementName)
ReadAutoAllocClasses(xmlReader);
+
+ if (insideProject && xmlReader.name() == IncludDirElementName)
+ ReadIncludeDirs(xmlReader);
break;
case QXmlStreamReader::EndElement:
@@ -90,6 +96,11 @@ QStringList ProjectFile::GetDeAllocatedClasses() const
return mDeAllocatedClasses;
}
+QStringList ProjectFile::GetIncludeDirs() const
+{
+ return mIncludeDirs;
+}
+
void ProjectFile::ReadAutoAllocClasses(QXmlStreamReader &reader)
{
QXmlStreamReader::TokenType type;
@@ -131,3 +142,45 @@ void ProjectFile::ReadAutoAllocClasses(QXmlStreamReader &reader)
}
while (!allRead);
}
+
+void ProjectFile::ReadIncludeDirs(QXmlStreamReader &reader)
+{
+ QXmlStreamReader::TokenType type;
+ bool allRead = false;
+ do
+ {
+ type = reader.readNext();
+ switch (type)
+ {
+ case QXmlStreamReader::StartElement:
+
+ // Read dir-elements
+ if (reader.name().toString() == DirElementName)
+ {
+ QXmlStreamAttributes attribs = reader.attributes();
+ QString name = attribs.value("", DirNameAttrib).toString();
+ if (!name.isEmpty())
+ mIncludeDirs << name;
+ }
+ break;
+
+ case QXmlStreamReader::EndElement:
+ if (reader.name().toString() == IncludDirElementName)
+ allRead = 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;
+ }
+ }
+ while (!allRead);
+}
diff --git a/gui/projectfile.h b/gui/projectfile.h
index 2c132cc6c..c20e8a2a5 100644
--- a/gui/projectfile.h
+++ b/gui/projectfile.h
@@ -49,9 +49,25 @@ public:
*/
QStringList GetDeAllocatedClasses() const;
+ /**
+ * @brief Get list of include directories.
+ * @return list of directories.
+ */
+ QStringList GetIncludeDirs() const;
+
protected:
+ /**
+ * @brief Read list of automatically deallocated classes from XML.
+ * @param reader XML stream reader.
+ */
void ReadAutoAllocClasses(QXmlStreamReader &reader);
+ /**
+ * @brief Read list of include directories from XML.
+ * @param reader XML stream reader.
+ */
+ void ReadIncludeDirs(QXmlStreamReader &reader);
+
private:
/**
@@ -63,6 +79,11 @@ private:
* @brief List of automatically deallocated classes.
*/
QStringList mDeAllocatedClasses;
+
+ /**
+ * @brief List of include directories used to search include files.
+ */
+ QStringList mIncludeDirs;
};
#endif // PROJECT_FILE_H
diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp
index 6dc40b4dd..bcd050906 100644
--- a/gui/resultstree.cpp
+++ b/gui/resultstree.cpp
@@ -421,9 +421,9 @@ void ResultsTree::StartApplication(QStandardItem *target, int application)
//If there are now application's specified, tell the user about it
if (mApplications->GetApplicationCount() == 0)
{
- QMessageBox msg(QMessageBox::Warning,
+ QMessageBox msg(QMessageBox::Information,
tr("Cppcheck"),
- tr("You can open this error by specifying applications in program's settings."),
+ tr("Configure the text file viewer program in Cppcheck preferences/Applications."),
QMessageBox::Ok,
this);
msg.exec();
diff --git a/gui/resultsview.ui b/gui/resultsview.ui
index e56a480ba..4d2223665 100644
--- a/gui/resultsview.ui
+++ b/gui/resultsview.ui
@@ -26,6 +26,9 @@
Results
+
+ 0
+
-
diff --git a/gui/translationhandler.cpp b/gui/translationhandler.cpp
index 04eb59faf..e10a4b6f8 100644
--- a/gui/translationhandler.cpp
+++ b/gui/translationhandler.cpp
@@ -19,6 +19,7 @@
#include "translationhandler.h"
#include
+#include
#include
TranslationHandler::TranslationHandler(QObject *parent) :
@@ -47,7 +48,7 @@ TranslationHandler::TranslationHandler(QObject *parent) :
}
else
{
- qDebug() << "Failed to load english translation!";
+ qDebug() << "Failed to load English translation!";
delete english;
}
}
@@ -88,6 +89,14 @@ bool TranslationHandler::SetLanguage(const int index, QString &error)
return false;
}
+ // Check translation file exists before trying to load it
+ if (!QFile::exists(mFiles[index]))
+ {
+ QString filename(mFiles[index]);
+ error = QObject::tr("Language file %1.qm not found!");
+ error = error.arg(mFiles[index]);
+ return false;
+ }
//Load the new language
if (!mTranslator->load(mFiles[index]))
diff --git a/src/checkclass.cpp b/src/checkclass.cpp
index f9e31e1f0..50f775d4a 100644
--- a/src/checkclass.cpp
+++ b/src/checkclass.cpp
@@ -262,7 +262,7 @@ void CheckClass::ClassChecking_VarList_Initialize(const Token *tok1, const Token
void CheckClass::constructors()
{
- const char pattern_class[] = "class %var% {";
+ const char pattern_class[] = "class %var% [{:]";
// Locate class
const Token *tok1 = Token::findmatch(_tokenizer->tokens(), pattern_class);
diff --git a/src/cppcheck.cpp b/src/cppcheck.cpp
index dfaf54894..b0307c4e3 100644
--- a/src/cppcheck.cpp
+++ b/src/cppcheck.cpp
@@ -159,7 +159,7 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
if (path[path.length()-1] != '/' && path[path.length()-1] != '\\')
path += '/';
- _includePaths.push_back(path);
+ _settings._includePaths.push_back(path);
}
// Include paths
@@ -344,13 +344,13 @@ unsigned int CppCheck::check()
{
// File content was given as a string
std::istringstream iss(_fileContents[ _filenames[c] ]);
- preprocessor.preprocess(iss, filedata, configurations, fname, _includePaths);
+ preprocessor.preprocess(iss, filedata, configurations, fname, _settings._includePaths);
}
else
{
// Only file name was given, read the content from file
std::ifstream fin(fname.c_str());
- preprocessor.preprocess(fin, filedata, configurations, fname, _includePaths);
+ preprocessor.preprocess(fin, filedata, configurations, fname, _settings._includePaths);
}
int checkCount = 0;
diff --git a/src/cppcheck.h b/src/cppcheck.h
index 8c8bf810c..1a1967ac7 100644
--- a/src/cppcheck.h
+++ b/src/cppcheck.h
@@ -141,10 +141,6 @@ private:
/** Current configuration */
std::string cfg;
- /** List of include paths, e.g. "my/includes/" which should be used
- for finding include files inside source files. */
- std::list _includePaths;
-
std::list _xmllist;
};
diff --git a/src/settings.h b/src/settings.h
index ff2084aaf..2d5549c0a 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -64,6 +64,10 @@ public:
Default value is 0. */
int _exitCode;
+ /** List of include paths, e.g. "my/includes/" which should be used
+ for finding include files inside source files. */
+ std::list _includePaths;
+
/** Fill list of automaticly deallocated classes */
void autoDealloc(std::istream &istr);
diff --git a/src/tokenize.cpp b/src/tokenize.cpp
index 17e8fc170..ca9b72229 100644
--- a/src/tokenize.cpp
+++ b/src/tokenize.cpp
@@ -2656,6 +2656,17 @@ bool Tokenizer::simplifyRedundantParanthesis()
ret = true;
}
+ if (Token::Match(tok->previous(), "( ( %var% )") && tok->next()->varId() != 0)
+ {
+ // We have "( var )", remove the paranthesis
+ tok = tok->previous();
+ tok->deleteNext();
+ tok = tok->next();
+ tok->deleteNext();
+ ret = true;
+ continue;
+ }
+
if (Token::Match(tok, "( ( %bool% )") ||
Token::Match(tok, "( ( %num% )"))
{
diff --git a/test/testclass.cpp b/test/testclass.cpp
index 8dae3e568..a6d81cf27 100644
--- a/test/testclass.cpp
+++ b/test/testclass.cpp
@@ -192,6 +192,18 @@ private:
"};\n");
ASSERT_EQUALS("[test.cpp:10]: (style) Member variable not initialized in the constructor 'Fred::_code'\n", errout.str());
+
+
+ checkUninitVar("class A{};\n"
+ "\n"
+ "class B : public A\n"
+ "{\n"
+ "public:\n"
+ " B() {}\n"
+ "private:\n"
+ " float f;\n"
+ "};\n");
+ ASSERT_EQUALS("[test.cpp:6]: (style) Member variable not initialized in the constructor 'B::f'\n", errout.str());
}
void uninitVarEnum()
diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp
index 458a83936..8e1771e4f 100644
--- a/test/testsimplifytokens.cpp
+++ b/test/testsimplifytokens.cpp
@@ -379,6 +379,9 @@ private:
// remove parantheses..
ASSERT_EQUALS("= p ; ", tok("= (p);"));
ASSERT_EQUALS("if ( a < p ) { } ", tok("if(a<(p)){}"));
+ ASSERT_EQUALS("void f ( ) { int p ; if ( p == -1 ) { } } ", tok("void f(){int p; if((p)==-1){}}"));
+ ASSERT_EQUALS("void f ( ) { int p ; if ( -1 == p ) { } } ", tok("void f(){int p; if(-1==(p)){}}"));
+ ASSERT_EQUALS("void f ( ) { int p ; if ( p ) { } } ", tok("void f(){int p; if((p)){}}"));
// keep parantheses..
ASSERT_EQUALS("= a ; ", tok("= (char)a;"));
diff --git a/win_installer/cppcheck.iss b/win_installer/cppcheck.iss
index daa010224..f4fb7c3c8 100644
--- a/win_installer/cppcheck.iss
+++ b/win_installer/cppcheck.iss
@@ -90,8 +90,8 @@ Name: modifypath; Description: &Add {#MyAppName} folder to your system path; Fla
Type: files; Name: {app}\COPYING
[Files]
+; Core / command line
Source: ..\Build\Release\cppcheck.exe; DestDir: {app}; Flags: ignoreversion; Components: Core
-Source: ..\gui\Release\gui.exe; DestDir: {app}; Flags: ignoreversion; Components: QTGui
Source: ..\COPYING; DestDir: {app}; DestName: COPYING.txt; Flags: ignoreversion; Components: Core
Source: ..\readme.txt; DestDir: {app}; Flags: ignoreversion; Components: Core
Source: ..\AUTHORS; DestDir: {app}; DestName: AUTHORS.txt; Flags: ignoreversion; Components: Core
@@ -99,6 +99,14 @@ Source: ..\AUTHORS; DestDir: {app}; DestName: AUTHORS.txt; Flags: ignoreversion;
Source: {#RuntimesFolder}\Microsoft.VC90.CRT.manifest; DestDir: {app}; Components: Core
Source: {#RuntimesFolder}\msvcp90.dll; DestDir: {app}; Components: Core
Source: {#RuntimesFolder}\msvcr90.dll; DestDir: {app}; Components: Core
+; GUI executable
+Source: ..\gui\Release\gui.exe; DestDir: {app}; Flags: ignoreversion; Components: QTGui
+; GUI translations
+Source: ..\gui\cppcheck_de.qm; DestDir: {app}; Components: QTGui
+Source: ..\gui\cppcheck_en.qm; DestDir: {app}; Components: QTGui
+Source: ..\gui\cppcheck_fi.qm; DestDir: {app}; Components: QTGui
+Source: ..\gui\cppcheck_ru.qm; DestDir: {app}; Components: QTGui
+Source: ..\gui\cppcheck_se.qm; DestDir: {app}; Components: QTGui
; QT runtimes
Source: {#RuntimesFolder}\QtCore4.dll; DestDir: {app}; Components: QTGui
Source: {#RuntimesFolder}\QtGui4.dll; DestDir: {app}; Components: QTGui
diff --git a/win_installer/readme.txt b/win_installer/readme.txt
index d6383d78d..9c50a94e2 100644
--- a/win_installer/readme.txt
+++ b/win_installer/readme.txt
@@ -17,11 +17,16 @@ Files the installer needs:
/COPYING
/readme.txt
/AUTHORS
-/gui/release/gui.exe
/Release/cppcheck.exe
/win_installer/icon.bmp
/win_installer/LargeLogo.bmp
/win_installer/
+/gui/release/gui.exe
+/gui/cppcheck_de.qm
+/gui/cppcheck_en.qm
+/gui/cppcheck_fi.qm
+/gui/cppcheck_ru.qm
+/gui/cppcheck_se.qm
NOTE: Remember to convert COPYING and AUTHORS to Windows EOL format! Otherwise
Windows Notepad (default viewer) can't show then properly.