From ab2bf0ee0c458648745876a6357252ebdb6628c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 26 Feb 2011 10:04:38 -0800 Subject: [PATCH] Fixed #2575 (false positive: Preprocessor does not ignore #include within #if 0 block) --- gui/applicationlist.cpp | 52 ++++--- gui/applicationlist.h | 38 +++-- gui/common.h | 1 + gui/cppcheck_de.ts | 271 ++++++++++++++++++++------------ gui/cppcheck_en.ts | 271 ++++++++++++++++++++------------ gui/cppcheck_fi.ts | 271 ++++++++++++++++++++------------ gui/cppcheck_fr.ts | 82 ++++++++-- gui/cppcheck_ja.ts | 273 +++++++++++++++++++------------- gui/cppcheck_nl.ts | 271 ++++++++++++++++++++------------ gui/cppcheck_pl.ts | 269 ++++++++++++++++++-------------- gui/cppcheck_ru.ts | 267 ++++++++++++++++++------------- gui/cppcheck_se.ts | 279 +++++++++++++++++++++------------ gui/cppcheck_sr.ts | 271 ++++++++++++++++++++------------ gui/projectfile.ui | 302 +++++++++++++++++++++++------------- gui/projectfiledialog.cpp | 118 ++++++++------ gui/projectfiledialog.h | 44 ++++-- gui/resultstree.cpp | 5 +- gui/resultstree.h | 5 +- gui/settings.ui | 181 +++++++++++++-------- gui/settingsdialog.cpp | 126 +++++++++++---- gui/settingsdialog.h | 38 ++++- lib/checkclass.cpp | 34 ++-- lib/checkclass.h | 6 +- lib/preprocessor.cpp | 35 +++++ lib/preprocessor.h | 7 + lib/symboldatabase.cpp | 33 +++- lib/symboldatabase.h | 86 +++++++++- lib/tokenize.cpp | 13 +- lib/tokenize.h | 12 ++ test/testclass.cpp | 126 +++++++++++++-- test/testpreprocessor.cpp | 30 ++++ test/testsimplifytokens.cpp | 15 +- test/testsymboldatabase.cpp | 58 +++++++ test/testtokenize.cpp | 8 + 34 files changed, 2589 insertions(+), 1309 deletions(-) diff --git a/gui/applicationlist.cpp b/gui/applicationlist.cpp index 090733c7a..7dada872b 100644 --- a/gui/applicationlist.cpp +++ b/gui/applicationlist.cpp @@ -27,7 +27,8 @@ ApplicationList::ApplicationList(QObject *parent) : - QObject(parent) + QObject(parent), + mDefaultApplicationIndex(-1) { //ctor } @@ -42,6 +43,7 @@ void ApplicationList::LoadSettings(QSettings *programSettings) QStringList names = programSettings->value(SETTINGS_APPLICATION_NAMES, QStringList()).toStringList(); QStringList paths = programSettings->value(SETTINGS_APPLICATION_PATHS, QStringList()).toStringList(); + int defapp = programSettings->value(SETTINGS_APPLICATION_DEFAULT, -1).toInt(); if (names.empty() && paths.empty()) { @@ -50,28 +52,37 @@ void ApplicationList::LoadSettings(QSettings *programSettings) // use as default for gnome environments if (QFileInfo("/usr/bin/gedit").isExecutable()) { - AddApplicationType("gedit", "/usr/bin/gedit +(line) (file)"); + AddApplication("gedit", "/usr/bin/gedit +(line) (file)"); + defapp = 0; break; } // use as default for kde environments if (QFileInfo("/usr/bin/kate").isExecutable()) { - AddApplicationType("kate", "/usr/bin/kate -l(line) (file)"); + AddApplication("kate", "/usr/bin/kate -l(line) (file)"); + defapp = 0; break; } - // use as default for windows environments if (FindDefaultWindowsEditor()) + { + defapp = 0; break; + } } while (0); } - if (names.size() == paths.size()) + if (names.size() > 0 && (names.size() == paths.size())) { for (int i = 0; i < names.size(); i++) - { - AddApplicationType(names[i], paths[i]); - } + AddApplication(names[i], paths[i]); + + if (defapp == -1) + mDefaultApplicationIndex = 0; + else if (defapp < names.size()) + mDefaultApplicationIndex = defapp; + else + mDefaultApplicationIndex = 0; } } @@ -88,6 +99,7 @@ void ApplicationList::SaveSettings(QSettings *programSettings) programSettings->setValue(SETTINGS_APPLICATION_NAMES, names); programSettings->setValue(SETTINGS_APPLICATION_PATHS, paths); + programSettings->setValue(SETTINGS_APPLICATION_DEFAULT, mDefaultApplicationIndex); } @@ -117,9 +129,9 @@ QString ApplicationList::GetApplicationPath(const int index) const } -void ApplicationList::SetApplicationType(const int index, - const QString &name, - const QString &path) +void ApplicationList::SetApplication(const int index, + const QString &name, + const QString &path) { if (index >= 0 && index < mApplications.size()) { @@ -128,7 +140,7 @@ void ApplicationList::SetApplicationType(const int index, } } -void ApplicationList::AddApplicationType(const QString &name, const QString &path) +void ApplicationList::AddApplication(const QString &name, const QString &path) { if (name.isEmpty() || path.isEmpty()) { @@ -146,15 +158,15 @@ void ApplicationList::RemoveApplication(const int index) mApplications.removeAt(index); } -void ApplicationList::MoveFirst(const int index) +void ApplicationList::SetDefault(const int index) { - if (index < mApplications.size() && index > 0) + if (index < mApplications.size() && index >= 0) { - mApplications.move(index, 0); + mDefaultApplicationIndex = index; } } -void ApplicationList::Copy(ApplicationList *list) +void ApplicationList::Copy(const ApplicationList *list) { if (!list) { @@ -164,13 +176,15 @@ void ApplicationList::Copy(ApplicationList *list) Clear(); for (int i = 0; i < list->GetApplicationCount(); i++) { - AddApplicationType(list->GetApplicationName(i), list->GetApplicationPath(i)); + AddApplication(list->GetApplicationName(i), list->GetApplicationPath(i)); } + mDefaultApplicationIndex = list->GetDefaultApplication(); } void ApplicationList::Clear() { mApplications.clear(); + mDefaultApplicationIndex = -1; } bool ApplicationList::FindDefaultWindowsEditor() @@ -179,7 +193,7 @@ bool ApplicationList::FindDefaultWindowsEditor() const QString notepadppPath = appPath + "\\Notepad++\\notepad++.exe"; if (QFileInfo(notepadppPath).isExecutable()) { - AddApplicationType("Notepad++", "\"" + notepadppPath + "\" -n(line) (file)"); + AddApplication("Notepad++", "\"" + notepadppPath + "\" -n(line) (file)"); return true; } @@ -187,7 +201,7 @@ bool ApplicationList::FindDefaultWindowsEditor() const QString notepadPath = windowsPath + "\\system32\\notepad.exe"; if (QFileInfo(notepadPath).isExecutable()) { - AddApplicationType("Notepad", notepadPath + " (file)"); + AddApplication("Notepad", notepadPath + " (file)"); return true; } return false; diff --git a/gui/applicationlist.h b/gui/applicationlist.h index 2cbc19156..9bad886a8 100644 --- a/gui/applicationlist.h +++ b/gui/applicationlist.h @@ -56,7 +56,7 @@ public: typedef struct { /** - * @brief Applicaton's name + * @brief Application's name * */ QString Name; @@ -106,6 +106,15 @@ public: */ QString GetApplicationPath(const int index) const; + /** + * @brief Return the default application. + * @return Index of the default application. + */ + int GetDefaultApplication() const + { + return mDefaultApplicationIndex; + } + /** * @brief Modify an application * @@ -113,9 +122,8 @@ public: * @param name New name for the application * @param path New path for the application */ - void SetApplicationType(const int index, - const QString &name, - const QString &path); + void SetApplication(const int index, const QString &name, + const QString &path); /** * @brief Add a new application @@ -123,7 +131,7 @@ public: * @param name Name of the application * @param path Path to the application */ - void AddApplicationType(const QString &name, const QString &path); + void AddApplication(const QString &name, const QString &path); /** * @brief Remove an application from the list @@ -133,21 +141,18 @@ public: void RemoveApplication(const int index); /** - * @brief Move certain application as first. - * Position of the application is used by the application to determine - * which of the applications is the default application. First application - * (index 0) is the default application. - * + * @brief Set application as default application. * @param index Index of the application to make the default one */ - void MoveFirst(const int index); + void SetDefault(const int index); /** * @brief Remove all applications from this list and copy all applications from * list given as a parameter. * @param list Copying source */ - void Copy(ApplicationList *list); + void Copy(const ApplicationList *list); + protected: /** @@ -162,12 +167,19 @@ protected: */ bool FindDefaultWindowsEditor(); +private: + /** * @brief List of applications * */ QList mApplications; -private: + + /** + * @brief Index of the default application. + * + */ + int mDefaultApplicationIndex; }; /// @} #endif // APPLICATIONLIST_H diff --git a/gui/common.h b/gui/common.h index 7f3b5669b..6d9383ad2 100644 --- a/gui/common.h +++ b/gui/common.h @@ -77,6 +77,7 @@ ShowTypes; #define SETTINGS_SAVE_FULL_PATH "Save full path" #define SETTINGS_APPLICATION_NAMES "Application names" #define SETTINGS_APPLICATION_PATHS "Application paths" +#define SETTINGS_APPLICATION_DEFAULT "Default Application" #define SETTINGS_LANGUAGE "Application language" #define SETTINGS_GLOBAL_INCLUDE_PATHS "Global include paths" #define SETTINGS_INLINE_SUPPRESSIONS "Inline suppressions" diff --git a/gui/cppcheck_de.ts b/gui/cppcheck_de.ts index 99899b8ae..4d41ecd63 100644 --- a/gui/cppcheck_de.ts +++ b/gui/cppcheck_de.ts @@ -220,12 +220,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -537,97 +537,103 @@ kate -l(line) (file) &Hilfe - + Select files to check Dateien zum Überprüfen auswählen - + Select directory to check Verzeichnis zum Überprüfen auswählen - + No suitable files found to check! Kein passenden Dateien zum Überprüfen gefunden! - + License Lizenz - + Authors Autoren - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML-Dateien (*.xml);;Textdateien (*.txt);;CSV-Dateien (*.csv) - + Save the report file Speichert die Berichtdatei - + XML files (*.xml) XML-Dateien (*.xml) - + You must close the project file before selecting new files or directories! - - - + + + Project: - + Open the report file - + Checking is running. Do you want to stop the checking and exit Cppcheck?. - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) Textdateien (*.txt) - + CSV files (*.csv) CSV-Dateien (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + + Failed to change the language: + +%1 + + + Failed to change the language: %1 @@ -636,56 +642,56 @@ Do you want to stop the checking and exit Cppcheck?. Failed to change language: %1 - Fehler beim Ändern der Sprache: + Fehler beim Ändern der Sprache: %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 - + Finnish Finnisch - + English Englisch @@ -695,33 +701,38 @@ Do you want to stop the checking and exit Cppcheck?. Niederländisch - + + French + + + + Swedish Schwedisch - + German Deutsch - + Russian Russisch - + Polish Polnisch - + Japanese Japanease - + Serbian @@ -753,28 +764,50 @@ Do you want to stop the checking and exit Cppcheck?. - + + Project + + + + Project: - + Paths: - - - Browse... + + + Add... - - Include paths: + + + Edit - + + + Remove + + + + + Includes + + + + + Include directories: + + + + Defines: @@ -800,18 +833,22 @@ Do you want to stop the checking and exit Cppcheck?. QObject - Incorrect language specified! - Falsche Sprache angegeben! + Falsche Sprache angegeben! - + + Unknown language specified! + + + + Language file %1 not found! Language file %1.qm not found! Sprachdatei %1 nicht gefunden! - + Failed to load translation for language %1 from file %2 Failed to load translation for language %1 from file %2.qm Die Übersetzungen der Sprache %1 konnten nicht aus der Datei %2 geladen werden @@ -821,71 +858,71 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File Datei - + Severity Schweregrad - + Line Zeile - + Summary - + Undefined file Undefinierte Datei - + Copy filename Dateiname kopieren - + Copy full path Vollständigen Pfad kopieren - + Copy message Meldung kopieren - + Hide - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. Konfigurieren Sie das Text-Dateibetrachter-Programm unter Einstellungen/Anwendungen. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. @@ -894,44 +931,44 @@ Please check the application path and parameters are correct. Bitte überprüfen Sie ob der Pfad und die Parameter der Anwendung richtig eingestellt sind. - + Could not find file: %1 Please select the directory where file is located. - + Select Directory - + style Stil - + error Fehler - + warning - + performance - + portability - + information @@ -1003,98 +1040,121 @@ Legen Sie unter dem Menü Ansicht fest, welche Art von Fehlern angezeigt werden Allgemein - + Include paths: - + + Add... - + Number of threads: Anzahl der Threads: - + Ideal count: - + TextLabel - + Force checking all #ifdef configurations Check all #ifdef configurations Alle #ifdef-Konfigurationen überprüfen - + Show full path of files Vollständigen Dateipfad anzeigen - + Show "No errors found" message when no errors found "Keine Fehler gefunden"-Meldung anzeigen, wenn keine Fehler gefunden werden - + Show internal warnings in log - + Enable inline suppressions - + + Paths + + + + + Edit + + + + + + Remove + + + + Applications Anwendungen - + + Edit... + + + + + Set as default + + + Add application - Anwendung hinzufügen + Anwendung hinzufügen - Delete application - Anwendung löschen + Anwendung löschen - Modify application - Anwendung ändern + Anwendung ändern - Set as default application - Als Standard-Anwendung verwenden + Als Standard-Anwendung verwenden - + Reports Berichte - + Save all errors when creating report Alle Fehler beim Erstellen von Berichten speichern - + Save full path to files in reports Vollständigen Dateipfad in Berichten speichern - + Language @@ -1102,22 +1162,27 @@ Legen Sie unter dem Menü Ansicht fest, welche Art von Fehlern angezeigt werden SettingsDialog - + N/A - + Add a new application Neue Anwendung hinzufügen - + Modify an application Anwendung ändern - + + [Default] + + + + Select include directory diff --git a/gui/cppcheck_en.ts b/gui/cppcheck_en.ts index 4621571d1..926c62f56 100644 --- a/gui/cppcheck_en.ts +++ b/gui/cppcheck_en.ts @@ -222,12 +222,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -539,97 +539,103 @@ kate -l(line) (file) &Help - + Select files to check Select files to check - + Select directory to check Select directory to check - + No suitable files found to check! No suitable files found to check! - + License License - + Authors Authors - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Save the report file Save the report file - + XML files (*.xml) XML files (*.xml) - + You must close the project file before selecting new files or directories! - - - + + + Project: - + Open the report file - + Checking is running. Do you want to stop the checking and exit Cppcheck?. - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + + Failed to change the language: + +%1 + + + Failed to change the language: %1 @@ -638,54 +644,54 @@ Do you want to stop the checking and exit Cppcheck?. Failed to change language: %1 - Failed to change language: + Failed to change language: %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 - + Finnish Finnish - + English English @@ -695,33 +701,38 @@ Do you want to stop the checking and exit Cppcheck?. - + + French + + + + Swedish Swedish - + German German - + Russian Russian - + Polish Polish - + Japanese Japanease - + Serbian Serbian @@ -753,28 +764,50 @@ Do you want to stop the checking and exit Cppcheck?. - + + Project + + + + Project: - + Paths: - - - Browse... + + + Add... - - Include paths: + + + Edit - + + + Remove + + + + + Includes + + + + + Include directories: + + + + Defines: @@ -800,18 +833,22 @@ Do you want to stop the checking and exit Cppcheck?. QObject - Incorrect language specified! - Incorrect language specified! + Incorrect language specified! - + + Unknown language specified! + + + + Language file %1 not found! Language file %1.qm not found! Could not find the file: %1! - + Failed to load translation for language %1 from file %2 Failed to load translation for language %1 from file %2.qm Failed to load translation for language %1 from file %2 @@ -821,71 +858,71 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File File - + Severity Severity - + Line Line - + Summary - + Undefined file Undefined file - + Copy filename Copy filename - + Copy full path Copy full path - + Copy message - + Hide - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. You can open this error by specifying applications in program's settings. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. @@ -894,44 +931,44 @@ Please check the application path and parameters are correct. Please check the application path and parameters are correct. - + Could not find file: %1 Please select the directory where file is located. - + Select Directory - + style Style - + error Error - + warning - + performance - + portability - + information @@ -1003,98 +1040,121 @@ To toggle what kind of errors are shown, open view menu. General - + Include paths: - + + Add... - + Number of threads: Number of threads: - + Ideal count: - + TextLabel - + Force checking all #ifdef configurations Check all #ifdef configurations Check all #ifdef configurations - + Show full path of files Show full path of files - + Show "No errors found" message when no errors found Show "No errors found" message when no errors found - + Show internal warnings in log - + Enable inline suppressions - + + Paths + + + + + Edit + + + + + + Remove + + + + Applications Applications - + + Edit... + + + + + Set as default + + + Add application - Add application + Add application - Delete application - Delete application + Delete application - Modify application - Modify application + Modify application - Set as default application - Set as default application + Set as default application - + Reports Reports - + Save all errors when creating report Save all errors when creating report - + Save full path to files in reports Save full path to files in reports - + Language @@ -1102,22 +1162,27 @@ To toggle what kind of errors are shown, open view menu. SettingsDialog - + N/A - + Add a new application Add a new application - + Modify an application Modify an application - + + [Default] + + + + Select include directory diff --git a/gui/cppcheck_fi.ts b/gui/cppcheck_fi.ts index f336f63c2..afc617cb1 100644 --- a/gui/cppcheck_fi.ts +++ b/gui/cppcheck_fi.ts @@ -224,12 +224,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -541,97 +541,103 @@ kate -l(line) (file) &Ohje - + Select files to check Valitse tarkistettavat tiedostot - + Select directory to check Valitse tarkistettava hakemisto - + No suitable files found to check! Tarkistettavaksi sopivia tiedostoja ei löytynyt! - + License Lisenssi - + Authors Tekijät - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML-tiedostot (*.xml);;Tekstitiedostot (*.txt);;CSV-tiedostot (*.csv) - + Save the report file Tallenna raportti - + XML files (*.xml) XML-tiedostot (*xml) - + You must close the project file before selecting new files or directories! - - - + + + Project: - + Open the report file - + Checking is running. Do you want to stop the checking and exit Cppcheck?. - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) Tekstitiedostot (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + + Failed to change the language: + +%1 + + + Failed to change the language: %1 @@ -640,56 +646,56 @@ Do you want to stop the checking and exit Cppcheck?. Failed to change language: %1 - Ohjelman kielen vaihtaminen epäonnistui: + Ohjelman kielen vaihtaminen epäonnistui: %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 - + Finnish Suomi - + English Englanti @@ -699,33 +705,38 @@ Do you want to stop the checking and exit Cppcheck?. - + + French + + + + Swedish Ruotsi - + German Saksa - + Russian Venäjä - + Polish Puola - + Japanese Japanease - + Serbian @@ -757,28 +768,50 @@ Do you want to stop the checking and exit Cppcheck?. - + + Project + + + + Project: - + Paths: - - - Browse... + + + Add... - - Include paths: + + + Edit - + + + Remove + + + + + Includes + + + + + Include directories: + + + + Defines: @@ -804,18 +837,22 @@ Do you want to stop the checking and exit Cppcheck?. QObject - Incorrect language specified! - Virheellinen kieli valittu! + Virheellinen kieli valittu! - + + Unknown language specified! + + + + Language file %1 not found! Language file %1.qm not found! Käännöstiedostoa %1 ei löytynyt! - + Failed to load translation for language %1 from file %2 Failed to load translation for language %1 from file %2.qm Käänöksen lataaminen kielelle %1 tiedostosta %2 epäonnistui @@ -825,71 +862,71 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File Tiedosto - + Severity Tyyppi - + Line Rivi - + Summary - + Undefined file Määrittelemätön tiedosto - + Copy filename Kopioi tiedostonimi - + Copy full path Kopioi tiedoston koko polku - + Copy message - + Hide - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. Voit asetuksista määritellä muita ohjelmia joilla avata tämän virheen sisältävän tiedoston. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. @@ -898,44 +935,44 @@ Please check the application path and parameters are correct. Tarkista että ohjelman polku ja parametrit ovat oikeat. - + Could not find file: %1 Please select the directory where file is located. - + Select Directory - + style Tyyli - + error Yleinen - + warning - + performance - + portability - + information @@ -1007,98 +1044,121 @@ Määrittääksesi minkä tyyppisiä virheitä näytetään, avaa näkymä valik Yleiset - + Include paths: - + + Add... - + Number of threads: Säikeiden lukumäärä: - + Ideal count: - + TextLabel - + Force checking all #ifdef configurations Check all #ifdef configurations Tarkista kaikki #ifdef kombinaatiot - + Show full path of files Näytä tiedostojen täysi polku - + Show "No errors found" message when no errors found Näytä "virheitä ei löytynyt"-viesti jos virheitä ei löydy - + Show internal warnings in log - + Enable inline suppressions - + + Paths + + + + + Edit + + + + + + Remove + + + + Applications Ohjelmat - + + Edit... + + + + + Set as default + + + Add application - Lisää ohjelma + Lisää ohjelma - Delete application - Poista ohjelma + Poista ohjelma - Modify application - Muokkaa ohjelmaa + Muokkaa ohjelmaa - Set as default application - Aseta oletusohjelmaksi + Aseta oletusohjelmaksi - + Reports Raportit - + Save all errors when creating report Tallenna kaikki virheet raporttia luodessa - + Save full path to files in reports Tallenna tiedostojen koko polku raportteihin - + Language @@ -1106,22 +1166,27 @@ Määrittääksesi minkä tyyppisiä virheitä näytetään, avaa näkymä valik SettingsDialog - + N/A - + Add a new application Lisää uusi ohjelma - + Modify an application Muokkaa ohjelmaa - + + [Default] + + + + Select include directory diff --git a/gui/cppcheck_fr.ts b/gui/cppcheck_fr.ts index bd9e29e7e..1c512ee03 100644 --- a/gui/cppcheck_fr.ts +++ b/gui/cppcheck_fr.ts @@ -339,7 +339,7 @@ kate -l(ligne) (fichier) %1 - Erreur lors du chargement de la langue : + Erreur lors du chargement de la langue : %1 @@ -563,6 +563,16 @@ Do you want to stop the checking and exit Cppcheck?. Serbian + + Failed to change the language: + +%1 + + + + French + + Project @@ -593,18 +603,34 @@ Do you want to stop the checking and exit Cppcheck?. Paths: - - Browse... - - - - Include paths: - - Defines: + + Project + + + + Add... + + + + Edit + + + + Remove + + + + Includes + + + + Include directories: + + ProjectFileDialog @@ -625,7 +651,7 @@ Do you want to stop the checking and exit Cppcheck?. QObject Incorrect language specified! - Langue incorrecte ! + Langue incorrecte ! Language file %1 not found! @@ -635,6 +661,10 @@ Do you want to stop the checking and exit Cppcheck?. Failed to load translation for language %1 from file %2 Erreur lors du chargement de la langue %1 depuis le fichier %2 + + Unknown language specified! + + ResultsTree @@ -798,19 +828,19 @@ Pour configurer les erreurs affichées, ouvrez le menu d'affichage. Add application - Ajouter une application + Ajouter une application Delete application - Supprimer l'application + Supprimer l'application Modify application - Modifier l'application + Modifier l'application Set as default application - Définir comme application par défaut + Définir comme application par défaut Reports @@ -856,6 +886,26 @@ Pour configurer les erreurs affichées, ouvrez le menu d'affichage.Language + + Paths + + + + Edit + + + + Remove + + + + Edit... + + + + Set as default + + SettingsDialog @@ -875,6 +925,10 @@ Pour configurer les erreurs affichées, ouvrez le menu d'affichage.Select include directory + + [Default] + + StatsDialog diff --git a/gui/cppcheck_ja.ts b/gui/cppcheck_ja.ts index 12d8c80ca..9b244d533 100644 --- a/gui/cppcheck_ja.ts +++ b/gui/cppcheck_ja.ts @@ -208,12 +208,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -525,44 +525,44 @@ kate -l(line) (file) ログ表示 - + No suitable files found to check! 解析可能なファイルではありません - + You must close the project file before selecting new files or directories! 新しいファイル/ディレクトリを解析するには現在のプロジェクトを閉じてください - + Select files to check チェック対象のファイルを選択 - + Select directory to check チェック対象のディレクトリを選択 - - - + + + Project: プロジェクト: - + XML files (*.xml) XML ファイル (*.xml) - + Open the report file レポートを開く - + Checking is running. Do you want to stop the checking and exit Cppcheck?. @@ -571,103 +571,109 @@ Do you want to stop the checking and exit Cppcheck?. 解析を停止してCppcheckを終了しますか?. - + License ライセンス - + Authors 作者 - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML ファイル (*.xml);;テキストファイル (*.txt);;CSV形式ファイル (*.csv) - + Save the report file レポートを保存 - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) テキストファイル (*.txt) - + CSV files (*.csv) CSV形式ファイル (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + + Failed to change the language: + +%1 + + + Failed to change the language: %1 - 言語の切り替えに失敗: + 言語の切り替えに失敗: %1 + - 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 プロジェクトファイルが読み込まれていません - + English @@ -677,38 +683,43 @@ Do you want to stop the checking and exit Cppcheck?. - + Finnish - + + French + + + + Swedish - + German - + Russian - + Polish - + Japanese Japanease - + Serbian @@ -740,28 +751,54 @@ Do you want to stop the checking and exit Cppcheck?. プロジェクトファイル - + + Project + プロジェクト + + + Project: プロジェクト名: - + Paths: パス: - - - Browse... - + + + Add... + 追加... + + + + + Edit + + + + + + Remove + + + + + Includes + + + + + Include directories: + - Include paths: - Include ディレクトリ: + Include ディレクトリ: - + Defines: Defines: @@ -787,17 +824,17 @@ Do you want to stop the checking and exit Cppcheck?. QObject - - Incorrect language specified! + + Unknown language specified! - + Language file %1 not found! 言語ファイル %1 が見つかりません! - + Failed to load translation for language %1 from file %2 @@ -806,70 +843,70 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File ファイル - + Severity 警告種別 - + Line - + Summary 内容 - + Undefined file 未定義ファイル - + Copy filename ファイル名をコピー - + Copy full path フルパスをコピー - + Copy message メッセージをコピー - + Hide 非表示 - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. メニューの「編集」→「設定」からテキストファイルを表示するアプリケーションを設定してください。 - + Could not find the file! ファイルが見つかりません - + Could not start %1 Please check the application path and parameters are correct. @@ -878,7 +915,7 @@ Please check the application path and parameters are correct. 実行ファイルパスや引数の設定を確認してください。 - + Could not find file: %1 Please select the directory where file is located. @@ -887,37 +924,37 @@ Please select the directory where file is located. ディレクトリにファイルが存在するか確認してください。 - + Select Directory ディレクトリを選択 - + style スタイル - + error エラー - + warning 警告 - + performance パフォーマンス - + portability - + information @@ -988,98 +1025,121 @@ To toggle what kind of errors are shown, open view menu. 全般 - + Include paths: Include ディレクトリ: - + + Add... 追加... - + Number of threads: 解析スレッド数: - + Ideal count: - + TextLabel - + Force checking all #ifdef configurations Check all #ifdef configurations すべての #ifdef をチェックする - + Show full path of files ファイルのフルパスを表示 - + Show "No errors found" message when no errors found エラーが無いときは"エラーなし"を表示 - + Show internal warnings in log cppcheck内部警告をログに表示する - + Enable inline suppressions - + + Paths + + + + + Edit + + + + + + Remove + + + + Applications アプリケーション - + + Edit... + + + + + Set as default + + + Add application - アプリケーションを追加 + アプリケーションを追加 - Delete application - アプリケーションの削除 + アプリケーションの削除 - Modify application - アプリケーション設定の変更 + アプリケーション設定の変更 - Set as default application - デフォルトアプリケーションに設定 + デフォルトアプリケーションに設定 - + Reports レポート - + Save all errors when creating report すべての警告/エラーを保存 - + Save full path to files in reports ファイルのフルパスを保存 - + Language @@ -1087,22 +1147,27 @@ To toggle what kind of errors are shown, open view menu. SettingsDialog - + N/A - + Add a new application 新しいアプリケーションの追加 - + Modify an application アプリケーションの変更 - + + [Default] + + + + Select include directory include ディレクトリを選択 diff --git a/gui/cppcheck_nl.ts b/gui/cppcheck_nl.ts index e34529164..957f80c22 100644 --- a/gui/cppcheck_nl.ts +++ b/gui/cppcheck_nl.ts @@ -222,12 +222,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -539,97 +539,103 @@ kate -l(line) (file) &Help - + Select files to check Selecteer bestanden om te controleren - + Select directory to check Selecteer een map om te controleren - + No suitable files found to check! Geen geschikte bestanden gevonden om te controleren! - + License Licentie - + Authors Auteurs - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML bestanden (*.xml);;Tekst bestanden (*.txt);;CSV bestanden (*.csv) - + Save the report file Rapport opslaan - + XML files (*.xml) XML bestanden (*.xml) - + You must close the project file before selecting new files or directories! - - - + + + Project: - + Open the report file - + Checking is running. Do you want to stop the checking and exit Cppcheck?. - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) Tekst bestanden (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + + Failed to change the language: + +%1 + + + Failed to change the language: %1 @@ -638,54 +644,54 @@ Do you want to stop the checking and exit Cppcheck?. Failed to change language: %1 - Kon de taal niet wisselen: + Kon de taal niet wisselen: %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 - + Finnish Fins - + English Engels @@ -695,33 +701,38 @@ Do you want to stop the checking and exit Cppcheck?. Nederlands - + + French + + + + Swedish Zweeds - + German Duits - + Russian Russisch - + Polish Pools - + Japanese Japanease - + Serbian @@ -753,28 +764,50 @@ Do you want to stop the checking and exit Cppcheck?. - + + Project + + + + Project: - + Paths: - - - Browse... + + + Add... - - Include paths: + + + Edit - + + + Remove + + + + + Includes + + + + + Include directories: + + + + Defines: @@ -800,18 +833,22 @@ Do you want to stop the checking and exit Cppcheck?. QObject - Incorrect language specified! - Ongeldige taal gespecifieerd! + Ongeldige taal gespecifieerd! - + + Unknown language specified! + + + + Language file %1 not found! Language file %1.qm not found! Kon het taalbestand niet vinden: %1! - + Failed to load translation for language %1 from file %2 Failed to load translation for language %1 from file %2.qm Kon de vertaling voor taal %1 in bestand %2 niet laden @@ -821,71 +858,71 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File Bestand - + Severity Ernst - + Line Regel - + Summary - + Undefined file Niet gedefinieerd bestand - + Copy filename Kopier bestandsnaam - + Copy full path Kopieer volledig pad - + Copy message - + Hide - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. U dient een applicatie te configureren in de instellingen om deze fout in te openen. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. @@ -894,44 +931,44 @@ Please check the application path and parameters are correct. Gelieve te controleren of de het pad en de parameters correct zijn. - + Could not find file: %1 Please select the directory where file is located. - + Select Directory - + style Stijlfouten - + error Fouten - + warning - + performance - + portability - + information @@ -1003,98 +1040,121 @@ Gebruik het uitzicht menu om te selecteren welke fouten getoond worden.Algemeen - + Include paths: - + + Add... - + Number of threads: Aantal threads: - + Ideal count: - + TextLabel - + Force checking all #ifdef configurations Check all #ifdef configurations Controleer alle #ifdef combinaties - + Show full path of files Toon het volledige pad van bestanden - + Show "No errors found" message when no errors found Toon "Geen fouten gevonden" indien geen fouten gevonden werden - + Show internal warnings in log - + Enable inline suppressions - + + Paths + + + + + Edit + + + + + + Remove + + + + Applications Applicaties - + + Edit... + + + + + Set as default + + + Add application - Applicatie toevoegen + Applicatie toevoegen - Delete application - Applicatie verwijderen + Applicatie verwijderen - Modify application - Applicatie wijzigen + Applicatie wijzigen - Set as default application - Configureer als standaard applicatie + Configureer als standaard applicatie - + Reports Rapporten - + Save all errors when creating report Alle fouten opslaan - + Save full path to files in reports Volledig pad opslaan - + Language @@ -1102,22 +1162,27 @@ Gebruik het uitzicht menu om te selecteren welke fouten getoond worden. SettingsDialog - + N/A - + Add a new application Nieuwe applicatie toevoegen - + Modify an application Applicatie wijzigen - + + [Default] + + + + Select include directory diff --git a/gui/cppcheck_pl.ts b/gui/cppcheck_pl.ts index f80b37956..e00aa58de 100644 --- a/gui/cppcheck_pl.ts +++ b/gui/cppcheck_pl.ts @@ -209,12 +209,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck @@ -526,143 +526,141 @@ kate -l(line) (file) - + No suitable files found to check! - + You must close the project file before selecting new files or directories! - + Select files to check - + Select directory to check - - - + + + Project: - + Open the report file - + License - + Authors - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Save the report file - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) + + Failed to change the language: + +%1 + + + + - Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - + Select Project Filename - + No project file loaded - + XML files (*.xml) - + Checking is running. Do you want to stop the checking and exit Cppcheck?. - + Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 - - Failed to change the language: - -%1 - - - - - - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File - + English @@ -672,38 +670,43 @@ Do you want to stop the checking and exit Cppcheck?. - + Finnish - + + French + + + + Swedish - + German - + Russian - + Polish - + Japanese Japanease - + Serbian @@ -735,28 +738,50 @@ Do you want to stop the checking and exit Cppcheck?. - + + Project + + + + Project: - + Paths: - - - Browse... + + + Add... - - Include paths: + + + Edit - + + + Remove + + + + + Includes + + + + + Include directories: + + + + Defines: @@ -782,17 +807,17 @@ Do you want to stop the checking and exit Cppcheck?. QObject - - Incorrect language specified! + + Unknown language specified! - + Language file %1 not found! - + Failed to load translation for language %1 from file %2 @@ -801,114 +826,114 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File - + Severity - + Line - + Summary - + Undefined file - + Copy filename - + Copy full path - + Copy message - + Hide - + Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. - + Could not find file: %1 Please select the directory where file is located. - + Select Directory - + style - + error - + warning - + performance - + portability - + information @@ -979,98 +1004,105 @@ To toggle what kind of errors are shown, open view menu. - + Include paths: - + + Add... - + Number of threads: - + Ideal count: - + TextLabel - + Force checking all #ifdef configurations Check all #ifdef configurations - + Show full path of files - + Show "No errors found" message when no errors found - + Show internal warnings in log - + Enable inline suppressions - + + Paths + + + + + Edit + + + + + + Remove + + + + Applications - - Add application + + Edit... - - Delete application + + Set as default - - Modify application - - - - - Set as default application - - - - + Reports - + Save all errors when creating report - + Save full path to files in reports - + Language @@ -1078,22 +1110,27 @@ To toggle what kind of errors are shown, open view menu. SettingsDialog - + N/A - + Add a new application - + Modify an application - + + [Default] + + + + Select include directory diff --git a/gui/cppcheck_ru.ts b/gui/cppcheck_ru.ts index 9bc1aecb2..8f66703e5 100644 --- a/gui/cppcheck_ru.ts +++ b/gui/cppcheck_ru.ts @@ -212,12 +212,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -529,97 +529,103 @@ kate -l(line) (file) Помощь - + Select files to check Выберите файлы для проверки - + Select directory to check Выберите каталог для проверки - + No suitable files found to check! - + License Лицензия - + Authors Авторы - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Save the report file - + XML files (*.xml) - + You must close the project file before selecting new files or directories! - - - + + + Project: - + Open the report file - + Checking is running. Do you want to stop the checking and exit Cppcheck?. - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) Текстовые файлы (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + + Failed to change the language: + +%1 + + + Failed to change the language: %1 @@ -628,56 +634,56 @@ Do you want to stop the checking and exit Cppcheck?. Failed to change language: %1 - Невозможно изменить язык приложения: + Невозможно изменить язык приложения: %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 - + Finnish Финский - + English Английский @@ -687,33 +693,38 @@ Do you want to stop the checking and exit Cppcheck?. - + + French + + + + Swedish Швецкий - + German Немецкий - + Russian Русский - + Polish - + Japanese Japanease - + Serbian @@ -745,28 +756,50 @@ Do you want to stop the checking and exit Cppcheck?. - + + Project + + + + Project: - + Paths: - - - Browse... + + + Add... - - Include paths: + + + Edit - + + + Remove + + + + + Includes + + + + + Include directories: + + + + Defines: @@ -792,18 +825,22 @@ Do you want to stop the checking and exit Cppcheck?. QObject - Incorrect language specified! - Выбран неверный язык! + Выбран неверный язык! - + + Unknown language specified! + + + + Language file %1 not found! Language file %1.qm not found! - + Failed to load translation for language %1 from file %2 Failed to load translation for language %1 from file %2.qm Ошибка загрузки переводов для языка %1 из файла %2 @@ -813,115 +850,115 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File Файл - + Severity Важность - + Line Строка - + Summary - + Undefined file - + Copy filename Скопировать имя файла - + Copy full path Скопировать полный путь - + Copy message - + Hide - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. - + Could not find file: %1 Please select the directory where file is located. - + Select Directory - + style - + error - + warning - + performance - + portability - + information @@ -992,98 +1029,105 @@ To toggle what kind of errors are shown, open view menu. Общие - + Include paths: - + + Add... - + Number of threads: Количество потоков исполнения: - + Ideal count: - + TextLabel - + Force checking all #ifdef configurations Check all #ifdef configurations Проверять все варианты #ifdef конфигураций - + Show full path of files Показывать полные пути к файлам - + Show "No errors found" message when no errors found Показывать сообщение, если ошибок не найдено - + Show internal warnings in log - + Enable inline suppressions - + + Paths + + + + + Edit + + + + + + Remove + + + + Applications - - Add application + + Edit... - - Delete application + + Set as default - - Modify application - - - - - Set as default application - - - - + Reports Отчёты - + Save all errors when creating report Сохранять все ошибки при создании отчёта - + Save full path to files in reports Сохранять полные пути к файлам в отчётах - + Language @@ -1091,22 +1135,27 @@ To toggle what kind of errors are shown, open view menu. SettingsDialog - + N/A - + Add a new application - + Modify an application - + + [Default] + + + + Select include directory diff --git a/gui/cppcheck_se.ts b/gui/cppcheck_se.ts index 593a59fa7..3cdea4876 100644 --- a/gui/cppcheck_se.ts +++ b/gui/cppcheck_se.ts @@ -222,12 +222,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -540,65 +540,65 @@ kate -l(line) (file) &Hjälp - + Select files to check Välj filer att kontrollera - + Select directory to check Välj katalog som skall kontrolleras - + No suitable files found to check! Inga lämpliga filer hittades! - + License Licens - + Authors Utvecklare - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML filer (*.xml);;Text filer (*.txt);;CSV filer (*.csv) - + Save the report file Spara rapport - + XML files (*.xml) XML filer (*.xml) - + You must close the project file before selecting new files or directories! Du måste stänga projektfilen innan nya filer eller sökvägar kan väljas! - - - + + + Project: Projekt. - + Open the report file Öppna rapportfilen - + Checking is running. Do you want to stop the checking and exit Cppcheck?. @@ -607,32 +607,38 @@ 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 + + + Failed to change the language: %1 @@ -641,56 +647,56 @@ Vill du stoppa analysen och avsluta Cppcheck? Failed to change language: %1 - Misslyckades med att byta språk: + Misslyckades med att byta språk: %1 + - 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 - + Finnish Finska - + English Engelska @@ -700,33 +706,38 @@ Vill du stoppa analysen och avsluta Cppcheck? Nederländska - + + French + + + + Swedish Svenska - + German Tyska - + Russian Ryska - + Polish Polska - + Japanese Japanease Japanska - + Serbian Serbiska @@ -758,28 +769,58 @@ Vill du stoppa analysen och avsluta Cppcheck? Projektfil - + + Project + Projekt + + + Project: Projekt: - + Paths: Sökvägar: - - + + + Add... + Lägg till... + + + + + Edit + + + + + + Remove + + + + + Includes + + + + + Include directories: + + + Browse... - Bläddra... + Bläddra... - Include paths: - Include sökvägar: + Include sökvägar: - + Defines: Defines: @@ -805,18 +846,22 @@ Vill du stoppa analysen och avsluta Cppcheck? QObject - Incorrect language specified! - valt språk är ej korrekt! + valt språk är ej korrekt! - + + Unknown language specified! + + + + Language file %1 not found! Language file %1.qm not found! Språk filen %1 hittades ej! - + Failed to load translation for language %1 from file %2 Failed to load translation for language %1 from file %2.qm Misslyckades med att ladda översättningen för %1 från filen %2 @@ -826,71 +871,71 @@ Vill du stoppa analysen och avsluta Cppcheck? ResultsTree - + File Fil - + Severity Typ - + Line Rad - + Summary Sammanfattning - + Undefined file Odefinierad fil - + Copy filename Kopiera filnamn - + Copy full path Kopiera full sökväg - + Copy message Kopiera meddelande - + Hide Dölj - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. Konfigurera program i inställningar/program. - + Could not find the file! Kunde inte hitta filen! - + Could not start %1 Please check the application path and parameters are correct. @@ -899,7 +944,7 @@ Please check the application path and parameters are correct. Kontrollera att sökvägen och parametrarna är korrekta. - + Could not find file: %1 Please select the directory where file is located. @@ -908,37 +953,37 @@ Please select the directory where file is located. Välj mappen där filen finns. - + Select Directory Välj mapp - + style stil - + error fel - + warning varning - + performance prestanda - + portability portabilitet - + information information @@ -1010,98 +1055,121 @@ För att ställa in vilka fel som skall visas använd visa menyn. Allmänt - + Include paths: Include sökvägar: - + + Add... Lägg till... - + Number of threads: Antal trådar: - + Ideal count: Optimalt värde: - + TextLabel TextLabel - + Force checking all #ifdef configurations Check all #ifdef configurations Kontrollera alla #ifdef konfigurationer - + Show full path of files Visa den fulla sökvägen för filer - + Show "No errors found" message when no errors found Visa "Inga fel hittades" meddelande när inga fel hittas - + Show internal warnings in log Visa interna fel i loggen - + Enable inline suppressions Använd inline suppressions - + + Paths + + + + + Edit + + + + + + Remove + + + + Applications Program - + + Edit... + + + + + Set as default + + + Add application - Lägg till program + Lägg till program - Delete application - Ta bort program + Ta bort program - Modify application - Ändra program + Ändra program - Set as default application - Ange som standard program + Ange som standard program - + Reports Rapporter - + Save all errors when creating report Spara alla fel - + Save full path to files in reports Spara fulla sökvägar - + Language Språk @@ -1109,22 +1177,27 @@ För att ställa in vilka fel som skall visas använd visa menyn. SettingsDialog - + N/A Ej tillgängligt - + Add a new application Lägg till program - + Modify an application Ändra program - + + [Default] + + + + Select include directory Välj include mapp diff --git a/gui/cppcheck_sr.ts b/gui/cppcheck_sr.ts index 91eb79c7a..fa23f823a 100644 --- a/gui/cppcheck_sr.ts +++ b/gui/cppcheck_sr.ts @@ -222,12 +222,12 @@ kate -l(line) (file) MainWindow - - - - - - + + + + + + Cppcheck Cppcheck @@ -539,97 +539,103 @@ kate -l(line) (file) &Help - + Select files to check Select files to check - + Select directory to check Select directory to check - + No suitable files found to check! No suitable files found to check! - + License License - + Authors Authors - + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Save the report file Save the report file - + XML files (*.xml) XML files (*.xml) - + You must close the project file before selecting new files or directories! - - - + + + Project: - + Open the report file - + Checking is running. Do you want to stop the checking and exit Cppcheck?. - + XML files version 1 (*.xml) - + XML files version 2 (*.xml) - + Text files (*.txt) Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + + Failed to change the language: + +%1 + + + Failed to change the language: %1 @@ -638,54 +644,54 @@ Do you want to stop the checking and exit Cppcheck?. Failed to change language: %1 - Failed to change language: + Failed to change language: %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 - + Finnish Finski - + English Engleski @@ -695,33 +701,38 @@ Do you want to stop the checking and exit Cppcheck?. Holandski - + + French + + + + Swedish Švedski - + German Nemački - + Russian Ruski - + Polish Poljski - + Japanese Japanease Japanski - + Serbian Srpski @@ -753,28 +764,50 @@ Do you want to stop the checking and exit Cppcheck?. - + + Project + + + + Project: - + Paths: - - - Browse... + + + Add... - - Include paths: + + + Edit - + + + Remove + + + + + Includes + + + + + Include directories: + + + + Defines: @@ -800,18 +833,22 @@ Do you want to stop the checking and exit Cppcheck?. QObject - Incorrect language specified! - Incorrect language specified! + Incorrect language specified! - + + Unknown language specified! + + + + Language file %1 not found! Language file %1.qm not found! Could not find the file: %1! - + Failed to load translation for language %1 from file %2 Failed to load translation for language %1 from file %2.qm Failed to load translation for language %1 from file %2 @@ -821,71 +858,71 @@ Do you want to stop the checking and exit Cppcheck?. ResultsTree - + File File - + Severity Severity - + Line Line - + Summary - + Undefined file Undefined file - + Copy filename Copy filename - + Copy full path Copy full path - + Copy message - + Hide - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. You can open this error by specifying applications in program's settings. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. @@ -894,44 +931,44 @@ Please check the application path and parameters are correct. Please check the application path and parameters are correct. - + Could not find file: %1 Please select the directory where file is located. - + Select Directory - + style Style - + error Error - + warning - + performance - + portability - + information @@ -1003,98 +1040,121 @@ To toggle what kind of errors are shown, open view menu. General - + Include paths: - + + Add... - + Number of threads: Number of threads: - + Ideal count: - + TextLabel - + Force checking all #ifdef configurations Check all #ifdef configurations Check all #ifdef configurations - + Show full path of files Show full path of files - + Show "No errors found" message when no errors found Show "No errors found" message when no errors found - + Show internal warnings in log - + Enable inline suppressions - + + Paths + + + + + Edit + + + + + + Remove + + + + Applications Applications - + + Edit... + + + + + Set as default + + + Add application - Add application + Add application - Delete application - Delete application + Delete application - Modify application - Modify application + Modify application - Set as default application - Set as default application + Set as default application - + Reports Reports - + Save all errors when creating report Save all errors when creating report - + Save full path to files in reports Save full path to files in reports - + Language @@ -1102,22 +1162,27 @@ To toggle what kind of errors are shown, open view menu. SettingsDialog - + N/A - + Add a new application Add a new application - + Modify an application Modify an application - + + [Default] + + + + Select include directory diff --git a/gui/projectfile.ui b/gui/projectfile.ui index 6cc570c31..7a978159a 100644 --- a/gui/projectfile.ui +++ b/gui/projectfile.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 159 + 467 + 329 @@ -15,99 +15,188 @@ - - - - - Project: - - - mEditProjectRoot - - - - - - - - - - - - - - Paths: - - - mEditPaths - - - - - - - - - - Browse... - - - - - - - - - - - Include paths: - - - mEditIncludePaths - - - - - - - - - - Browse... - - - - - - - - - - - Defines: - - - mEditDefines - - - - - - - - - - - - Qt::Vertical + + + 1 - - - 20 - 40 - - - + + + Project + + + + + + + + + + Project: + + + mEditProjectRoot + + + + + + + + + + + + + + Defines: + + + mEditDefines + + + + + + + + + + + + + + + + Paths: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + Add... + + + + + + + Edit + + + + + + + Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + Includes + + + + + + Include directories: + + + + + + + + + QAbstractItemView::SelectRows + + + + + + + + + Add... + + + + + + + Edit + + + + + + + Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + @@ -122,13 +211,18 @@ - mEditProjectRoot - mEditPaths - mBtnBrowsePaths - mEditIncludePaths - mBtnBrowseIncludes - mEditDefines mButtons + tabWidget + mEditProjectRoot + mEditDefines + mListPaths + mBtnAddPath + mBtnEditPath + mBtnRemovePath + mListIncludeDirs + mBtnAddInclude + mBtnEditInclude + mBtnRemoveInclude @@ -139,8 +233,8 @@ accept() - 257 - 148 + 266 + 319 157 @@ -155,8 +249,8 @@ reject() - 325 - 148 + 334 + 319 286 diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index 2eaddf2d3..f8a0d1241 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -37,8 +37,32 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent) setWindowTitle(title); connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept())); - connect(mUI.mBtnBrowseIncludes, SIGNAL(clicked()), this, SLOT(BrowseIncludes())); - connect(mUI.mBtnBrowsePaths, SIGNAL(clicked()), this, SLOT(BrowsePaths())); + connect(mUI.mBtnAddInclude, SIGNAL(clicked()), this, SLOT(AddIncludeDir())); + connect(mUI.mBtnAddPath, SIGNAL(clicked()), this, SLOT(AddPath())); + connect(mUI.mBtnEditInclude, SIGNAL(clicked()), this, SLOT(EditIncludeDir())); + connect(mUI.mBtnRemoveInclude, SIGNAL(clicked()), this, SLOT(RemoveIncludeDir())); + connect(mUI.mBtnEditPath, SIGNAL(clicked()), this, SLOT(EditPath())); + connect(mUI.mBtnRemovePath, SIGNAL(clicked()), this, SLOT(RemovePath())); +} + +void ProjectFileDialog::AddIncludeDir(const QString &dir) +{ + if (dir.isNull() || dir.isEmpty()) + return; + + QListWidgetItem *item = new QListWidgetItem(dir); + item->setFlags(item->flags() | Qt::ItemIsEditable); + mUI.mListIncludeDirs->addItem(item); +} + +void ProjectFileDialog::AddPath(const QString &path) +{ + if (path.isNull() || path.isEmpty()) + return; + + QListWidgetItem *item = new QListWidgetItem(path); + item->setFlags(item->flags() | Qt::ItemIsEditable); + mUI.mListPaths->addItem(item); } QString ProjectFileDialog::GetRootPath() const @@ -50,18 +74,14 @@ QString ProjectFileDialog::GetRootPath() const QStringList ProjectFileDialog::GetIncludePaths() const { - QString include = mUI.mEditIncludePaths->text(); - QStringList includes; - if (!include.isEmpty()) + const int count = mUI.mListIncludeDirs->count(); + QStringList includePaths; + for (int i = 0; i < count; i++) { - include = include.trimmed(); - include = QDir::fromNativeSeparators(include); - if (include.indexOf(';') != -1) - includes = include.split(";"); - else - includes.append(include); + QListWidgetItem *item = mUI.mListIncludeDirs->item(i); + includePaths << item->text(); } - return includes; + return includePaths; } QStringList ProjectFileDialog::GetDefines() const @@ -81,16 +101,12 @@ QStringList ProjectFileDialog::GetDefines() const QStringList ProjectFileDialog::GetPaths() const { - QString path = mUI.mEditPaths->text(); + const int count = mUI.mListPaths->count(); QStringList paths; - if (!path.isEmpty()) + for (int i = 0; i < count; i++) { - path = path.trimmed(); - path = QDir::fromNativeSeparators(path); - if (path.indexOf(';') != -1) - paths = path.split(";"); - else - paths.append(path); + QListWidgetItem *item = mUI.mListPaths->item(i); + paths << item->text(); } return paths; } @@ -102,18 +118,10 @@ void ProjectFileDialog::SetRootPath(const QString &root) void ProjectFileDialog::SetIncludepaths(const QStringList &includes) { - QString includestr; - QString dir; - foreach(dir, includes) + foreach(QString dir, includes) { - includestr += dir; - includestr += ";"; + AddIncludeDir(dir); } - // Remove ; from the end of the string - if (includestr.endsWith(';')) - includestr = includestr.left(includestr.length() - 1); - includestr = QDir::toNativeSeparators(includestr); - mUI.mEditIncludePaths->setText(includestr); } void ProjectFileDialog::SetDefines(const QStringList &defines) @@ -133,21 +141,13 @@ void ProjectFileDialog::SetDefines(const QStringList &defines) void ProjectFileDialog::SetPaths(const QStringList &paths) { - QString pathstr; - QString path; - foreach(path, paths) + foreach(QString path, paths) { - pathstr += path; - pathstr += ";"; + AddPath(path); } - // Remove ; from the end of the string - if (pathstr.endsWith(';')) - pathstr = pathstr.left(pathstr.length() - 1); - pathstr = QDir::toNativeSeparators(pathstr); - mUI.mEditPaths->setText(pathstr); } -void ProjectFileDialog::BrowseIncludes() +void ProjectFileDialog::AddIncludeDir() { QString selectedDir = QFileDialog::getExistingDirectory(this, tr("Select include directory"), @@ -155,11 +155,11 @@ void ProjectFileDialog::BrowseIncludes() if (!selectedDir.isEmpty()) { - AppendDirname(mUI.mEditIncludePaths, selectedDir); + AddIncludeDir(selectedDir); } } -void ProjectFileDialog::BrowsePaths() +void ProjectFileDialog::AddPath() { QString selectedDir = QFileDialog::getExistingDirectory(this, tr("Select directory to check"), @@ -167,16 +167,32 @@ void ProjectFileDialog::BrowsePaths() if (!selectedDir.isEmpty()) { - AppendDirname(mUI.mEditPaths, selectedDir); + AddPath(selectedDir); } } -void ProjectFileDialog::AppendDirname(QLineEdit *edit, const QString &dir) +void ProjectFileDialog::RemoveIncludeDir() { - QString wholeText = edit->text(); - wholeText += ";"; - wholeText += dir; - if (!wholeText.endsWith(QDir::separator())) - wholeText += QDir::separator(); - edit->setText(wholeText); + const int row = mUI.mListIncludeDirs->currentRow(); + QListWidgetItem *item = mUI.mListIncludeDirs->takeItem(row); + delete item; +} + +void ProjectFileDialog::EditIncludeDir() +{ + QListWidgetItem *item = mUI.mListIncludeDirs->currentItem(); + mUI.mListIncludeDirs->editItem(item); +} + +void ProjectFileDialog::EditPath() +{ + QListWidgetItem *item = mUI.mListPaths->currentItem(); + mUI.mListPaths->editItem(item); +} + +void ProjectFileDialog::RemovePath() +{ + const int row = mUI.mListPaths->currentRow(); + QListWidgetItem *item = mUI.mListPaths->takeItem(row); + delete item; } diff --git a/gui/projectfiledialog.h b/gui/projectfiledialog.h index acfd45667..9256d31c0 100644 --- a/gui/projectfiledialog.h +++ b/gui/projectfiledialog.h @@ -93,22 +93,48 @@ public: protected slots: /** * @brief Browse for include directory. - * Allow user to choose new include directory. + * Allow user to add new include directory to the list. */ - void BrowseIncludes(); + void AddIncludeDir(); + /** - * @brief Browse for checked directory. - * Allow user to choose new checked directory. + * @brief Add new path to check. */ - void BrowsePaths(); + void AddPath(); + + /** + * @brief Remove include directory from the list. + */ + void RemoveIncludeDir(); + + /** + * @brief Edit include directory in the list. + */ + void EditIncludeDir(); + + /** + * @brief Edit path in the list. + */ + void EditPath(); + + /** + * @brief Remove path from the list. + */ + void RemovePath(); protected: + /** - * @brief Append new path to the edit control. - * @param edit Edit control to modify. - * @param dir Path to add. + * @brief Add new indlude directory. + * @param dir Directory to add. */ - void AppendDirname(QLineEdit *edit, const QString &dir); + void AddIncludeDir(const QString &dir); + + /** + * @brief Add new path to check. + * @param path Path to add. + */ + void AddPath(const QString &path); private: Ui::ProjectFile mUI; diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index 82ebd62fd..5f2630c53 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -564,6 +564,9 @@ void ResultsTree::StartApplication(QStandardItem *target, int application) return; } + if (application == -1) + application = mApplications->GetDefaultApplication(); + if (target && application >= 0 && application < mApplications->GetApplicationCount() && target->parent()) { // Make sure we are working with the first column @@ -704,7 +707,7 @@ void ResultsTree::Context(int application) void ResultsTree::QuickStartApplication(const QModelIndex &index) { - StartApplication(mModel.itemFromIndex(index), 0); + StartApplication(mModel.itemFromIndex(index)); } void ResultsTree::CopyPath(QStandardItem *target, bool fullPath) diff --git a/gui/resultstree.h b/gui/resultstree.h index 8dbd7e0a7..99448261e 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -238,9 +238,10 @@ protected: * @brief Helper function to open an error within target with application* * * @param target Error tree item to open - * @param application Index of the application to open with + * @param application Index of the application to open with. Giving -1 + * (default value) will open the default application. */ - void StartApplication(QStandardItem *target, int application); + void StartApplication(QStandardItem *target, int application = -1); /** * @brief Helper function to copy filename/full path to the clipboard diff --git a/gui/settings.ui b/gui/settings.ui index 8d6fc2e3d..f4366013f 100644 --- a/gui/settings.ui +++ b/gui/settings.ui @@ -7,7 +7,7 @@ 0 0 589 - 313 + 319 @@ -17,37 +17,13 @@ - 0 + 2 General - - - - - - Include paths: - - - mEditIncludePaths - - - - - - - - - - Add... - - - - - @@ -182,41 +158,125 @@ + + + Paths + + + + + + Include paths: + + + + + + + + + QAbstractItemView::SelectRows + + + + + + + + + Add... + + + + + + + Edit + + + + + + + Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Applications - + - - - - - - Add application - - - - - - - Delete application - - - - - - - Modify application - - - - - - - Set as default application - - + + + + + + + + + + Add... + + + + + + + Edit... + + + + + + + Remove + + + + + + + Set as default + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + @@ -284,18 +344,15 @@ tabWidget - mEditIncludePaths - mBtnAddIncludePath mJobs mForce mShowFullPath mShowNoErrorsMessage mShowDebugWarnings mListWidget - mButtonAdd - mButtonDelete - mButtonModify - mButtonDefault + mBtnAddApplication + mBtnEditApplication + mBtnDefaultApplication mSaveAllErrors mSaveFullPath mButtons diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index 2301950fa..ca78c1d9d 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -46,7 +46,6 @@ SettingsDialog::SettingsDialog(QSettings *programSettings, mUI.setupUi(this); mTempApplications->Copy(list); - mUI.mEditIncludePaths->setText(programSettings->value(SETTINGS_GLOBAL_INCLUDE_PATHS).toString()); mUI.mJobs->setText(programSettings->value(SETTINGS_CHECK_THREADS, 1).toString()); mUI.mForce->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_CHECK_FORCE, false).toBool())); mUI.mShowFullPath->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SHOW_FULL_PATH, false).toBool())); @@ -58,21 +57,25 @@ SettingsDialog::SettingsDialog(QSettings *programSettings, connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(Ok())); connect(mUI.mButtons, SIGNAL(rejected()), this, SLOT(reject())); - connect(mUI.mButtonAdd, SIGNAL(clicked()), + connect(mUI.mBtnAddApplication, SIGNAL(clicked()), this, SLOT(AddApplication())); - connect(mUI.mButtonDelete, SIGNAL(clicked()), - this, SLOT(DeleteApplication())); - connect(mUI.mButtonModify, SIGNAL(clicked()), - this, SLOT(ModifyApplication())); - connect(mUI.mButtonDefault, SIGNAL(clicked()), + connect(mUI.mBtnRemoveApplication, SIGNAL(clicked()), + this, SLOT(RemoveApplication())); + connect(mUI.mBtnEditApplication, SIGNAL(clicked()), + this, SLOT(EditApplication())); + connect(mUI.mBtnDefaultApplication, SIGNAL(clicked()), this, SLOT(DefaultApplication())); connect(mUI.mListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), - this, SLOT(ModifyApplication())); + this, SLOT(EditApplication())); connect(mUI.mBtnAddIncludePath, SIGNAL(clicked()), this, SLOT(AddIncludePath())); + connect(mUI.mBtnRemoveIncludePath, SIGNAL(clicked()), + this, SLOT(RemoveIncludePath())); + connect(mUI.mBtnEditIncludePath, SIGNAL(clicked()), + this, SLOT(EditIncludePath())); mUI.mListWidget->setSortingEnabled(false); - PopulateListWidget(); + PopulateApplicationList(); const int count = QThread::idealThreadCount(); if (count != -1) @@ -82,6 +85,7 @@ SettingsDialog::SettingsDialog(QSettings *programSettings, LoadSettings(); InitTranslationsList(); + InitIncludepathsList(); } SettingsDialog::~SettingsDialog() @@ -89,6 +93,26 @@ SettingsDialog::~SettingsDialog() SaveSettings(); } +void SettingsDialog::AddIncludePath(const QString &path) +{ + if (path.isNull() || path.isEmpty()) + return; + + QListWidgetItem *item = new QListWidgetItem(path); + item->setFlags(item->flags() | Qt::ItemIsEditable); + mUI.mListIncludePaths->addItem(item); +} + +void SettingsDialog::InitIncludepathsList() +{ + const QString allPaths = mSettings->value(SETTINGS_GLOBAL_INCLUDE_PATHS).toString(); + const QStringList paths = allPaths.split(";", QString::SkipEmptyParts); + foreach(QString path, paths) + { + AddIncludePath(path); + } +} + void SettingsDialog::InitTranslationsList() { const QString current = mTranslator->GetCurrentLanguage(); @@ -151,11 +175,20 @@ void SettingsDialog::SaveSettingValues() SaveCheckboxValue(mUI.mShowNoErrorsMessage, SETTINGS_SHOW_NO_ERRORS); SaveCheckboxValue(mUI.mShowDebugWarnings, SETTINGS_SHOW_DEBUG_WARNINGS); SaveCheckboxValue(mUI.mInlineSuppressions, SETTINGS_INLINE_SUPPRESSIONS); - mSettings->setValue(SETTINGS_GLOBAL_INCLUDE_PATHS, mUI.mEditIncludePaths->text()); QListWidgetItem *currentLang = mUI.mListLanguages->currentItem(); const QString langcode = currentLang->data(LangCodeRole).toString(); mSettings->setValue(SETTINGS_LANGUAGE, langcode); + + const int count = mUI.mListIncludePaths->count(); + QString includePaths; + for (int i = 0; i < count; i++) + { + QListWidgetItem *item = mUI.mListIncludePaths->item(i); + includePaths += item->text(); + includePaths += ";"; + } + mSettings->setValue(SETTINGS_GLOBAL_INCLUDE_PATHS, includePaths); } void SettingsDialog::SaveCheckboxValue(QCheckBox *box, const QString &name) @@ -169,26 +202,31 @@ void SettingsDialog::AddApplication() if (dialog.exec() == QDialog::Accepted) { - mTempApplications->AddApplicationType(dialog.GetName(), dialog.GetPath()); + mTempApplications->AddApplication(dialog.GetName(), dialog.GetPath()); mUI.mListWidget->addItem(dialog.GetName()); } } -void SettingsDialog::DeleteApplication() +void SettingsDialog::RemoveApplication() { - QList selected = mUI.mListWidget->selectedItems(); - QListWidgetItem *item = 0; - - foreach(item, selected) + foreach(QListWidgetItem *item, selected) { - mTempApplications->RemoveApplication(mUI.mListWidget->row(item)); - mUI.mListWidget->clear(); - PopulateListWidget(); + const int removeIndex = mUI.mListWidget->row(item); + const int currentDefault = mTempApplications->GetDefaultApplication(); + mTempApplications->RemoveApplication(removeIndex); + if (removeIndex == currentDefault) + // If default app is removed set default to unknown + mTempApplications->SetDefault(-1); + else if (removeIndex < currentDefault) + // Move default app one up if earlier app was removed + mTempApplications->SetDefault(currentDefault - 1); } + mUI.mListWidget->clear(); + PopulateApplicationList(); } -void SettingsDialog::ModifyApplication() +void SettingsDialog::EditApplication() { QList selected = mUI.mListWidget->selectedItems(); QListWidgetItem *item = 0; @@ -202,7 +240,7 @@ void SettingsDialog::ModifyApplication() if (dialog.exec() == QDialog::Accepted) { - mTempApplications->SetApplicationType(row, dialog.GetName(), dialog.GetPath()); + mTempApplications->SetApplication(row, dialog.GetName(), dialog.GetPath()); item->setText(dialog.GetName()); } } @@ -214,23 +252,36 @@ void SettingsDialog::DefaultApplication() if (selected.size() > 0) { int index = mUI.mListWidget->row(selected[0]); - mTempApplications->MoveFirst(index); + mTempApplications->SetDefault(index); mUI.mListWidget->clear(); - PopulateListWidget(); + PopulateApplicationList(); } } -void SettingsDialog::PopulateListWidget() +void SettingsDialog::PopulateApplicationList() { + const int defapp = mTempApplications->GetDefaultApplication(); for (int i = 0; i < mTempApplications->GetApplicationCount(); i++) { - mUI.mListWidget->addItem(mTempApplications->GetApplicationName(i)); + QString name = mTempApplications->GetApplicationName(i); + if (i == defapp) + { + name += " "; + name += tr("[Default]"); + } + mUI.mListWidget->addItem(name); } - // If list contains items select first item - if (mTempApplications->GetApplicationCount()) - { + // Select default application, or if there is no default app then the + // first item. + if (defapp == -1) mUI.mListWidget->setCurrentRow(0); + else + { + if (mTempApplications->GetApplicationCount() > defapp) + mUI.mListWidget->setCurrentRow(defapp); + else + mUI.mListWidget->setCurrentRow(0); } } @@ -268,10 +319,19 @@ void SettingsDialog::AddIncludePath() if (!selectedDir.isEmpty()) { - QString text = mUI.mEditIncludePaths->text(); - if (!text.isEmpty()) - text += ';'; - text += selectedDir; - mUI.mEditIncludePaths->setText(text); + AddIncludePath(selectedDir); } } + +void SettingsDialog::RemoveIncludePath() +{ + const int row = mUI.mListIncludePaths->currentRow(); + QListWidgetItem *item = mUI.mListIncludePaths->takeItem(row); + delete item; +} + +void SettingsDialog::EditIncludePath() +{ + QListWidgetItem *item = mUI.mListIncludePaths->currentItem(); + mUI.mListIncludePaths->editItem(item); +} diff --git a/gui/settingsdialog.h b/gui/settingsdialog.h index d2a9e11ad..22d3c3253 100644 --- a/gui/settingsdialog.h +++ b/gui/settingsdialog.h @@ -98,13 +98,13 @@ protected slots: * @brief Slot for deleting an application from the list * */ - void DeleteApplication(); + void RemoveApplication(); /** * @brief Slot for modifying an application in the list * */ - void ModifyApplication(); + void EditApplication(); /** * @brief Slot for making the selected application as the default (first) @@ -118,19 +118,38 @@ protected slots: */ void AddIncludePath(); + /** + * @brief Slot for removing an include path. + * + */ + void RemoveIncludePath(); + + /** + * @brief Slot for editing an include path. + * + */ + void EditIncludePath(); + protected: + /** + * @brief Add new include path to the list. + * @param path Path to add. + * + */ + void AddIncludePath(const QString &path); + /** * @brief Clear all applications from the list and re insert them from mTempApplications * */ - void PopulateListWidget(); + void PopulateApplicationList(); /** - * @brief Load saved values - * Loads dialog size and column widths. - * - */ + * @brief Load saved values + * Loads dialog size and column widths. + * + */ void SaveSettings(); /** @@ -165,6 +184,11 @@ protected: */ bool CheckStateToBool(Qt::CheckState state) const; + /** + * @brief Populate the include paths-list. + */ + void InitIncludepathsList(); + /** * @brief Populate the translations list. */ diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index b13143d80..4bcb60719 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -712,6 +712,18 @@ void CheckClass::noMemset() type = tok->strAt(10); else if (Token::Match(tok, "%type% ( %var% , %var% , sizeof ( %type% ) )")) type = tok->strAt(8); + else if (Token::Match(tok, "memset ( & %var% , %num% , sizeof ( %var% ) )")) + { + unsigned int varid = tok->tokAt(3)->varId(); + for (const Token *lookback = tok->previous(); lookback; lookback = lookback->previous()) + { + if (Token::Match(lookback, "%type% %varid%", varid)) + { + type = lookback->str(); + break; + } + } + } // No type defined => The tokens didn't match if (type.empty()) @@ -719,7 +731,14 @@ void CheckClass::noMemset() // Warn if type is a class or struct that contains any std::* variables const std::string pattern2(std::string("struct|class ") + type + " {"); - for (const Token *tstruct = Token::findmatch(_tokenizer->tokens(), pattern2.c_str()); tstruct; tstruct = tstruct->next()) + const Token *tstruct = Token::findmatch(_tokenizer->tokens(), pattern2.c_str()); + + if (!tstruct) + continue; + + const std::string &typeName = tstruct->str(); + + for (; tstruct; tstruct = tstruct->next()) { if (tstruct->str() == "}") break; @@ -739,7 +758,7 @@ void CheckClass::noMemset() tstruct->str().find(":") != std::string::npos) { if (Token::Match(tstruct->next(), "std :: %type% %var% ;")) - memsetStructError(tok, tok->str(), tstruct->strAt(3)); + memsetError(tok, tok->str(), tstruct->strAt(3), typeName); else if (Token::Match(tstruct->next(), "std :: %type% <")) { @@ -767,21 +786,16 @@ void CheckClass::noMemset() // found error => report if (Token::Match(tstruct, "> %var% ;")) - memsetStructError(tok, tok->str(), typestr); + memsetError(tok, tok->str(), typestr, typeName); } } } } } -void CheckClass::memsetClassError(const Token *tok, const std::string &memfunc) +void CheckClass::memsetError(const Token *tok, const std::string &memfunc, const std::string &classname, const std::string &type) { - reportError(tok, Severity::error, "memsetClass", "Using '" + memfunc + "' on class"); -} - -void CheckClass::memsetStructError(const Token *tok, const std::string &memfunc, const std::string &classname) -{ - reportError(tok, Severity::error, "memsetStruct", "Using '" + memfunc + "' on struct that contains a 'std::" + classname + "'"); + reportError(tok, Severity::error, "memsetClass", "Using '" + memfunc + "' on " + type + " that contains a 'std::" + classname + "'"); } //--------------------------------------------------------------------------- diff --git a/lib/checkclass.h b/lib/checkclass.h index cc550c36b..2dd238f83 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -117,8 +117,7 @@ private: void uninitVarError(const Token *tok, const std::string &classname, const std::string &varname); void operatorEqVarError(const Token *tok, const std::string &classname, const std::string &varname); void unusedPrivateFunctionError(const Token *tok, const std::string &classname, const std::string &funcname); - void memsetClassError(const Token *tok, const std::string &memfunc); - void memsetStructError(const Token *tok, const std::string &memfunc, const std::string &classname); + void memsetError(const Token *tok, const std::string &memfunc, const std::string &classname, const std::string &type); void operatorEqReturnError(const Token *tok); void virtualDestructorError(const Token *tok, const std::string &Base, const std::string &Derived); void thisSubtractionError(const Token *tok); @@ -134,8 +133,7 @@ private: c.uninitVarError(0, "classname", "varname"); c.operatorEqVarError(0, "classname", ""); c.unusedPrivateFunctionError(0, "classname", "funcname"); - c.memsetClassError(0, "memfunc"); - c.memsetStructError(0, "memfunc", "classname"); + c.memsetError(0, "memfunc", "classname", "class"); c.operatorEqReturnError(0); //c.virtualDestructorError(0, "Base", "Derived"); c.thisSubtractionError(0); diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index f7f56185d..0fc64cc33 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -178,6 +178,10 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename, // Remove all comments.. result = removeComments(result, filename, settings); + // Remove '#if 0' blocks + if (result.find("#if 0\n") != std::string::npos) + result = removeIf0(result); + // ------------------------------------------------------------------------------------------ // // Clean up all preprocessor statements @@ -547,6 +551,37 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri return code.str(); } +std::string Preprocessor::removeIf0(const std::string &code) +{ + std::ostringstream ret; + std::istringstream istr(code); + std::string line; + while (std::getline(istr,line)) + { + if (line != "#if 0") + ret << line << "\n"; + else + { + // replace '#if 0' with empty line + ret << "\n"; + + // goto the end of the '#if 0' block + unsigned int level = 1; + while (level > 0 && std::getline(istr,line)) + { + if (line.compare(0,3,"#if") == 0) + ++level; + else if (line == "#endif") + --level; + + // replace code within '#if 0' block with empty lines + ret << "\n"; + } + } + } + return ret.str(); +} + std::string Preprocessor::removeParantheses(const std::string &str) { diff --git a/lib/preprocessor.h b/lib/preprocessor.h index 82f5da2bd..e871f8562 100644 --- a/lib/preprocessor.h +++ b/lib/preprocessor.h @@ -144,6 +144,13 @@ protected: */ std::string removeComments(const std::string &str, const std::string &filename, Settings *settings); + /** + * Cleanup 'if 0' from the code + * @param str Code processed by read(). + * @return code without 'if 0' + */ + static std::string removeIf0(const std::string &code); + /** * Remove redundant parentheses from preprocessor commands. This should only be called from read(). * @param str Code processed by read(). diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index a600a1a3a..54f5ea32f 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1071,10 +1071,31 @@ Scope::hasDefaultConstructor() const return false; } +AccessControl Scope::defaultAccess() const +{ + switch (type) + { + case eGlobal: + return Global; + case eClass: + return Private; + case eStruct: + return Public; + case eUnion: + return Public; + case eNamespace: + return Namespace; + case eFunction: + return Local; + } + + return Public; +} + // Get variable list.. void Scope::getVariableList() { - AccessControl varaccess = type == eClass ? Private : Public; + AccessControl varaccess = defaultAccess(); const Token *start; if (classStart) @@ -1164,7 +1185,7 @@ void Scope::getVariableList() continue; // Search for start of statement.. - else if (!tok->previous() || !Token::Match(tok->previous(), ";|{|}|public:|protected:|private:")) + else if (tok->previous() && !Token::Match(tok->previous(), ";|{|}|public:|protected:|private:")) continue; else if (Token::Match(tok, ";|{|}")) continue; @@ -1242,7 +1263,7 @@ void Scope::getVariableList() if (typetok) scope = check->findVariableType(this, typetok); - addVariable(vartok, typestart, varaccess, isMutable, isStatic, isConst, isClass, scope); + addVariable(vartok, typestart, vartok->previous(), varaccess, isMutable, isStatic, isConst, isClass, scope, this); } } } @@ -1288,7 +1309,7 @@ bool Scope::isVariableDeclaration(const Token* tok, const Token*& vartok, const { localVarTok = skipPointers(closeTok->next()); - if (Token::Match(localVarTok, ":: %type% %var% ;")) + if (Token::Match(localVarTok, ":: %type% %var% ;|=")) { localTypeTok = localVarTok->next(); localVarTok = localVarTok->tokAt(2); @@ -1311,7 +1332,7 @@ bool Scope::isVariableDeclaration(const Token* tok, const Token*& vartok, const bool Scope::isSimpleVariable(const Token* tok) const { - return Token::Match(tok, "%var% ;"); + return Token::Match(tok, "%var% ;|="); } bool Scope::isArrayVariable(const Token* tok) const @@ -1325,7 +1346,7 @@ bool Scope::findClosingBracket(const Token* tok, const Token*& close) const if (NULL != tok && tok->str() == "<") { unsigned int depth = 0; - for (close = tok; (close != NULL) && (close->str() != ";"); close = close->next()) + for (close = tok; (close != NULL) && (close->str() != ";") && (close->str() != "="); close = close->next()) { if (close->str() == "<") { diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index b21417c51..d45ad701f 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -38,7 +38,7 @@ class SymbolDatabase; /** * @brief Access control enumerations. */ -enum AccessControl { Public, Protected, Private }; +enum AccessControl { Public, Protected, Private, Global, Namespace, Argument, Local }; /** @brief Information about a member variable. */ class Variable @@ -73,15 +73,18 @@ class Variable } public: - Variable(const Token *name_, const Token *start_, std::size_t index_, - AccessControl access_, bool mutable_, bool static_, bool const_, - bool class_, const Scope *type_) + Variable(const Token *name_, const Token *start_, const Token *end_, + std::size_t index_, AccessControl access_, bool mutable_, + bool static_, bool const_, bool class_, const Scope *type_, + const Scope *scope_) : _name(name_), _start(start_), + _end(end_), _index(index_), _access(access_), _flags(0), - _type(type_) + _type(type_), + _scope(scope_) { setFlag(fIsMutable, mutable_); setFlag(fIsStatic, static_); @@ -107,6 +110,15 @@ public: return _start; } + /** + * Get type end token. + * @return type end token + */ + const Token *typeEndToken() const + { + return _end; + } + /** * Get name string. * @return name string @@ -161,6 +173,42 @@ public: return _access == Private; } + /** + * Is variable global. + * @return true if global, false if not + */ + bool isGlobal() const + { + return _access == Global; + } + + /** + * Is variable in a namespace. + * @return true if in a namespace, false if not + */ + bool isNamespace() const + { + return _access == Namespace; + } + + /** + * Is variable a function argument. + * @return true if a function argument, false if not + */ + bool isArgument() const + { + return _access == Argument; + } + + /** + * Is variable local. + * @return true if local, false if not + */ + bool isLocal() const + { + return _access == Local; + } + /** * Is variable mutable. * @return true if mutable, false if not @@ -206,6 +254,15 @@ public: return _type; } + /** + * Get Scope pointer of enclosing scope. + * @return pointer to enclosing scope + */ + const Scope *scope() const + { + return _scope; + } + private: /** @brief variable name token */ const Token *_name; @@ -213,6 +270,9 @@ private: /** @brief variable type start token */ const Token *_start; + /** @brief variable type end token */ + const Token *_end; + /** @brief order declared */ std::size_t _index; @@ -224,6 +284,9 @@ private: /** @brief pointer to user defined type info (for known types) */ const Scope *_type; + + /** @brief pointer to scope this variable is in */ + const Scope *_scope; }; class Function @@ -313,7 +376,7 @@ public: AccessControl access; unsigned int numConstructors; NeedInitialization needInitialization; - Scope * functionOf; // class/struct this function belongs to + Scope *functionOf; // class/struct this function belongs to bool isClassOrStruct() const { @@ -332,9 +395,14 @@ public: */ Scope * findInNestedListRecursive(const std::string & name); - void addVariable(const Token *token_, const Token *start_, AccessControl access_, bool mutable_, bool static_, bool const_, bool class_, const Scope *type_) + void addVariable(const Token *token_, const Token *start_, + const Token *end_, AccessControl access_, bool mutable_, + bool static_, bool const_, bool class_, const Scope *type_, + const Scope *scope_) { - varlist.push_back(Variable(token_, start_, varlist.size(), access_, mutable_, static_, const_, class_, type_)); + varlist.push_back(Variable(token_, start_, end_, varlist.size(), + access_, mutable_, static_, const_, class_, + type_, scope_)); } /** @brief initialize varlist */ @@ -352,6 +420,8 @@ public: bool hasDefaultConstructor() const; + AccessControl defaultAccess() const; + private: /** * @brief helper function for getVariableList() diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 9fae3503c..0a2900372 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -58,6 +58,9 @@ Tokenizer::Tokenizer() // symbol database _symbolDatabase = NULL; + + // variable count + _varId = 0; } Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger) @@ -75,6 +78,9 @@ Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger) // symbol database _symbolDatabase = NULL; + + // variable count + _varId = 0; } Tokenizer::~Tokenizer() @@ -3271,7 +3277,7 @@ void Tokenizer::setVarId() tok->varId(0); // Set variable ids.. - unsigned int _varId = 0; + _varId = 0; for (Token *tok = _tokens; tok; tok = tok->next()) { if (tok != _tokens && !Token::Match(tok, "[;{}(,] %type%")) @@ -4663,6 +4669,8 @@ void Tokenizer::simplifyIfAddBraces() break; } tempToken = tempToken->link(); + if (!tempToken || !tempToken->next()) + break; if (tempToken->next()->isName() && tempToken->next()->str() != "else") break; continue; @@ -9382,7 +9390,8 @@ void Tokenizer::removeUnnecessaryQualification() classInfo.pop(); else if (tok->str() == classInfo.top().className && Token::Match(tok, "%type% :: %type% (") && - Token::Match(tok->tokAt(3)->link(), ") const| {|;")) + Token::Match(tok->tokAt(3)->link(), ") const| {|;") && + tok->previous()->str() != ":") { std::list locationList; ErrorLogger::ErrorMessage::FileLocation loc; diff --git a/lib/tokenize.h b/lib/tokenize.h index d5faa0812..a9b5c556d 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -650,6 +650,15 @@ public: Token *deleteInvalidTypedef(Token *typeDef); + /** + * Get variable count. + * @return number of variables + */ + unsigned int varIdCount() const + { + return _varId; + } + private: /** Disable copy constructor, no implementation */ Tokenizer(const Tokenizer &); @@ -684,6 +693,9 @@ private: /** Symbol database that all checks etc can use */ mutable SymbolDatabase *_symbolDatabase; + + /** variable count */ + unsigned int _varId; }; /// @} diff --git a/test/testclass.cpp b/test/testclass.cpp index a4f727618..d49d5abe3 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -2908,7 +2908,52 @@ private: void memsetOnClass() { - checkNoMemset("class A\n" + checkNoMemset("class Fred\n" + "{\n" + "};\n" + "void f()\n" + "{\n" + " Fred fred;\n" + " memset(&fred, 0, sizeof(Fred));\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + checkNoMemset("class Fred\n" + "{\n" + " std::string b; \n" + "};\n" + "void f()\n" + "{\n" + " Fred fred;\n" + " memset(&fred, 0, sizeof(Fred));\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on class that contains a 'std::string'\n", errout.str()); + + checkNoMemset("class Fred\n" + "{\n" + "};\n" + "void f()\n" + "{\n" + " Fred fred;\n" + " memset(&fred, 0, sizeof(fred));\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + checkNoMemset("class Fred\n" + "{\n" + " std::string s;\n" + "};\n" + "void f()\n" + "{\n" + " Fred fred;\n" + " memset(&fred, 0, sizeof(fred));\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on class that contains a 'std::string'\n", errout.str()); + } + + void memsetOnStruct() + { + checkNoMemset("struct A\n" "{\n" "};\n" "void f()\n" @@ -2924,23 +2969,24 @@ private: "void f()\n" "{\n" " struct A a;\n" - " memset(&a, 0, sizeof(A));\n" + " memset(&a, 0, sizeof(struct A));\n" "}\n"); ASSERT_EQUALS("", errout.str()); - } - void memsetOnStruct() - { - checkNoMemset("class A\n" + checkNoMemset("struct A\n" "{\n" - " void g( struct sockaddr_in6& a);\n" - "private:\n" - " std::string b; \n" "};\n" "void f()\n" "{\n" - " struct sockaddr_in6 fail;\n" - " memset(&fail, 0, sizeof(struct sockaddr_in6));\n" + " struct A a;\n" + " memset(&a, 0, sizeof(A));\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + checkNoMemset("void f()\n" + "{\n" + " struct sockaddr_in6 fail;\n" + " memset(&fail, 0, sizeof(struct sockaddr_in6));\n" "}\n"); ASSERT_EQUALS("", errout.str()); @@ -2966,18 +3012,68 @@ private: " Fred fred;\n" " memset(&fred, 0, sizeof(fred));\n" "}\n"); - TODO_ASSERT_EQUALS("error", "", errout.str()); + ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on struct that contains a 'std::string'\n", errout.str()); } void memsetVector() { + checkNoMemset("class A\n" + "{ std::vector ints; }\n" + "\n" + "void f()\n" + "{\n" + " A a;\n" + " memset(&a, 0, sizeof(A));\n" + "}"); + ASSERT_EQUALS("[test.cpp:7]: (error) Using 'memset' on class that contains a 'std::vector'\n", errout.str()); + checkNoMemset("struct A\n" "{ std::vector ints; }\n" "\n" "void f()\n" "{\n" " A a;\n" - " memset(a, 0, sizeof(A));\n" + " memset(&a, 0, sizeof(A));\n" + "}"); + ASSERT_EQUALS("[test.cpp:7]: (error) Using 'memset' on struct that contains a 'std::vector'\n", errout.str()); + + checkNoMemset("struct A\n" + "{ std::vector ints; }\n" + "\n" + "void f()\n" + "{\n" + " A a;\n" + " memset(&a, 0, sizeof(struct A));\n" + "}"); + ASSERT_EQUALS("[test.cpp:7]: (error) Using 'memset' on struct that contains a 'std::vector'\n", errout.str()); + + checkNoMemset("struct A\n" + "{ std::vector ints; }\n" + "\n" + "void f()\n" + "{\n" + " A a;\n" + " memset(&a, 0, sizeof(a));\n" + "}"); + ASSERT_EQUALS("[test.cpp:7]: (error) Using 'memset' on struct that contains a 'std::vector'\n", errout.str()); + + checkNoMemset("class A\n" + "{ std::vector< std::vector > ints; }\n" + "\n" + "void f()\n" + "{\n" + " A a;\n" + " memset(&a, 0, sizeof(A));\n" + "}"); + ASSERT_EQUALS("[test.cpp:7]: (error) Using 'memset' on class that contains a 'std::vector'\n", errout.str()); + + checkNoMemset("struct A\n" + "{ std::vector< std::vector > ints; }\n" + "\n" + "void f()\n" + "{\n" + " A a;\n" + " memset(&a, 0, sizeof(A));\n" "}"); ASSERT_EQUALS("[test.cpp:7]: (error) Using 'memset' on struct that contains a 'std::vector'\n", errout.str()); @@ -2987,7 +3083,7 @@ private: "void f()\n" "{\n" " A a;\n" - " memset(a, 0, sizeof(A));\n" + " memset(&a, 0, sizeof(a));\n" "}"); ASSERT_EQUALS("[test.cpp:7]: (error) Using 'memset' on struct that contains a 'std::vector'\n", errout.str()); @@ -2997,7 +3093,7 @@ private: "void f()\n" "{\n" " A a;\n" - " memset(a, 0, sizeof(A));\n" + " memset(&a, 0, sizeof(A));\n" "}"); ASSERT_EQUALS("[test.cpp:7]: (error) Using 'memset' on struct that contains a 'std::vector'\n", errout.str()); } diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index d01a79829..37df95c61 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -92,6 +92,10 @@ private: TEST_CASE(error3); + // Don't handle include in a #if 0 block + TEST_CASE(if0_include_1); + TEST_CASE(if0_include_2); + // Handling include guards (don't create extra configuration for it) TEST_CASE(includeguard1); TEST_CASE(includeguard2); @@ -637,6 +641,32 @@ private: ASSERT_EQUALS("[test.c:1]: (error) #error hello world!\n", errout.str()); } + void if0_include_1() + { + Settings settings; + Preprocessor preprocessor(&settings, this); + + std::istringstream code("#if 0\n" + "#include \"a.h\"\n" + "#endif\n" + "AB\n"); + ASSERT_EQUALS("\n\n\nAB\n", preprocessor.read(code,"",NULL)); + } + + void if0_include_2() + { + Settings settings; + Preprocessor preprocessor(&settings, this); + + std::istringstream code("#if 0\n" + "#include \"a.h\"\n" + "#ifdef WIN32\n" + "#else\n" + "#endif\n" + "#endif\n" + "AB\n"); + ASSERT_EQUALS("\n\n\n\n\n\nAB\n", preprocessor.read(code,"",NULL)); + } void includeguard1() { diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 35f0d4e34..a546b3654 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -328,7 +328,8 @@ private: TEST_CASE(simplifyFunctionReturn); - TEST_CASE(removeUnnecessaryQualification); + TEST_CASE(removeUnnecessaryQualification1); + TEST_CASE(removeUnnecessaryQualification2); TEST_CASE(simplifyIfNotNull); } @@ -6550,7 +6551,7 @@ private: ASSERT_EQUALS(expected, tok(code, false)); } - void removeUnnecessaryQualification() + void removeUnnecessaryQualification1() { const char code[] = "class Fred { Fred::Fred() {} };"; const char expected[] = "class Fred { Fred ( ) { } } ;"; @@ -6558,6 +6559,16 @@ private: ASSERT_EQUALS("[test.cpp:1]: (portability) Extra qualification 'Fred::' unnecessary and considered an error by many compilers.\n", errout.str()); } + void removeUnnecessaryQualification2() + { + const char code[] = "template\n" + "struct grammar : qi::grammar {\n" + " grammar() : grammar::base_type(start) { }\n" + "};\n"; + tok(code, false); + ASSERT_EQUALS("", errout.str()); + } + void simplifyIfNotNull() // ticket # 2601 segmentation fault { const char code[] = "|| #if #define <="; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index bfcb71b60..d3ba32467 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -93,6 +93,10 @@ private: TEST_CASE(hasInlineClassFunctionReturningFunctionPointer); TEST_CASE(hasMissingInlineClassFunctionReturningFunctionPointer); TEST_CASE(hasClassFunctionReturningFunctionPointer); + + TEST_CASE(hasGlobalVariables1); + TEST_CASE(hasGlobalVariables2); + TEST_CASE(hasGlobalVariables3); } void test_isVariableDeclarationCanHandleNull() @@ -522,6 +526,60 @@ private: ASSERT(function && function->hasBody && !function->isInline && function->retFuncPtr); } } + + void hasGlobalVariables1() + { + GET_SYMBOL_DB("int i;\n") + + ASSERT(db && db->scopeList.size() == 1); + if (db && db->scopeList.size() == 1) + { + std::list::const_iterator it = db->scopeList.begin(); + ASSERT((*it)->varlist.size() == 1); + if ((*it)->varlist.size() == 1) + { + std::list::const_iterator var = (*it)->varlist.begin(); + ASSERT(var->name() == "i"); + ASSERT(var->typeStartToken()->str() == "int"); + } + } + } + + void hasGlobalVariables2() + { + GET_SYMBOL_DB("int array[2][2];\n") + + ASSERT(db && db->scopeList.size() == 1); + if (db && db->scopeList.size() == 1) + { + std::list::const_iterator it = db->scopeList.begin(); + ASSERT((*it)->varlist.size() == 1); + if ((*it)->varlist.size() == 1) + { + std::list::const_iterator var = (*it)->varlist.begin(); + ASSERT(var->name() == "array"); + ASSERT(var->typeStartToken()->str() == "int"); + } + } + } + + void hasGlobalVariables3() + { + GET_SYMBOL_DB("int array[2][2] = { { 0, 0 }, { 0, 0 } };\n") + + ASSERT(db && db->scopeList.size() == 1); + if (db && db->scopeList.size() == 1) + { + std::list::const_iterator it = db->scopeList.begin(); + ASSERT((*it)->varlist.size() == 1); + if ((*it)->varlist.size() == 1) + { + std::list::const_iterator var = (*it)->varlist.begin(); + ASSERT(var->name() == "array"); + ASSERT(var->typeStartToken()->str() == "int"); + } + } + } }; REGISTER_TEST(TestSymbolDatabase) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 7b35ea570..02cf0cc71 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -79,6 +79,7 @@ private: TEST_CASE(ifAddBraces11); TEST_CASE(ifAddBraces12); TEST_CASE(ifAddBraces13); + TEST_CASE(ifAddBraces14); // #2610 - segfault: if()<{} TEST_CASE(whileAddBraces); TEST_CASE(doWhileAddBraces); @@ -850,6 +851,13 @@ private: ASSERT_EQUALS(expected2, tokenizeAndStringify(code2, true)); } + void ifAddBraces14() + { + // ticket #2610 (segfault) + tokenizeAndStringify("if()<{}", false); + } + + void whileAddBraces() { const char code[] = ";while(a);";