From eaf0bca8fed55cb14b019dc97e48c80d5b36c8cf Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Thu, 3 Feb 2011 21:40:35 +0200 Subject: [PATCH 01/21] GUI: Write XML version 2. Ticket #2521 (GUI: Add XML format 2 support) --- gui/gui.pro | 2 + gui/mainwindow.cpp | 10 ++- gui/report.h | 1 + gui/resultsview.cpp | 4 + gui/xmlreportv2.cpp | 200 ++++++++++++++++++++++++++++++++++++++++++++ gui/xmlreportv2.h | 96 +++++++++++++++++++++ 6 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 gui/xmlreportv2.cpp create mode 100644 gui/xmlreportv2.h diff --git a/gui/gui.pro b/gui/gui.pro index 54952ac6c..5df4c2bab 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -69,6 +69,7 @@ HEADERS += mainwindow.h \ report.h \ txtreport.h \ xmlreport.h \ + xmlreportv2.h \ translationhandler.h \ csvreport.h \ logview.h \ @@ -96,6 +97,7 @@ SOURCES += main.cpp \ report.cpp \ txtreport.cpp \ xmlreport.cpp \ + xmlreportv2.cpp \ translationhandler.cpp \ csvreport.cpp \ logview.cpp \ diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 72cd10091..e052db341 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -579,7 +579,7 @@ void MainWindow::ShowAuthors() void MainWindow::Save() { QString selectedFilter; - QString filter(tr("XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)")); + QString filter(tr("XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv)")); QString selectedFile = QFileDialog::getSaveFileName(this, tr("Save the report file"), QString(), @@ -589,12 +589,18 @@ void MainWindow::Save() if (!selectedFile.isEmpty()) { Report::Type type = Report::TXT; - if (selectedFilter == tr("XML files (*.xml)")) + if (selectedFilter == tr("XML files version 1 (*.xml)")) { type = Report::XML; if (!selectedFile.endsWith(".xml", Qt::CaseInsensitive)) selectedFile += ".xml"; } + else if (selectedFilter == tr("XML files version 2 (*.xml)")) + { + type = Report::XMLV2; + if (!selectedFile.endsWith(".xml", Qt::CaseInsensitive)) + selectedFile += ".xml"; + } else if (selectedFilter == tr("Text files (*.txt)")) { type = Report::TXT; diff --git a/gui/report.h b/gui/report.h index 681bdecf6..ace33c4b6 100644 --- a/gui/report.h +++ b/gui/report.h @@ -39,6 +39,7 @@ public: { TXT, XML, + XMLV2, CSV, }; diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index ab1234f46..e74d7b982 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -31,6 +31,7 @@ #include "report.h" #include "txtreport.h" #include "xmlreport.h" +#include "xmlreportv2.h" #include "csvreport.h" #include "applicationlist.h" #include "checkstatistics.h" @@ -132,6 +133,9 @@ void ResultsView::Save(const QString &filename, Report::Type type) case Report::XML: report = new XmlReport(filename, this); break; + case Report::XMLV2: + report = new XmlReportV2(filename, this); + break; } if (report) diff --git a/gui/xmlreportv2.cpp b/gui/xmlreportv2.cpp new file mode 100644 index 000000000..165811b2e --- /dev/null +++ b/gui/xmlreportv2.cpp @@ -0,0 +1,200 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2011 Daniel Marjamki and Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include "report.h" +#include "erroritem.h" +#include "xmlreportv2.h" +#include "cppcheck.h" + +static const char ResultElementName[] = "results"; +static const char CppcheckElementName[] = "cppcheck"; +static const char ErrorElementName[] = "error"; +static const char ErrorsElementName[] = "errors"; +static const char LocationElementName[] = "location"; +static const char FilenameAttribute[] = "file"; +static const char LineAttribute[] = "line"; +static const char IdAttribute[] = "id"; +static const char SeverityAttribute[] = "severity"; +static const char MsgAttribute[] = "msg"; +static const char VersionAttribute[] = "version"; +static const char VerboseAttribute[] = "verbose"; + +XmlReportV2::XmlReportV2(const QString &filename, QObject * parent) : + Report(filename, parent), + mXmlReader(NULL), + mXmlWriter(NULL) +{ +} + +XmlReportV2::~XmlReportV2() +{ + delete mXmlReader; + delete mXmlWriter; + Close(); +} + +bool XmlReportV2::Create() +{ + bool success = false; + if (Report::Create()) + { + mXmlWriter = new QXmlStreamWriter(Report::GetFile()); + success = true; + } + return success; +} + +bool XmlReportV2::Open() +{ + bool success = false; + if (Report::Open()) + { + mXmlReader = new QXmlStreamReader(Report::GetFile()); + success = true; + } + return success; +} + +void XmlReportV2::WriteHeader() +{ + mXmlWriter->setAutoFormatting(true); + mXmlWriter->writeStartDocument(); + mXmlWriter->writeStartElement(ResultElementName); + mXmlWriter->writeAttribute(VersionAttribute, QString::number(2)); + mXmlWriter->writeStartElement(CppcheckElementName); + mXmlWriter->writeAttribute(VersionAttribute, QString(CppCheck::version())); + mXmlWriter->writeEndElement(); + mXmlWriter->writeStartElement(ErrorsElementName); +} + +void XmlReportV2::WriteFooter() +{ + mXmlWriter->writeEndElement(); // errors + mXmlWriter->writeEndElement(); // results + mXmlWriter->writeEndDocument(); +} + +void XmlReportV2::WriteError(const ErrorItem &error) +{ + /* + Error example from the core program in xml + + + + + */ + + mXmlWriter->writeStartElement(ErrorElementName); + mXmlWriter->writeAttribute(IdAttribute, error.id); + mXmlWriter->writeAttribute(SeverityAttribute, error.severity); + mXmlWriter->writeAttribute(MsgAttribute, error.summary); + mXmlWriter->writeAttribute(VerboseAttribute, error.message); + + for (int i = 0; i < error.files.count(); i++) + { + mXmlWriter->writeStartElement(LocationElementName); + + const QString file = QDir::toNativeSeparators(error.files[i]); + mXmlWriter->writeAttribute(FilenameAttribute, file); + const QString line = QString::number(error.lines[i]); + mXmlWriter->writeAttribute(LineAttribute, line); + + mXmlWriter->writeEndElement(); + } + + mXmlWriter->writeEndElement(); +} + +QList XmlReportV2::Read() +{ + QList errors; + bool insideResults = false; + if (!mXmlReader) + { + qDebug() << "You must Open() the file before reading it!"; + return errors; + } + while (!mXmlReader->atEnd()) + { + switch (mXmlReader->readNext()) + { + case QXmlStreamReader::StartElement: + if (mXmlReader->name() == ResultElementName) + insideResults = true; + + // Read error element from inside result element + if (insideResults && mXmlReader->name() == ErrorElementName) + { + ErrorLine line = ReadError(mXmlReader); + errors.append(line); + } + break; + + case QXmlStreamReader::EndElement: + if (mXmlReader->name() == ResultElementName) + insideResults = false; + break; + + // Not handled + case QXmlStreamReader::NoToken: + case QXmlStreamReader::Invalid: + case QXmlStreamReader::StartDocument: + case QXmlStreamReader::EndDocument: + case QXmlStreamReader::Characters: + case QXmlStreamReader::Comment: + case QXmlStreamReader::DTD: + case QXmlStreamReader::EntityReference: + case QXmlStreamReader::ProcessingInstruction: + break; + } + } + return errors; +} + +ErrorLine XmlReportV2::ReadError(QXmlStreamReader *reader) +{ + ErrorLine line; + if (reader->name().toString() == ErrorElementName) + { + QXmlStreamAttributes attribs = reader->attributes(); + line.file = attribs.value("", FilenameAttribute).toString(); + line.line = attribs.value("", LineAttribute).toString().toUInt(); + line.id = attribs.value("", IdAttribute).toString(); + line.severity = attribs.value("", SeverityAttribute).toString(); + + // NOTE: This dublicates the message to Summary-field. But since + // old XML format doesn't have separate summary and verbose messages + // we must add same message to both data so it shows up in GUI. + // Check if there is full stop and cut the summary to it. + QString summary = attribs.value("", MsgAttribute).toString(); + const int ind = summary.indexOf('.'); + if (ind != -1) + summary = summary.left(ind + 1); + line.summary = summary; + line.message = attribs.value("", MsgAttribute).toString(); + } + return line; +} diff --git a/gui/xmlreportv2.h b/gui/xmlreportv2.h new file mode 100644 index 000000000..33f96349d --- /dev/null +++ b/gui/xmlreportv2.h @@ -0,0 +1,96 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2011 Daniel Marjamki and Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef XML_REPORTV2_H +#define XML_REPORTV2_H + +#include +#include +#include +#include +#include +#include +#include "report.h" + +/// @addtogroup GUI +/// @{ + + +/** +* @brief XML file report version 2. +* This report outputs XML-formatted report. The XML format must match command +* line version's XML output. +*/ +class XmlReportV2 : public Report +{ +public: + XmlReportV2(const QString &filename, QObject * parent = 0); + virtual ~XmlReportV2(); + + /** + * @brief Create the report (file). + * @return true if succeeded, false if file could not be created. + */ + virtual bool Create(); + + /** + * @brief Open existing report file. + */ + bool Open(); + + /** + * @brief Write report header. + */ + virtual void WriteHeader(); + + /** + * @brief Write report footer. + */ + virtual void WriteFooter(); + + /** + * @brief Write error to report. + * @param error Error data. + */ + virtual void WriteError(const ErrorItem &error); + + /** + * @brief Read contents of the report file. + */ + QList Read(); + +protected: + /** + * @brief Read and parse error item from XML stream. + * @param reader XML stream reader to use. + */ + ErrorLine ReadError(QXmlStreamReader *reader); + +private: + /** + * @brief XML stream reader for reading the report in XML format. + */ + QXmlStreamReader *mXmlReader; + + /** + * @brief XML stream writer for writing the report in XML format. + */ + QXmlStreamWriter *mXmlWriter; +}; +/// @} +#endif // XML_REPORTV2_H From df231aa7387085eba4cfbf85a90b122ec18ff13c Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Fri, 4 Feb 2011 23:56:14 +0200 Subject: [PATCH 02/21] GUI: Add base class for XML report classes. A base class is needed for e.g. some common routines that can be shared between the formats. --- gui/gui.pro | 2 + gui/resultsview.cpp | 5 +- gui/xmlreport.cpp | 148 +------------------------------------ gui/xmlreport.h | 63 +--------------- gui/xmlreportv1.cpp | 175 ++++++++++++++++++++++++++++++++++++++++++++ gui/xmlreportv1.h | 96 ++++++++++++++++++++++++ gui/xmlreportv2.cpp | 2 +- gui/xmlreportv2.h | 4 +- 8 files changed, 284 insertions(+), 211 deletions(-) create mode 100644 gui/xmlreportv1.cpp create mode 100644 gui/xmlreportv1.h diff --git a/gui/gui.pro b/gui/gui.pro index 5df4c2bab..25f3a73a2 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -69,6 +69,7 @@ HEADERS += mainwindow.h \ report.h \ txtreport.h \ xmlreport.h \ + xmlreportv1.h \ xmlreportv2.h \ translationhandler.h \ csvreport.h \ @@ -97,6 +98,7 @@ SOURCES += main.cpp \ report.cpp \ txtreport.cpp \ xmlreport.cpp \ + xmlreportv1.cpp \ xmlreportv2.cpp \ translationhandler.cpp \ csvreport.cpp \ diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index e74d7b982..6c3615f56 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -31,6 +31,7 @@ #include "report.h" #include "txtreport.h" #include "xmlreport.h" +#include "xmlreportv1.h" #include "xmlreportv2.h" #include "csvreport.h" #include "applicationlist.h" @@ -131,7 +132,7 @@ void ResultsView::Save(const QString &filename, Report::Type type) report = new TxtReport(filename, this); break; case Report::XML: - report = new XmlReport(filename, this); + report = new XmlReportV1(filename, this); break; case Report::XMLV2: report = new XmlReportV2(filename, this); @@ -243,7 +244,7 @@ void ResultsView::DisableProgressbar() void ResultsView::ReadErrorsXml(const QString &filename) { - XmlReport *report = new XmlReport(filename, this); + XmlReportV1 *report = new XmlReportV1(filename, this); QList errors; if (report) { diff --git a/gui/xmlreport.cpp b/gui/xmlreport.cpp index f481f3615..ce009e3ef 100644 --- a/gui/xmlreport.cpp +++ b/gui/xmlreport.cpp @@ -18,158 +18,12 @@ #include #include -#include -#include -#include -#include -#include #include "report.h" -#include "erroritem.h" #include "xmlreport.h" -static const char ResultElementName[] = "results"; -static const char ErrorElementName[] = "error"; -static const char FilenameAttribute[] = "file"; -static const char LineAttribute[] = "line"; -static const char IdAttribute[] = "id"; -static const char SeverityAttribute[] = "severity"; -static const char MsgAttribute[] = "msg"; XmlReport::XmlReport(const QString &filename, QObject * parent) : - Report(filename, parent), - mXmlReader(NULL), - mXmlWriter(NULL) + Report(filename, parent) { } -XmlReport::~XmlReport() -{ - delete mXmlReader; - delete mXmlWriter; - Close(); -} - -bool XmlReport::Create() -{ - bool success = false; - if (Report::Create()) - { - mXmlWriter = new QXmlStreamWriter(Report::GetFile()); - success = true; - } - return success; -} - -bool XmlReport::Open() -{ - bool success = false; - if (Report::Open()) - { - mXmlReader = new QXmlStreamReader(Report::GetFile()); - success = true; - } - return success; -} - -void XmlReport::WriteHeader() -{ - mXmlWriter->setAutoFormatting(true); - mXmlWriter->writeStartDocument(); - mXmlWriter->writeStartElement(ResultElementName); -} - -void XmlReport::WriteFooter() -{ - mXmlWriter->writeEndElement(); - mXmlWriter->writeEndDocument(); -} - -void XmlReport::WriteError(const ErrorItem &error) -{ - /* - Error example from the core program in xml - - The callstack seems to be ignored here as well, instead last item of the stack is used - */ - - mXmlWriter->writeStartElement(ErrorElementName); - const QString file = QDir::toNativeSeparators(error.files[error.files.size() - 1]); - mXmlWriter->writeAttribute(FilenameAttribute, file); - const QString line = QString::number(error.lines[error.lines.size() - 1]); - mXmlWriter->writeAttribute(LineAttribute, line); - mXmlWriter->writeAttribute(IdAttribute, error.id); - mXmlWriter->writeAttribute(SeverityAttribute, error.severity); - mXmlWriter->writeAttribute(MsgAttribute, error.message); - mXmlWriter->writeEndElement(); -} - -QList XmlReport::Read() -{ - QList errors; - bool insideResults = false; - if (!mXmlReader) - { - qDebug() << "You must Open() the file before reading it!"; - return errors; - } - while (!mXmlReader->atEnd()) - { - switch (mXmlReader->readNext()) - { - case QXmlStreamReader::StartElement: - if (mXmlReader->name() == ResultElementName) - insideResults = true; - - // Read error element from inside result element - if (insideResults && mXmlReader->name() == ErrorElementName) - { - ErrorLine line = ReadError(mXmlReader); - errors.append(line); - } - break; - - case QXmlStreamReader::EndElement: - if (mXmlReader->name() == ResultElementName) - insideResults = false; - break; - - // Not handled - case QXmlStreamReader::NoToken: - case QXmlStreamReader::Invalid: - case QXmlStreamReader::StartDocument: - case QXmlStreamReader::EndDocument: - case QXmlStreamReader::Characters: - case QXmlStreamReader::Comment: - case QXmlStreamReader::DTD: - case QXmlStreamReader::EntityReference: - case QXmlStreamReader::ProcessingInstruction: - break; - } - } - return errors; -} - -ErrorLine XmlReport::ReadError(QXmlStreamReader *reader) -{ - ErrorLine line; - if (reader->name().toString() == ErrorElementName) - { - QXmlStreamAttributes attribs = reader->attributes(); - line.file = attribs.value("", FilenameAttribute).toString(); - line.line = attribs.value("", LineAttribute).toString().toUInt(); - line.id = attribs.value("", IdAttribute).toString(); - line.severity = attribs.value("", SeverityAttribute).toString(); - - // NOTE: This dublicates the message to Summary-field. But since - // old XML format doesn't have separate summary and verbose messages - // we must add same message to both data so it shows up in GUI. - // Check if there is full stop and cut the summary to it. - QString summary = attribs.value("", MsgAttribute).toString(); - const int ind = summary.indexOf('.'); - if (ind != -1) - summary = summary.left(ind + 1); - line.summary = summary; - line.message = attribs.value("", MsgAttribute).toString(); - } - return line; -} diff --git a/gui/xmlreport.h b/gui/xmlreport.h index 0c8058dd0..b1afd192f 100644 --- a/gui/xmlreport.h +++ b/gui/xmlreport.h @@ -19,78 +19,23 @@ #ifndef XML_REPORT_H #define XML_REPORT_H -#include #include -#include -#include -#include -#include #include "report.h" +class QObject; + /// @addtogroup GUI /// @{ /** -* @brief XML file report. -* This report outputs XML-formatted report. The XML format must match command -* line version's XML output. +* @brief Base class for XML report classes. */ class XmlReport : public Report { public: XmlReport(const QString &filename, QObject * parent = 0); - virtual ~XmlReport(); - - /** - * @brief Create the report (file). - * @return true if succeeded, false if file could not be created. - */ - virtual bool Create(); - - /** - * @brief Open existing report file. - */ - bool Open(); - - /** - * @brief Write report header. - */ - virtual void WriteHeader(); - - /** - * @brief Write report footer. - */ - virtual void WriteFooter(); - - /** - * @brief Write error to report. - * @param error Error data. - */ - virtual void WriteError(const ErrorItem &error); - - /** - * @brief Read contents of the report file. - */ - QList Read(); - -protected: - /** - * @brief Read and parse error item from XML stream. - * @param reader XML stream reader to use. - */ - ErrorLine ReadError(QXmlStreamReader *reader); - -private: - /** - * @brief XML stream reader for reading the report in XML format. - */ - QXmlStreamReader *mXmlReader; - - /** - * @brief XML stream writer for writing the report in XML format. - */ - QXmlStreamWriter *mXmlWriter; }; /// @} + #endif // XML_REPORT_H diff --git a/gui/xmlreportv1.cpp b/gui/xmlreportv1.cpp new file mode 100644 index 000000000..9fa8cbfd3 --- /dev/null +++ b/gui/xmlreportv1.cpp @@ -0,0 +1,175 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include "report.h" +#include "erroritem.h" +#include "xmlreportv1.h" + +static const char ResultElementName[] = "results"; +static const char ErrorElementName[] = "error"; +static const char FilenameAttribute[] = "file"; +static const char LineAttribute[] = "line"; +static const char IdAttribute[] = "id"; +static const char SeverityAttribute[] = "severity"; +static const char MsgAttribute[] = "msg"; + +XmlReportV1::XmlReportV1(const QString &filename, QObject * parent) : + XmlReport(filename, parent), + mXmlReader(NULL), + mXmlWriter(NULL) +{ +} + +XmlReportV1::~XmlReportV1() +{ + delete mXmlReader; + delete mXmlWriter; + Close(); +} + +bool XmlReportV1::Create() +{ + bool success = false; + if (Report::Create()) + { + mXmlWriter = new QXmlStreamWriter(Report::GetFile()); + success = true; + } + return success; +} + +bool XmlReportV1::Open() +{ + bool success = false; + if (Report::Open()) + { + mXmlReader = new QXmlStreamReader(Report::GetFile()); + success = true; + } + return success; +} + +void XmlReportV1::WriteHeader() +{ + mXmlWriter->setAutoFormatting(true); + mXmlWriter->writeStartDocument(); + mXmlWriter->writeStartElement(ResultElementName); +} + +void XmlReportV1::WriteFooter() +{ + mXmlWriter->writeEndElement(); + mXmlWriter->writeEndDocument(); +} + +void XmlReportV1::WriteError(const ErrorItem &error) +{ + /* + Error example from the core program in xml + + The callstack seems to be ignored here as well, instead last item of the stack is used + */ + + mXmlWriter->writeStartElement(ErrorElementName); + const QString file = QDir::toNativeSeparators(error.files[error.files.size() - 1]); + mXmlWriter->writeAttribute(FilenameAttribute, file); + const QString line = QString::number(error.lines[error.lines.size() - 1]); + mXmlWriter->writeAttribute(LineAttribute, line); + mXmlWriter->writeAttribute(IdAttribute, error.id); + mXmlWriter->writeAttribute(SeverityAttribute, error.severity); + mXmlWriter->writeAttribute(MsgAttribute, error.message); + mXmlWriter->writeEndElement(); +} + +QList XmlReportV1::Read() +{ + QList errors; + bool insideResults = false; + if (!mXmlReader) + { + qDebug() << "You must Open() the file before reading it!"; + return errors; + } + while (!mXmlReader->atEnd()) + { + switch (mXmlReader->readNext()) + { + case QXmlStreamReader::StartElement: + if (mXmlReader->name() == ResultElementName) + insideResults = true; + + // Read error element from inside result element + if (insideResults && mXmlReader->name() == ErrorElementName) + { + ErrorLine line = ReadError(mXmlReader); + errors.append(line); + } + break; + + case QXmlStreamReader::EndElement: + if (mXmlReader->name() == ResultElementName) + insideResults = false; + break; + + // Not handled + case QXmlStreamReader::NoToken: + case QXmlStreamReader::Invalid: + case QXmlStreamReader::StartDocument: + case QXmlStreamReader::EndDocument: + case QXmlStreamReader::Characters: + case QXmlStreamReader::Comment: + case QXmlStreamReader::DTD: + case QXmlStreamReader::EntityReference: + case QXmlStreamReader::ProcessingInstruction: + break; + } + } + return errors; +} + +ErrorLine XmlReportV1::ReadError(QXmlStreamReader *reader) +{ + ErrorLine line; + if (reader->name().toString() == ErrorElementName) + { + QXmlStreamAttributes attribs = reader->attributes(); + line.file = attribs.value("", FilenameAttribute).toString(); + line.line = attribs.value("", LineAttribute).toString().toUInt(); + line.id = attribs.value("", IdAttribute).toString(); + line.severity = attribs.value("", SeverityAttribute).toString(); + + // NOTE: This dublicates the message to Summary-field. But since + // old XML format doesn't have separate summary and verbose messages + // we must add same message to both data so it shows up in GUI. + // Check if there is full stop and cut the summary to it. + QString summary = attribs.value("", MsgAttribute).toString(); + const int ind = summary.indexOf('.'); + if (ind != -1) + summary = summary.left(ind + 1); + line.summary = summary; + line.message = attribs.value("", MsgAttribute).toString(); + } + return line; +} diff --git a/gui/xmlreportv1.h b/gui/xmlreportv1.h new file mode 100644 index 000000000..685afa9ef --- /dev/null +++ b/gui/xmlreportv1.h @@ -0,0 +1,96 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef XML_REPORTV1_H +#define XML_REPORTV1_H + +#include +#include +#include +#include +#include +#include +#include "xmlreport.h" + +/// @addtogroup GUI +/// @{ + + +/** +* @brief XML file report version 1. +* This report outputs XML-formatted report, version 1. The XML format must match command +* line version's XML output. +*/ +class XmlReportV1 : public XmlReport +{ +public: + XmlReportV1(const QString &filename, QObject * parent = 0); + virtual ~XmlReportV1(); + + /** + * @brief Create the report (file). + * @return true if succeeded, false if file could not be created. + */ + virtual bool Create(); + + /** + * @brief Open existing report file. + */ + bool Open(); + + /** + * @brief Write report header. + */ + virtual void WriteHeader(); + + /** + * @brief Write report footer. + */ + virtual void WriteFooter(); + + /** + * @brief Write error to report. + * @param error Error data. + */ + virtual void WriteError(const ErrorItem &error); + + /** + * @brief Read contents of the report file. + */ + virtual QList Read(); + +protected: + /** + * @brief Read and parse error item from XML stream. + * @param reader XML stream reader to use. + */ + ErrorLine ReadError(QXmlStreamReader *reader); + +private: + /** + * @brief XML stream reader for reading the report in XML format. + */ + QXmlStreamReader *mXmlReader; + + /** + * @brief XML stream writer for writing the report in XML format. + */ + QXmlStreamWriter *mXmlWriter; +}; +/// @} +#endif // XML_REPORTV1_H diff --git a/gui/xmlreportv2.cpp b/gui/xmlreportv2.cpp index 165811b2e..4caf7d05e 100644 --- a/gui/xmlreportv2.cpp +++ b/gui/xmlreportv2.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2011 Daniel Marjamki and Cppcheck team. + * Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/xmlreportv2.h b/gui/xmlreportv2.h index 33f96349d..3107b32b3 100644 --- a/gui/xmlreportv2.h +++ b/gui/xmlreportv2.h @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2011 Daniel Marjamki and Cppcheck team. + * Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -72,7 +72,7 @@ public: /** * @brief Read contents of the report file. */ - QList Read(); + virtual QList Read(); protected: /** From 299e200d45957768f15d34835e0249cf2d30f729 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 5 Feb 2011 00:23:25 +0200 Subject: [PATCH 03/21] GUI: Quote special chars in the XML output. Fixes ticket #2543 (GUI: Xml report does not quote special characters) --- gui/xmlreport.cpp | 10 ++++++++++ gui/xmlreport.h | 7 +++++++ gui/xmlreportv1.cpp | 7 +++++-- gui/xmlreportv2.cpp | 10 +++++++--- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/gui/xmlreport.cpp b/gui/xmlreport.cpp index ce009e3ef..a63aa5be2 100644 --- a/gui/xmlreport.cpp +++ b/gui/xmlreport.cpp @@ -27,3 +27,13 @@ XmlReport::XmlReport(const QString &filename, QObject * parent) : { } +QString XmlReport::quoteMessage(const QString &message) +{ + QString quotedMessage(message); + quotedMessage.replace("&", "&"); + quotedMessage.replace("\"", """); + quotedMessage.replace("'", "'"); + quotedMessage.replace("<", "<"); + quotedMessage.replace(">", ">"); + return quotedMessage; +} diff --git a/gui/xmlreport.h b/gui/xmlreport.h index b1afd192f..bb94bb79b 100644 --- a/gui/xmlreport.h +++ b/gui/xmlreport.h @@ -35,6 +35,13 @@ class XmlReport : public Report { public: XmlReport(const QString &filename, QObject * parent = 0); + + /** + * @brief Quote the message. + * @param message Message to quote. + * @return quoted message. + */ + static QString quoteMessage(const QString &message); }; /// @} diff --git a/gui/xmlreportv1.cpp b/gui/xmlreportv1.cpp index 9fa8cbfd3..7fdf2d5fb 100644 --- a/gui/xmlreportv1.cpp +++ b/gui/xmlreportv1.cpp @@ -25,6 +25,7 @@ #include #include "report.h" #include "erroritem.h" +#include "xmlreport.h" #include "xmlreportv1.h" static const char ResultElementName[] = "results"; @@ -93,13 +94,15 @@ void XmlReportV1::WriteError(const ErrorItem &error) */ mXmlWriter->writeStartElement(ErrorElementName); - const QString file = QDir::toNativeSeparators(error.files[error.files.size() - 1]); + QString file = QDir::toNativeSeparators(error.files[error.files.size() - 1]); + file = XmlReport::quoteMessage(file); mXmlWriter->writeAttribute(FilenameAttribute, file); const QString line = QString::number(error.lines[error.lines.size() - 1]); mXmlWriter->writeAttribute(LineAttribute, line); mXmlWriter->writeAttribute(IdAttribute, error.id); mXmlWriter->writeAttribute(SeverityAttribute, error.severity); - mXmlWriter->writeAttribute(MsgAttribute, error.message); + const QString message = XmlReport::quoteMessage(error.message); + mXmlWriter->writeAttribute(MsgAttribute, message); mXmlWriter->writeEndElement(); } diff --git a/gui/xmlreportv2.cpp b/gui/xmlreportv2.cpp index 4caf7d05e..6c4fc088f 100644 --- a/gui/xmlreportv2.cpp +++ b/gui/xmlreportv2.cpp @@ -25,6 +25,7 @@ #include #include "report.h" #include "erroritem.h" +#include "xmlreport.h" #include "xmlreportv2.h" #include "cppcheck.h" @@ -110,14 +111,17 @@ void XmlReportV2::WriteError(const ErrorItem &error) mXmlWriter->writeStartElement(ErrorElementName); mXmlWriter->writeAttribute(IdAttribute, error.id); mXmlWriter->writeAttribute(SeverityAttribute, error.severity); - mXmlWriter->writeAttribute(MsgAttribute, error.summary); - mXmlWriter->writeAttribute(VerboseAttribute, error.message); + const QString summary = XmlReport::quoteMessage(error.summary); + mXmlWriter->writeAttribute(MsgAttribute, summary); + const QString message = XmlReport::quoteMessage(error.message); + mXmlWriter->writeAttribute(VerboseAttribute, message); for (int i = 0; i < error.files.count(); i++) { mXmlWriter->writeStartElement(LocationElementName); - const QString file = QDir::toNativeSeparators(error.files[i]); + QString file = QDir::toNativeSeparators(error.files[i]); + file = XmlReport::quoteMessage(file); mXmlWriter->writeAttribute(FilenameAttribute, file); const QString line = QString::number(error.lines[i]); mXmlWriter->writeAttribute(LineAttribute, line); From 0f0f53f9193cf0c277c8009658d3add1f25d7211 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 5 Feb 2011 12:12:34 +0200 Subject: [PATCH 04/21] GUI: Determine the XML report format before reading report. --- gui/resultsview.cpp | 17 +++++++++++++++- gui/xmlreport.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++ gui/xmlreport.h | 13 ++++++++++++ gui/xmlreportv2.cpp | 2 +- gui/xmlreportv2.h | 2 +- 5 files changed, 79 insertions(+), 3 deletions(-) diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 6c3615f56..1ded1c4b4 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -244,7 +244,22 @@ void ResultsView::DisableProgressbar() void ResultsView::ReadErrorsXml(const QString &filename) { - XmlReportV1 *report = new XmlReportV1(filename, this); + const int version = XmlReport::determineVersion(filename); + if (version == 0) + { + QMessageBox msgBox; + msgBox.setText(tr("Failed to read the report.")); + msgBox.setIcon(QMessageBox::Critical); + msgBox.exec(); + return; + } + + XmlReport *report = NULL; + if (version == 1) + report = new XmlReportV1(filename, this); + else if (version == 2) + report = new XmlReportV2(filename, this); + QList errors; if (report) { diff --git a/gui/xmlreport.cpp b/gui/xmlreport.cpp index a63aa5be2..c3cc521d3 100644 --- a/gui/xmlreport.cpp +++ b/gui/xmlreport.cpp @@ -18,9 +18,13 @@ #include #include +#include +#include #include "report.h" #include "xmlreport.h" +static const char ResultElementName[] = "results"; +static const char VersionAttribute[] = "version"; XmlReport::XmlReport(const QString &filename, QObject * parent) : Report(filename, parent) @@ -37,3 +41,47 @@ QString XmlReport::quoteMessage(const QString &message) quotedMessage.replace(">", ">"); return quotedMessage; } + +int XmlReport::determineVersion(const QString &filename) +{ + QFile file; + file.setFileName(filename); + bool succeed = file.open(QIODevice::ReadOnly | QIODevice::Text); + if (!succeed) + return 0; + + QXmlStreamReader reader(&file); + while (!reader.atEnd()) + { + switch (reader.readNext()) + { + case QXmlStreamReader::StartElement: + if (reader.name() == ResultElementName) + { + QXmlStreamAttributes attribs = reader.attributes(); + if (attribs.hasAttribute(QString(VersionAttribute))) + { + int ver = attribs.value("", VersionAttribute).toString().toInt(); + return ver; + } + else + return 1; + } + break; + + // Not handled + case QXmlStreamReader::EndElement: + case QXmlStreamReader::NoToken: + case QXmlStreamReader::Invalid: + case QXmlStreamReader::StartDocument: + case QXmlStreamReader::EndDocument: + case QXmlStreamReader::Characters: + case QXmlStreamReader::Comment: + case QXmlStreamReader::DTD: + case QXmlStreamReader::EntityReference: + case QXmlStreamReader::ProcessingInstruction: + break; + } + } + return 0; +} diff --git a/gui/xmlreport.h b/gui/xmlreport.h index bb94bb79b..45ce6f3c7 100644 --- a/gui/xmlreport.h +++ b/gui/xmlreport.h @@ -20,6 +20,7 @@ #define XML_REPORT_H #include +#include #include "report.h" class QObject; @@ -36,12 +37,24 @@ class XmlReport : public Report public: XmlReport(const QString &filename, QObject * parent = 0); + /** + * @brief Read contents of the report file. + */ + virtual QList Read() = 0; + /** * @brief Quote the message. * @param message Message to quote. * @return quoted message. */ static QString quoteMessage(const QString &message); + + /** + * @brief Get the XML report format version from the file. + * @param filename Filename of the report file. + * @return XML report format version or 0 if error happened. + */ + static int determineVersion(const QString &filename); }; /// @} diff --git a/gui/xmlreportv2.cpp b/gui/xmlreportv2.cpp index 6c4fc088f..0659cf03f 100644 --- a/gui/xmlreportv2.cpp +++ b/gui/xmlreportv2.cpp @@ -43,7 +43,7 @@ static const char VersionAttribute[] = "version"; static const char VerboseAttribute[] = "verbose"; XmlReportV2::XmlReportV2(const QString &filename, QObject * parent) : - Report(filename, parent), + XmlReport(filename, parent), mXmlReader(NULL), mXmlWriter(NULL) { diff --git a/gui/xmlreportv2.h b/gui/xmlreportv2.h index 3107b32b3..ba793061c 100644 --- a/gui/xmlreportv2.h +++ b/gui/xmlreportv2.h @@ -36,7 +36,7 @@ * This report outputs XML-formatted report. The XML format must match command * line version's XML output. */ -class XmlReportV2 : public Report +class XmlReportV2 : public XmlReport { public: XmlReportV2(const QString &filename, QObject * parent = 0); From d31703e4528c60954e7792ee9ee4092f3869a1a3 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 5 Feb 2011 12:41:29 +0200 Subject: [PATCH 05/21] GUI: Read ErrorItems instead of ErrorLines from XML report. XML report format 1 only had error "lines" that we promoted to "items" when adding to GUI. XML report format 2 contains error "items" so change the code to read items and do the promotion directly when reading and parsing the data. --- gui/resultsview.cpp | 7 +++---- gui/xmlreport.h | 3 ++- gui/xmlreportv1.cpp | 29 ++++++++++++++++------------- gui/xmlreportv1.h | 4 ++-- gui/xmlreportv2.cpp | 29 ++++++++++++++++------------- gui/xmlreportv2.h | 4 ++-- 6 files changed, 41 insertions(+), 35 deletions(-) diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 1ded1c4b4..1d4f90568 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -260,7 +260,7 @@ void ResultsView::ReadErrorsXml(const QString &filename) else if (version == 2) report = new XmlReportV2(filename, this); - QList errors; + QList errors; if (report) { if (report->Open()) @@ -283,10 +283,9 @@ void ResultsView::ReadErrorsXml(const QString &filename) msgBox.exec(); } - ErrorLine line; - foreach(line, errors) + ErrorItem item; + foreach(item, errors) { - ErrorItem item(line); mUI.mTree->AddErrorItem(item); } mUI.mTree->SetCheckDirectory(""); diff --git a/gui/xmlreport.h b/gui/xmlreport.h index 45ce6f3c7..e0e4e55ba 100644 --- a/gui/xmlreport.h +++ b/gui/xmlreport.h @@ -22,6 +22,7 @@ #include #include #include "report.h" +#include "erroritem.h" class QObject; @@ -40,7 +41,7 @@ public: /** * @brief Read contents of the report file. */ - virtual QList Read() = 0; + virtual QList Read() = 0; /** * @brief Quote the message. diff --git a/gui/xmlreportv1.cpp b/gui/xmlreportv1.cpp index 7fdf2d5fb..8df2a89da 100644 --- a/gui/xmlreportv1.cpp +++ b/gui/xmlreportv1.cpp @@ -106,9 +106,9 @@ void XmlReportV1::WriteError(const ErrorItem &error) mXmlWriter->writeEndElement(); } -QList XmlReportV1::Read() +QList XmlReportV1::Read() { - QList errors; + QList errors; bool insideResults = false; if (!mXmlReader) { @@ -126,8 +126,8 @@ QList XmlReportV1::Read() // Read error element from inside result element if (insideResults && mXmlReader->name() == ErrorElementName) { - ErrorLine line = ReadError(mXmlReader); - errors.append(line); + ErrorItem item = ReadError(mXmlReader); + errors.append(item); } break; @@ -152,16 +152,19 @@ QList XmlReportV1::Read() return errors; } -ErrorLine XmlReportV1::ReadError(QXmlStreamReader *reader) +ErrorItem XmlReportV1::ReadError(QXmlStreamReader *reader) { - ErrorLine line; + ErrorItem item; if (reader->name().toString() == ErrorElementName) { QXmlStreamAttributes attribs = reader->attributes(); - line.file = attribs.value("", FilenameAttribute).toString(); - line.line = attribs.value("", LineAttribute).toString().toUInt(); - line.id = attribs.value("", IdAttribute).toString(); - line.severity = attribs.value("", SeverityAttribute).toString(); + const QString file = attribs.value("", FilenameAttribute).toString(); + item.file = file; + item.files.push_back(file); + const int line = attribs.value("", LineAttribute).toString().toUInt(); + item.lines.push_back(line); + item.id = attribs.value("", IdAttribute).toString(); + item.severity = attribs.value("", SeverityAttribute).toString(); // NOTE: This dublicates the message to Summary-field. But since // old XML format doesn't have separate summary and verbose messages @@ -171,8 +174,8 @@ ErrorLine XmlReportV1::ReadError(QXmlStreamReader *reader) const int ind = summary.indexOf('.'); if (ind != -1) summary = summary.left(ind + 1); - line.summary = summary; - line.message = attribs.value("", MsgAttribute).toString(); + item.summary = summary; + item.message = attribs.value("", MsgAttribute).toString(); } - return line; + return item; } diff --git a/gui/xmlreportv1.h b/gui/xmlreportv1.h index 685afa9ef..181b21e4b 100644 --- a/gui/xmlreportv1.h +++ b/gui/xmlreportv1.h @@ -72,14 +72,14 @@ public: /** * @brief Read contents of the report file. */ - virtual QList Read(); + virtual QList Read(); protected: /** * @brief Read and parse error item from XML stream. * @param reader XML stream reader to use. */ - ErrorLine ReadError(QXmlStreamReader *reader); + ErrorItem ReadError(QXmlStreamReader *reader); private: /** diff --git a/gui/xmlreportv2.cpp b/gui/xmlreportv2.cpp index 0659cf03f..7e2011a92 100644 --- a/gui/xmlreportv2.cpp +++ b/gui/xmlreportv2.cpp @@ -132,9 +132,9 @@ void XmlReportV2::WriteError(const ErrorItem &error) mXmlWriter->writeEndElement(); } -QList XmlReportV2::Read() +QList XmlReportV2::Read() { - QList errors; + QList errors; bool insideResults = false; if (!mXmlReader) { @@ -152,8 +152,8 @@ QList XmlReportV2::Read() // Read error element from inside result element if (insideResults && mXmlReader->name() == ErrorElementName) { - ErrorLine line = ReadError(mXmlReader); - errors.append(line); + ErrorItem item = ReadError(mXmlReader); + errors.append(item); } break; @@ -178,16 +178,19 @@ QList XmlReportV2::Read() return errors; } -ErrorLine XmlReportV2::ReadError(QXmlStreamReader *reader) +ErrorItem XmlReportV2::ReadError(QXmlStreamReader *reader) { - ErrorLine line; + ErrorItem item; if (reader->name().toString() == ErrorElementName) { QXmlStreamAttributes attribs = reader->attributes(); - line.file = attribs.value("", FilenameAttribute).toString(); - line.line = attribs.value("", LineAttribute).toString().toUInt(); - line.id = attribs.value("", IdAttribute).toString(); - line.severity = attribs.value("", SeverityAttribute).toString(); + const QString file = attribs.value("", FilenameAttribute).toString(); + item.file = file; + item.files.push_back(file); + const int line = attribs.value("", LineAttribute).toString().toUInt(); + item.lines.push_back(line); + item.id = attribs.value("", IdAttribute).toString(); + item.severity = attribs.value("", SeverityAttribute).toString(); // NOTE: This dublicates the message to Summary-field. But since // old XML format doesn't have separate summary and verbose messages @@ -197,8 +200,8 @@ ErrorLine XmlReportV2::ReadError(QXmlStreamReader *reader) const int ind = summary.indexOf('.'); if (ind != -1) summary = summary.left(ind + 1); - line.summary = summary; - line.message = attribs.value("", MsgAttribute).toString(); + item.summary = summary; + item.message = attribs.value("", MsgAttribute).toString(); } - return line; + return item; } diff --git a/gui/xmlreportv2.h b/gui/xmlreportv2.h index ba793061c..6b1a2841c 100644 --- a/gui/xmlreportv2.h +++ b/gui/xmlreportv2.h @@ -72,14 +72,14 @@ public: /** * @brief Read contents of the report file. */ - virtual QList Read(); + virtual QList Read(); protected: /** * @brief Read and parse error item from XML stream. * @param reader XML stream reader to use. */ - ErrorLine ReadError(QXmlStreamReader *reader); + ErrorItem ReadError(QXmlStreamReader *reader); private: /** From 26f017e9c685ff022ad7527b775194de3d1c37be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 5 Feb 2011 12:53:28 +0100 Subject: [PATCH 06/21] scripts: added tabs.pl - in my opinion it is bad to use tabs inside string constants. spaces or \t should be used instead. --- scripts/tabs.pl | 35 +++++++++++++++++++++++++++++++++++ test/testclass.cpp | 12 ++++++------ test/testmathlib.cpp | 20 ++++++++++---------- test/testnullpointer.cpp | 2 +- test/testuninitvar.cpp | 6 +++--- 5 files changed, 55 insertions(+), 20 deletions(-) create mode 100755 scripts/tabs.pl diff --git a/scripts/tabs.pl b/scripts/tabs.pl new file mode 100755 index 000000000..bf58359ae --- /dev/null +++ b/scripts/tabs.pl @@ -0,0 +1,35 @@ +#!/usr/bin/perl +# warn if there are tabs in string constants, it can have surprising effects. +# example usage: +# scripts/tabs.pl lib/checkstl.cpp + +sub checkfile +{ + my $filename = $_[0]; + + # parse file + open(FILE, $filename); + my @lines = ; + close(FILE); + + # check comments.. + my $linenr = 0; + foreach $line (@lines) + { + $linenr = $linenr + 1; + + # is there a tab in a string + if ($line =~ /".*\t.*"/) + { + print "[$filename:$linenr] tab inside string constant\n"; + } + } +} + + +foreach $filename (@ARGV) +{ + checkfile($filename) +} + + diff --git a/test/testclass.cpp b/test/testclass.cpp index a8cb213e1..fd284f8fb 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -488,11 +488,11 @@ private: " UString& operator=( const UString& s );\n" "};\n" "UString& UString::assign( const char* c_str ) {\n" - " std::string tmp( c_str );\n" - " return assign( tmp );\n" + " std::string tmp( c_str );\n" + " return assign( tmp );\n" "}\n" "UString& UString::operator=( const UString& s ) {\n" - " return assign( s );\n" + " return assign( s );\n" "}\n"); } @@ -2723,7 +2723,7 @@ private: " A()\n" " {\n" " init();\n" - " }\n" + " }\n" "\n" " void init() { init(0); }\n" "\n" @@ -5452,12 +5452,12 @@ private: checkConst("template class E,class D> class C : E\n" "{\n" "public:\n" - " int f();\n" + " int f();\n" "};\n" "class E : C\n" "{\n" "public:\n" - " int f() { return C< ::D,int>::f(); }\n" + " int f() { return C< ::D,int>::f(); }\n" "};\n"); ASSERT_EQUALS("", errout.str()); diff --git a/test/testmathlib.cpp b/test/testmathlib.cpp index f05a029bc..cd3637da3 100644 --- a/test/testmathlib.cpp +++ b/test/testmathlib.cpp @@ -66,20 +66,20 @@ private: ASSERT_EQUALS("3000" , MathLib::multiply("1.0E3", "3")); ASSERT_EQUALS("-3000" , MathLib::multiply("-1.0E3", "3")); ASSERT_EQUALS("-3000" , MathLib::multiply("-1.0E+3", "3")); - ASSERT_EQUALS("0" , MathLib::multiply("-1.0E+3", "0")); - ASSERT_EQUALS("0" , MathLib::multiply("+1.0E+3", "0")); - ASSERT_EQUALS("2147483648" , MathLib::multiply("2","1073741824")); - ASSERT_EQUALS("536870912" , MathLib::multiply("512","1048576")); + ASSERT_EQUALS("0" , MathLib::multiply("-1.0E+3", "0")); + ASSERT_EQUALS("0" , MathLib::multiply("+1.0E+3", "0")); + ASSERT_EQUALS("2147483648" , MathLib::multiply("2","1073741824")); + ASSERT_EQUALS("536870912" , MathLib::multiply("512","1048576")); // divide - ASSERT_EQUALS("1" , MathLib::divide("1", "1")); - ASSERT_EQUALS("0" , MathLib::divide("0", "1")); - ASSERT_EQUALS("5" , MathLib::divide("-10", "-2")); + ASSERT_EQUALS("1" , MathLib::divide("1", "1")); + ASSERT_EQUALS("0" , MathLib::divide("0", "1")); + ASSERT_EQUALS("5" , MathLib::divide("-10", "-2")); ASSERT_EQUALS("-2.5", MathLib::divide("-10.", "4")); ASSERT_EQUALS("2.5" , MathLib::divide("-10.", "-4")); - ASSERT_EQUALS("5" , MathLib::divide("25.5", "5.1")); - ASSERT_EQUALS("7" , MathLib::divide("21.", "3")); - ASSERT_EQUALS("1" , MathLib::divide("3", "2")); + ASSERT_EQUALS("5" , MathLib::divide("25.5", "5.1")); + ASSERT_EQUALS("7" , MathLib::divide("21.", "3")); + ASSERT_EQUALS("1" , MathLib::divide("3", "2")); } diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 0c9e09a1f..35b239974 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -668,7 +668,7 @@ private: check("void f(int a) {\n" " const char *p = 0;\n" " if (a) {\n" - " p = \"abcd\";\n" + " p = \"abcd\";\n" " }\n" " for (int i = 0; i < 3; i++) {\n" " if (a && (p[i] == '1'));\n" diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 9c24fe6a5..3dc598f83 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -736,9 +736,9 @@ private: checkUninitVar("enum ABCD { A, B, C, D };\n" "\n" "static void f(char *str ) {\n" - " enum ABCD i;\n" - " for (i = 0; i < D; i++) {\n" - " str[i] = 0;\n" + " enum ABCD i;\n" + " for (i = 0; i < D; i++) {\n" + " str[i] = 0;\n" " }\n" "}\n"); ASSERT_EQUALS("", errout.str()); From 9eacceb00ac43281459b1789b5a150dd7d50ebab Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 5 Feb 2011 15:56:56 +0200 Subject: [PATCH 07/21] GUI: Read XML format version 2 files. Implement the parsing of XML format v2 error data. --- gui/xmlreportv2.cpp | 69 +++++++++++++++++++++++++++++++++++---------- gui/xmlreportv2.h | 6 ++++ 2 files changed, 60 insertions(+), 15 deletions(-) diff --git a/gui/xmlreportv2.cpp b/gui/xmlreportv2.cpp index 7e2011a92..e6068ed8c 100644 --- a/gui/xmlreportv2.cpp +++ b/gui/xmlreportv2.cpp @@ -180,28 +180,67 @@ QList XmlReportV2::Read() ErrorItem XmlReportV2::ReadError(QXmlStreamReader *reader) { + /* + Error example from the core program in xml + + + + + */ + ErrorItem item; if (reader->name().toString() == ErrorElementName) { QXmlStreamAttributes attribs = reader->attributes(); - const QString file = attribs.value("", FilenameAttribute).toString(); - item.file = file; - item.files.push_back(file); - const int line = attribs.value("", LineAttribute).toString().toUInt(); - item.lines.push_back(line); item.id = attribs.value("", IdAttribute).toString(); item.severity = attribs.value("", SeverityAttribute).toString(); + item.summary = attribs.value("", MsgAttribute).toString(); + item.message = attribs.value("", VerboseAttribute).toString(); - // NOTE: This dublicates the message to Summary-field. But since - // old XML format doesn't have separate summary and verbose messages - // we must add same message to both data so it shows up in GUI. - // Check if there is full stop and cut the summary to it. - QString summary = attribs.value("", MsgAttribute).toString(); - const int ind = summary.indexOf('.'); - if (ind != -1) - summary = summary.left(ind + 1); - item.summary = summary; - item.message = attribs.value("", MsgAttribute).toString(); + ReadLocations(item); } return item; } + +void XmlReportV2::ReadLocations(ErrorItem &item) +{ + QList errors; + bool allRead = false; + while (!allRead && !mXmlReader->atEnd()) + { + switch (mXmlReader->readNext()) + { + case QXmlStreamReader::StartElement: + if (mXmlReader->name() != LocationElementName) + continue; // Skip other than location elements + { + QXmlStreamAttributes attribs = mXmlReader->attributes(); + const QString file = attribs.value("", FilenameAttribute).toString(); + if (item.file.isEmpty()) + item.file = file; + item.files.push_back(file); + const int line = attribs.value("", LineAttribute).toString().toUInt(); + item.lines.push_back(line); + } + break; + + case QXmlStreamReader::EndElement: + if (mXmlReader->name() == LocationElementName) + allRead = true; + break; + + // Not handled + case QXmlStreamReader::NoToken: + case QXmlStreamReader::Invalid: + case QXmlStreamReader::StartDocument: + case QXmlStreamReader::EndDocument: + case QXmlStreamReader::Characters: + case QXmlStreamReader::Comment: + case QXmlStreamReader::DTD: + case QXmlStreamReader::EntityReference: + case QXmlStreamReader::ProcessingInstruction: + break; + } + } +} diff --git a/gui/xmlreportv2.h b/gui/xmlreportv2.h index 6b1a2841c..d60b71126 100644 --- a/gui/xmlreportv2.h +++ b/gui/xmlreportv2.h @@ -81,6 +81,12 @@ protected: */ ErrorItem ReadError(QXmlStreamReader *reader); + /** + * @brief Read and parse error items location elements from XML stream. + * @param item ErrorItem to write the location data. + */ + void ReadLocations(ErrorItem &item); + private: /** * @brief XML stream reader for reading the report in XML format. From f279fcd351e5331551b34ab0f7c26730eb0af068 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 5 Feb 2011 16:07:59 +0200 Subject: [PATCH 08/21] GUI: Unquote special characters when reading XML. Unquote the quoted data from XML file when reading. We don't want quoted chars to be visible in the GUI. --- gui/xmlreport.cpp | 11 +++++++++++ gui/xmlreport.h | 7 +++++++ gui/xmlreportv1.cpp | 8 +++++--- gui/xmlreportv2.cpp | 9 ++++++--- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/gui/xmlreport.cpp b/gui/xmlreport.cpp index c3cc521d3..dc8f4be30 100644 --- a/gui/xmlreport.cpp +++ b/gui/xmlreport.cpp @@ -42,6 +42,17 @@ QString XmlReport::quoteMessage(const QString &message) return quotedMessage; } +QString XmlReport::unquoteMessage(const QString &message) +{ + QString quotedMessage(message); + quotedMessage.replace("&", "&"); + quotedMessage.replace(""", "\""); + quotedMessage.replace("'", "'"); + quotedMessage.replace("<", "<"); + quotedMessage.replace(">", ">"); + return quotedMessage; +} + int XmlReport::determineVersion(const QString &filename) { QFile file; diff --git a/gui/xmlreport.h b/gui/xmlreport.h index e0e4e55ba..74d2107d8 100644 --- a/gui/xmlreport.h +++ b/gui/xmlreport.h @@ -50,6 +50,13 @@ public: */ static QString quoteMessage(const QString &message); + /** + * @brief Unquote the message. + * @param message Message to quote. + * @return quoted message. + */ + static QString unquoteMessage(const QString &message); + /** * @brief Get the XML report format version from the file. * @param filename Filename of the report file. diff --git a/gui/xmlreportv1.cpp b/gui/xmlreportv1.cpp index 8df2a89da..1062de07f 100644 --- a/gui/xmlreportv1.cpp +++ b/gui/xmlreportv1.cpp @@ -158,7 +158,8 @@ ErrorItem XmlReportV1::ReadError(QXmlStreamReader *reader) if (reader->name().toString() == ErrorElementName) { QXmlStreamAttributes attribs = reader->attributes(); - const QString file = attribs.value("", FilenameAttribute).toString(); + QString file = attribs.value("", FilenameAttribute).toString(); + file = XmlReport::unquoteMessage(file); item.file = file; item.files.push_back(file); const int line = attribs.value("", LineAttribute).toString().toUInt(); @@ -174,8 +175,9 @@ ErrorItem XmlReportV1::ReadError(QXmlStreamReader *reader) const int ind = summary.indexOf('.'); if (ind != -1) summary = summary.left(ind + 1); - item.summary = summary; - item.message = attribs.value("", MsgAttribute).toString(); + item.summary = XmlReport::unquoteMessage(summary); + QString message = attribs.value("", MsgAttribute).toString(); + item.message = XmlReport::unquoteMessage(message); } return item; } diff --git a/gui/xmlreportv2.cpp b/gui/xmlreportv2.cpp index e6068ed8c..6088ea9a5 100644 --- a/gui/xmlreportv2.cpp +++ b/gui/xmlreportv2.cpp @@ -195,8 +195,10 @@ ErrorItem XmlReportV2::ReadError(QXmlStreamReader *reader) QXmlStreamAttributes attribs = reader->attributes(); item.id = attribs.value("", IdAttribute).toString(); item.severity = attribs.value("", SeverityAttribute).toString(); - item.summary = attribs.value("", MsgAttribute).toString(); - item.message = attribs.value("", VerboseAttribute).toString(); + const QString summary = attribs.value("", MsgAttribute).toString(); + item.summary = XmlReport::unquoteMessage(summary); + const QString message = attribs.value("", VerboseAttribute).toString(); + item.message = XmlReport::unquoteMessage(message); ReadLocations(item); } @@ -216,7 +218,8 @@ void XmlReportV2::ReadLocations(ErrorItem &item) continue; // Skip other than location elements { QXmlStreamAttributes attribs = mXmlReader->attributes(); - const QString file = attribs.value("", FilenameAttribute).toString(); + QString file = attribs.value("", FilenameAttribute).toString(); + file = XmlReport::unquoteMessage(file); if (item.file.isEmpty()) item.file = file; item.files.push_back(file); From dd0182c99de8cd4ada108b665e7c122c549f712b Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 5 Feb 2011 18:33:45 +0200 Subject: [PATCH 09/21] GUI: Fix reading multiple error locations from XML. --- gui/xmlreportv2.cpp | 25 +++++++++++-------------- gui/xmlreportv2.h | 6 ------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/gui/xmlreportv2.cpp b/gui/xmlreportv2.cpp index 6088ea9a5..381d7d9c0 100644 --- a/gui/xmlreportv2.cpp +++ b/gui/xmlreportv2.cpp @@ -190,7 +190,9 @@ ErrorItem XmlReportV2::ReadError(QXmlStreamReader *reader) */ ErrorItem item; - if (reader->name().toString() == ErrorElementName) + + // Read error element from inside errors element + if (mXmlReader->name() == ErrorElementName) { QXmlStreamAttributes attribs = reader->attributes(); item.id = attribs.value("", IdAttribute).toString(); @@ -199,23 +201,17 @@ ErrorItem XmlReportV2::ReadError(QXmlStreamReader *reader) item.summary = XmlReport::unquoteMessage(summary); const QString message = attribs.value("", VerboseAttribute).toString(); item.message = XmlReport::unquoteMessage(message); - - ReadLocations(item); } - return item; -} -void XmlReportV2::ReadLocations(ErrorItem &item) -{ - QList errors; - bool allRead = false; - while (!allRead && !mXmlReader->atEnd()) + bool errorRead = false; + while (!errorRead && !mXmlReader->atEnd()) { switch (mXmlReader->readNext()) { case QXmlStreamReader::StartElement: - if (mXmlReader->name() != LocationElementName) - continue; // Skip other than location elements + + // Read location element from inside error element + if (mXmlReader->name() == LocationElementName) { QXmlStreamAttributes attribs = mXmlReader->attributes(); QString file = attribs.value("", FilenameAttribute).toString(); @@ -229,8 +225,8 @@ void XmlReportV2::ReadLocations(ErrorItem &item) break; case QXmlStreamReader::EndElement: - if (mXmlReader->name() == LocationElementName) - allRead = true; + if (mXmlReader->name() == ErrorElementName) + errorRead = true; break; // Not handled @@ -246,4 +242,5 @@ void XmlReportV2::ReadLocations(ErrorItem &item) break; } } + return item; } diff --git a/gui/xmlreportv2.h b/gui/xmlreportv2.h index d60b71126..6b1a2841c 100644 --- a/gui/xmlreportv2.h +++ b/gui/xmlreportv2.h @@ -81,12 +81,6 @@ protected: */ ErrorItem ReadError(QXmlStreamReader *reader); - /** - * @brief Read and parse error items location elements from XML stream. - * @param item ErrorItem to write the location data. - */ - void ReadLocations(ErrorItem &item); - private: /** * @brief XML stream reader for reading the report in XML format. From e8ebbf27012f7144340d440e9af9df5f756ff1e1 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 5 Feb 2011 18:38:17 +0200 Subject: [PATCH 10/21] GUI: Update translation files. --- gui/cppcheck_de.ts | 63 +++++++++++++++++++++++----------------------- gui/cppcheck_en.ts | 63 +++++++++++++++++++++++----------------------- gui/cppcheck_fi.ts | 63 +++++++++++++++++++++++----------------------- gui/cppcheck_ja.ts | 63 +++++++++++++++++++++++----------------------- gui/cppcheck_nl.ts | 63 +++++++++++++++++++++++----------------------- gui/cppcheck_pl.ts | 61 ++++++++++++++++++++++---------------------- gui/cppcheck_ru.ts | 61 ++++++++++++++++++++++---------------------- gui/cppcheck_se.ts | 63 +++++++++++++++++++++++----------------------- gui/cppcheck_sr.ts | 63 +++++++++++++++++++++++----------------------- 9 files changed, 286 insertions(+), 277 deletions(-) diff --git a/gui/cppcheck_de.ts b/gui/cppcheck_de.ts index 3c7b047a7..dbdcb3b0b 100644 --- a/gui/cppcheck_de.ts +++ b/gui/cppcheck_de.ts @@ -223,9 +223,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -563,8 +563,9 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - XML-Dateien (*.xml);;Textdateien (*.txt);;CSV-Dateien (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML-Dateien (*.xml);;Textdateien (*.txt);;CSV-Dateien (*.csv) @@ -573,7 +574,6 @@ kate -l(line) (file) - XML files (*.xml) XML-Dateien (*.xml) @@ -584,8 +584,8 @@ kate -l(line) (file) - - + + Project: @@ -602,22 +602,22 @@ Do you want to stop the checking and exit Cppcheck?. - + Text files (*.txt) Textdateien (*.txt) - + CSV files (*.csv) CSV-Dateien (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -633,39 +633,39 @@ Do you want to stop the checking and exit Cppcheck?. - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File - + Select Project Filename - + No project file loaded @@ -929,18 +929,18 @@ Please select the directory where file is located. ResultsView - - + + Cppcheck Cppcheck - + No errors found. Keine Fehler gefunden. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. Es wurden Fehler gefunden, aber sie sind so konfiguriert, ausgeblendet zu werden. @@ -948,28 +948,29 @@ Legen Sie unter dem Menü Ansicht fest, welche Art von Fehlern angezeigt werden - + + Failed to read the report. - + Summary - + Message - + No errors found, nothing to save. Keine Fehler gefunden, nichts zu speichern. - - + + Failed to save the report. Der Bericht konnte nicht speichern werden. diff --git a/gui/cppcheck_en.ts b/gui/cppcheck_en.ts index 9ee278852..e8823d1a7 100644 --- a/gui/cppcheck_en.ts +++ b/gui/cppcheck_en.ts @@ -225,9 +225,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -565,8 +565,9 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) @@ -575,7 +576,6 @@ kate -l(line) (file) - XML files (*.xml) XML files (*.xml) @@ -586,8 +586,8 @@ kate -l(line) (file) - - + + Project: @@ -604,22 +604,22 @@ Do you want to stop the checking and exit Cppcheck?. - + Text files (*.txt) Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -633,39 +633,39 @@ Do you want to stop the checking and exit Cppcheck?. %1 - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File - + Select Project Filename - + No project file loaded @@ -929,18 +929,18 @@ Please select the directory where file is located. ResultsView - - + + Cppcheck Cppcheck - + No errors found. No errors found. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. Errors were found, but they are configured to be hidden. @@ -948,28 +948,29 @@ To toggle what kind of errors are shown, open view menu. - + + Failed to read the report. - + Summary - + Message - + No errors found, nothing to save. No errors found, nothing to save. - - + + Failed to save the report. Failed to save the report. diff --git a/gui/cppcheck_fi.ts b/gui/cppcheck_fi.ts index 303d349e6..04e432f31 100644 --- a/gui/cppcheck_fi.ts +++ b/gui/cppcheck_fi.ts @@ -227,9 +227,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -567,8 +567,9 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - XML-tiedostot (*.xml);;Tekstitiedostot (*.txt);;CSV-tiedostot (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML-tiedostot (*.xml);;Tekstitiedostot (*.txt);;CSV-tiedostot (*.csv) @@ -577,7 +578,6 @@ kate -l(line) (file) - XML files (*.xml) XML-tiedostot (*xml) @@ -588,8 +588,8 @@ kate -l(line) (file) - - + + Project: @@ -606,22 +606,22 @@ Do you want to stop the checking and exit Cppcheck?. - + Text files (*.txt) Tekstitiedostot (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -637,39 +637,39 @@ Do you want to stop the checking and exit Cppcheck?. - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File - + Select Project Filename - + No project file loaded @@ -933,18 +933,18 @@ Please select the directory where file is located. ResultsView - - + + Cppcheck Cppcheck - + No errors found. Virheitä ei löytynyt. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. Virheitä löytyi, mutta asetuksissa kyseiset virheet on määritelty piilotettavaksi. @@ -952,28 +952,29 @@ Määrittääksesi minkä tyyppisiä virheitä näytetään, avaa näkymä valik - + + Failed to read the report. - + Summary - + Message - + No errors found, nothing to save. Virheitä ei löytynyt, ei mitään tallennettavaa. - - + + Failed to save the report. Raportin tallentaminen epäonnistui. diff --git a/gui/cppcheck_ja.ts b/gui/cppcheck_ja.ts index 222900f08..f893aaa1e 100644 --- a/gui/cppcheck_ja.ts +++ b/gui/cppcheck_ja.ts @@ -211,9 +211,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -546,14 +546,13 @@ kate -l(line) (file) - - + + Project: プロジェクト: - XML files (*.xml) XML ファイル (*.xml) @@ -583,8 +582,9 @@ Do you want to stop the checking and exit Cppcheck?. - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - XML ファイル (*.xml);;テキストファイル (*.txt);;CSV形式ファイル (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML ファイル (*.xml);;テキストファイル (*.txt);;CSV形式ファイル (*.csv) @@ -592,22 +592,22 @@ Do you want to stop the checking and exit Cppcheck?. レポートを保存 - + Text files (*.txt) テキストファイル (*.txt) - + CSV files (*.csv) CSV形式ファイル (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -620,39 +620,39 @@ Do you want to stop the checking and exit Cppcheck?. - - + + Cppcheck Help Cppcheck ヘルプ - + Failed to load help file (not found) ヘルプファイルが見つかりませんでした - + Failed to load help file ヘルプファイルの読み込みに失敗しました - - + + Project files (*.cppcheck);;All files(*.*) プロジェクトファイル (*.cppcheck);;All files(*.*) - + Select Project File プロジェクトファイルを選択 - + Select Project Filename プロジェクトファイル名を選択 - + No project file loaded プロジェクトファイルが読み込まれていません @@ -920,46 +920,47 @@ Please select the directory where file is located. 結果 - + No errors found, nothing to save. 警告/エラーが見つからなかったため、保存しません。 - - + + Failed to save the report. レポートの保存に失敗しました。 - - + + Cppcheck Cppcheck - + No errors found. 警告/エラーは見つかりませんでした。 - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. 警告/エラーが見つかりましたが、非表示設定になっています。 - + + Failed to read the report. レポートの読み込みに失敗. - + Summary 内容 - + Message メッセージ diff --git a/gui/cppcheck_nl.ts b/gui/cppcheck_nl.ts index a5ac7b33f..f2fe03251 100644 --- a/gui/cppcheck_nl.ts +++ b/gui/cppcheck_nl.ts @@ -225,9 +225,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -565,8 +565,9 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - XML bestanden (*.xml);;Tekst bestanden (*.txt);;CSV bestanden (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML bestanden (*.xml);;Tekst bestanden (*.txt);;CSV bestanden (*.csv) @@ -575,7 +576,6 @@ kate -l(line) (file) - XML files (*.xml) XML bestanden (*.xml) @@ -586,8 +586,8 @@ kate -l(line) (file) - - + + Project: @@ -604,22 +604,22 @@ Do you want to stop the checking and exit Cppcheck?. - + Text files (*.txt) Tekst bestanden (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -633,39 +633,39 @@ Do you want to stop the checking and exit Cppcheck?. %1 - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File - + Select Project Filename - + No project file loaded @@ -929,18 +929,18 @@ Please select the directory where file is located. ResultsView - - + + Cppcheck Cppcheck - + No errors found. Geen fouten gevonden. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. Fouten werden gevonden, maar volgens de configuratie zijn deze verborgen. @@ -948,28 +948,29 @@ Gebruik het uitzicht menu om te selecteren welke fouten getoond worden. - + + Failed to read the report. - + Summary - + Message - + No errors found, nothing to save. Geen fouten gevonden; geen data om op te slaan. - - + + Failed to save the report. Kon het rapport niet opslaan. diff --git a/gui/cppcheck_pl.ts b/gui/cppcheck_pl.ts index 79013cad9..080c41565 100644 --- a/gui/cppcheck_pl.ts +++ b/gui/cppcheck_pl.ts @@ -212,9 +212,9 @@ kate -l(line) (file) - - - + + + Cppcheck @@ -547,8 +547,8 @@ kate -l(line) (file) - - + + Project: @@ -569,7 +569,8 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) @@ -578,34 +579,33 @@ kate -l(line) (file) - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - + Select Project Filename - + No project file loaded - XML files (*.xml) @@ -617,22 +617,22 @@ Do you want to stop the checking and exit Cppcheck?. - + Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 - + Failed to change the language: %1 @@ -641,13 +641,13 @@ Do you want to stop the checking and exit Cppcheck?. - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File @@ -906,46 +906,47 @@ Please select the directory where file is located. ResultsView - - + + Cppcheck - + No errors found. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. - + + Failed to read the report. - + Summary - + Message - + No errors found, nothing to save. - - + + Failed to save the report. diff --git a/gui/cppcheck_ru.ts b/gui/cppcheck_ru.ts index 56e10c928..853864fd7 100644 --- a/gui/cppcheck_ru.ts +++ b/gui/cppcheck_ru.ts @@ -215,9 +215,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -555,7 +555,8 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) @@ -565,7 +566,6 @@ kate -l(line) (file) - XML files (*.xml) @@ -576,8 +576,8 @@ kate -l(line) (file) - - + + Project: @@ -594,22 +594,22 @@ Do you want to stop the checking and exit Cppcheck?. - + Text files (*.txt) Текстовые файлы (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -625,39 +625,39 @@ Do you want to stop the checking and exit Cppcheck?. - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File - + Select Project Filename - + No project file loaded @@ -919,46 +919,47 @@ Please select the directory where file is located. ResultsView - - + + Cppcheck Cppcheck - + No errors found. Ошибок не найдено. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. - + + Failed to read the report. - + Summary - + Message - + No errors found, nothing to save. - - + + Failed to save the report. diff --git a/gui/cppcheck_se.ts b/gui/cppcheck_se.ts index 624f1abc6..7db1ab57d 100644 --- a/gui/cppcheck_se.ts +++ b/gui/cppcheck_se.ts @@ -225,9 +225,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -566,8 +566,9 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - XML filer (*.xml);;Text filer (*.txt);;CSV filer (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML filer (*.xml);;Text filer (*.txt);;CSV filer (*.csv) @@ -576,7 +577,6 @@ kate -l(line) (file) - XML files (*.xml) XML filer (*.xml) @@ -587,8 +587,8 @@ kate -l(line) (file) - - + + Project: Projekt. @@ -607,22 +607,22 @@ Do you want to stop the checking and exit Cppcheck?. Vill du stoppa analysen och avsluta Cppcheck? - + Text files (*.txt) Text filer (*.txt) - + CSV files (*.csv) CSV filer (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -638,39 +638,39 @@ Vill du stoppa analysen och avsluta Cppcheck? - - + + Cppcheck Help Cppcheck Hjälp - + Failed to load help file (not found) Misslyckades att öppna hjälpfilen (hittades ej) - + Failed to load help file Misslykades att öppna hjälpfilen - - + + Project files (*.cppcheck);;All files(*.*) Projektfiler (*.cppcheck);;Alla filer(*.*) - + Select Project File Välj projektfil - + Select Project Filename Välj Projektfil - + No project file loaded Inget projekt laddat @@ -936,18 +936,18 @@ Välj mappen där filen finns. ResultsView - - + + Cppcheck Cppcheck - + No errors found. Inga fel hittades. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. Fel hittades, men de visas ej. @@ -955,28 +955,29 @@ För att ställa in vilka fel som skall visas använd visa menyn. - + + Failed to read the report. Misslyckades att läsa rapporten. - + Summary Sammanfattning - + Message Meddelande - + No errors found, nothing to save. Inga fel hittades, ingenting att spara. - - + + Failed to save the report. Misslyckades med att spara rapporten. diff --git a/gui/cppcheck_sr.ts b/gui/cppcheck_sr.ts index 8710dd855..67ccc5a4b 100644 --- a/gui/cppcheck_sr.ts +++ b/gui/cppcheck_sr.ts @@ -225,9 +225,9 @@ kate -l(line) (file) - - - + + + Cppcheck Cppcheck @@ -565,8 +565,9 @@ kate -l(line) (file) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) @@ -575,7 +576,6 @@ kate -l(line) (file) - XML files (*.xml) XML files (*.xml) @@ -586,8 +586,8 @@ kate -l(line) (file) - - + + Project: @@ -604,22 +604,22 @@ Do you want to stop the checking and exit Cppcheck?. - + Text files (*.txt) Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -633,39 +633,39 @@ Do you want to stop the checking and exit Cppcheck?. %1 - - + + Cppcheck Help - + Failed to load help file (not found) - + Failed to load help file - - + + Project files (*.cppcheck);;All files(*.*) - + Select Project File - + Select Project Filename - + No project file loaded @@ -929,18 +929,18 @@ Please select the directory where file is located. ResultsView - - + + Cppcheck Cppcheck - + No errors found. No errors found. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. Errors were found, but they are configured to be hidden. @@ -948,28 +948,29 @@ To toggle what kind of errors are shown, open view menu. - + + Failed to read the report. - + Summary - + Message - + No errors found, nothing to save. No errors found, nothing to save. - - + + Failed to save the report. Failed to save the report. From 2fa21575433388e59d197ae22ab08a73b58c32ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 5 Feb 2011 20:15:22 +0100 Subject: [PATCH 11/21] Cppcheck: Added short info about --rule and --rule-file to --help output --- cli/cmdlineparser.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 39c6eb916..3f1467475 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -610,8 +610,9 @@ void CmdLineParser::PrintHelp() " cppcheck [--append=file] [-D] [--enable=] [--error-exitcode=[n]]\n" " [--exitcode-suppressions file] [--file-list=file.txt] [--force]\n" " [--help] [-Idir] [--inline-suppr] [-j [jobs]] [--quiet]\n" - " [--report-progress] [--style] [--suppressions-list=file.txt]\n" - " [--verbose] [--version] [--xml] [file or path1] [file or path]\n" + " [--report-progress] [--rule=] [--rule-file=]\n" + " [--style] [--suppressions-list=file.txt] [--verbose]\n" + " [--version] [--xml] [file or path1] [file or path]\n" "\n" "If path is given instead of filename, *.cpp, *.cxx, *.cc, *.c++ and *.c files\n" "are checked recursively from given directory.\n\n" @@ -655,6 +656,8 @@ void CmdLineParser::PrintHelp() " -j [jobs] Start [jobs] threads to do the checking simultaneously.\n" " -q, --quiet Only print error messages\n" " --report-progress Report progress messages while checking a file.\n" + " --rule= match regular expression\n" + " --rule-file= use given rule file\n" " -s, --style deprecated, use --enable=style\n" " --suppressions-list=file\n" " Suppress warnings listed in the file. Filename and line\n" From 35066c898ac99e75fcff71f4c207983230561210 Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Sat, 5 Feb 2011 22:31:31 +0200 Subject: [PATCH 12/21] Update man page --- man/cppcheck.1.xml | 66 ++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/man/cppcheck.1.xml b/man/cppcheck.1.xml index 7c86354cd..2159a80ab 100644 --- a/man/cppcheck.1.xml +++ b/man/cppcheck.1.xml @@ -102,28 +102,30 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ &dhpackage; - - - - + + + + - - + + - - + + - + + + - - + + - + @@ -146,20 +148,20 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ variablelist.term.break.after parameters to control the term elements. --> - + This allows you to provide information about functions by providing an implementation for these. - + By default Cppcheck checks all configurations. Use -D to limit the checking. When -D is used the checking is limited to the given configuration. Example: -DDEBUG=1 -D__cplusplus - + Enable additional checks. The available ids are: @@ -199,9 +201,9 @@ Example: -DDEBUG=1 -D__cplusplus - + - If errors are found, integer [n] is returned instead of default 0. + If errors are found, integer <n> is returned instead of default 0. EXIT_FAILURE is returned if arguments are not valid or if no input files are provided. Note that your operating system can modify this value, e.g. 256 can become 0. @@ -214,13 +216,13 @@ Example: -DDEBUG=1 -D__cplusplus - + Used when certain messages should be displayed but should not cause a non-zero exitcode. - + Specify the files to check in a text file. One filename per line. @@ -241,7 +243,7 @@ default. - + Give include path. Give several -I parameters to give several paths. First given path is checked first. If paths are relative to source files, this is not needed. @@ -249,7 +251,7 @@ files, this is not needed. - + Give path to ignore. Give several -i parameters to ignore several paths. Give directory name or filename with path as parameter. Directory name is matched to all parts of the path. @@ -264,9 +266,9 @@ Directory name is matched to all parts of the path. - + - Start [jobs] threads to do the checking work. + Start <jobs> threads to do the checking work. @@ -282,6 +284,18 @@ Directory name is matched to all parts of the path. Report progress when checking a file. + + + + Match regular expression. + + + + + + Use given rule file. + + @@ -290,14 +304,14 @@ Directory name is matched to all parts of the path. - + Suppress warnings listed in the file. Filename and line are optional. The format of the single line in file is: [error id]:[filename]:[line]. You can use --template or --xml to see the error id. - + Format the error messages. E.g. '{file}:{line},{severity},{id},{message}' or '{file}({line}):({severity}) {message}'. Pre-defined templates: gcc, vs @@ -322,7 +336,7 @@ Directory name is matched to all parts of the path. - + Select the XML file version. Currently versions 1 and 2 are available. The default version is 1. From bc5abd063fbf528acda885ae815b7f1b8d23370b Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Sat, 5 Feb 2011 22:50:25 +0200 Subject: [PATCH 13/21] Update man page to contain more info about --rule options. --- man/cppcheck.1.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man/cppcheck.1.xml b/man/cppcheck.1.xml index 2159a80ab..3344d02b3 100644 --- a/man/cppcheck.1.xml +++ b/man/cppcheck.1.xml @@ -287,13 +287,13 @@ Directory name is matched to all parts of the path. - Match regular expression. + Match regular expression to create your own checks. E.g. rule "/ 0" can be used to check division by zero. - Use given rule file. + Use given rule XML file. See https://sourceforge.net/projects/cppcheck/files/Articles/ for more info about the syntax. From 2bded1091b9c66f095e729bb797bd0eebeafa194 Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Sat, 5 Feb 2011 22:59:26 +0200 Subject: [PATCH 14/21] Improve --help listing by removing duplicate options list and using lt and gt characters for option arguments. --- cli/cmdlineparser.cpp | 50 ++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 3f1467475..0b5da1128 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -607,71 +607,67 @@ void CmdLineParser::PrintHelp() std::cout << "Cppcheck - A tool for static C/C++ code analysis\n" "\n" "Syntax:\n" - " cppcheck [--append=file] [-D] [--enable=] [--error-exitcode=[n]]\n" - " [--exitcode-suppressions file] [--file-list=file.txt] [--force]\n" - " [--help] [-Idir] [--inline-suppr] [-j [jobs]] [--quiet]\n" - " [--report-progress] [--rule=] [--rule-file=]\n" - " [--style] [--suppressions-list=file.txt] [--verbose]\n" - " [--version] [--xml] [file or path1] [file or path]\n" + " cppcheck [OPTIONS] [files or paths]\n" "\n" "If path is given instead of filename, *.cpp, *.cxx, *.cc, *.c++ and *.c files\n" "are checked recursively from given directory.\n\n" "Options:\n" - " --append=file This allows you to provide information about\n" + " --append= This allows you to provide information about\n" " functions by providing an implementation for these.\n" " -D By default Cppcheck checks all configurations.\n" " Use -D to limit the checking. When -D is used the\n" " checking is limited to the given configuration.\n" " Example: -DDEBUG=1 -D__cplusplus\n" - " --enable=id Enable additional checks. The available ids are:\n" + " --enable= Enable additional checks. The available ids are:\n" " * all - enable all checks\n" " * style - Check coding style\n" " * information - Enable information messages\n" " * unusedFunction - check for unused functions\n" " * missingInclude - check for missing includes\n" - " Several ids can be given if you separate them with commas\n" - " --error-exitcode=[n] If errors are found, integer [n] is returned instead\n" + " Several ids can be given if you separate them with commas.\n" + " --error-exitcode= If errors are found, integer [n] is returned instead\n" " of default 0. EXIT_FAILURE is returned\n" " if arguments are not valid or if no input files are\n" " provided. Note that your operating system can\n" " modify this value, e.g. 256 can become 0.\n" " --errorlist Print a list of all error messages in XML format.\n" - " --exitcode-suppressions=file\n" + " --exitcode-suppressions=\n" " Used when certain messages should be displayed but\n" " should not cause a non-zero exitcode.\n" - " --file-list=file Specify the files to check in a text file. One Filename per line.\n" + " --file-list= Specify the files to check in a text file. One Filename per line.\n" " -f, --force Force checking on files that have \"too many\"\n" - " configurations\n" - " -h, --help Print this help\n" - " -I [dir] Give include path. Give several -I parameters to give\n" + " configurations.\n" + " -h, --help Print this help.\n" + " -I Give include path. Give several -I parameters to give\n" " several paths. First given path is checked first. If\n" - " paths are relative to source files, this is not needed\n" - " -i [dir] Give path to ignore. Give several -i parameters to ignore\n" + " paths are relative to source files, this is not needed.\n" + " -i Give path to ignore. Give several -i parameters to ignore\n" " several paths. Give directory name or filename with path\n" " as parameter. Directory name is matched to all parts of the\n" " path.\n" " --inline-suppr Enable inline suppressions. Use them by placing one or\n" " more comments, like: // cppcheck-suppress warningId\n" " on the lines before the warning to suppress.\n" - " -j [jobs] Start [jobs] threads to do the checking simultaneously.\n" - " -q, --quiet Only print error messages\n" + " -j Start [jobs] threads to do the checking simultaneously.\n" + " -q, --quiet Only print error messages.\n" " --report-progress Report progress messages while checking a file.\n" - " --rule= match regular expression\n" - " --rule-file= use given rule file\n" - " -s, --style deprecated, use --enable=style\n" - " --suppressions-list=file\n" + " --rule= Match regular expression.\n" + " --rule-file= Use given rule file. For more information, see: \n" + " https://sourceforge.net/projects/cppcheck/files/Articles/\n" + " -s, --style Deprecated, use --enable=style\n" + " --suppressions-list=\n" " Suppress warnings listed in the file. Filename and line\n" " are optional in the suppression file. The format of the\n" " single line in the suppression file is:\n" " [error id]:[filename]:[line]\n" - " --template '[text]' Format the error messages. E.g.\n" + " --template '' Format the error messages. E.g.\n" " '{file}:{line},{severity},{id},{message}' or\n" " '{file}({line}):({severity}) {message}'\n" " Pre-defined templates: gcc, vs\n" - " -v, --verbose More detailed error reports\n" - " --version Print out version number\n" + " -v, --verbose More detailed error reports.\n" + " --version Print out version number.\n" " --xml Write results in xml to error stream.\n" - " --xml-version=[version]\n" + " --xml-version=\n" " Select the XML file version. Currently versions 1 and 2\n" " are available. The default version is 1." "\n" From 1e5743ff1ecaf396a349a70bb3d9748b2ffe4c5f Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 5 Feb 2011 23:40:50 +0200 Subject: [PATCH 15/21] GUI: Add French translation to project file. --- gui/gui.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/gui/gui.pro b/gui/gui.pro index 25f3a73a2..26428b4ed 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -35,6 +35,7 @@ FORMS = main.ui \ stats.ui TRANSLATIONS = cppcheck_fi.ts \ + cppcheck_fr.ts \ cppcheck_nl.ts \ cppcheck_en.ts \ cppcheck_se.ts \ From 6e11c03d860b6380d0ed742c6b4d506235608492 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 5 Feb 2011 23:42:24 +0200 Subject: [PATCH 16/21] Installer: Add French translation to installer. --- win_installer/cppcheck.wxs | 1 + 1 file changed, 1 insertion(+) diff --git a/win_installer/cppcheck.wxs b/win_installer/cppcheck.wxs index de310aaae..1b7e438a1 100755 --- a/win_installer/cppcheck.wxs +++ b/win_installer/cppcheck.wxs @@ -43,6 +43,7 @@ + From f33efc7fa566aafe8c553f39e569a58d0528e7c0 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 5 Feb 2011 23:43:06 +0200 Subject: [PATCH 17/21] Installer: Update CLI build directory. --- win_installer/config.wxi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win_installer/config.wxi b/win_installer/config.wxi index 47c568ef5..c3f1934f5 100644 --- a/win_installer/config.wxi +++ b/win_installer/config.wxi @@ -4,7 +4,7 @@ - + From b62d034eae9e8d2650952c66dc00b4f2f5cc079f Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 5 Feb 2011 23:43:38 +0200 Subject: [PATCH 18/21] GUI: Update translation files. --- gui/cppcheck_de.ts | 10 + gui/cppcheck_en.ts | 10 + gui/cppcheck_fi.ts | 10 + gui/cppcheck_fr.ts | 642 ++++++++++++++++++++++++++++++++++++++++----- gui/cppcheck_ja.ts | 10 + gui/cppcheck_nl.ts | 10 + gui/cppcheck_pl.ts | 10 + gui/cppcheck_ru.ts | 10 + gui/cppcheck_se.ts | 10 + gui/cppcheck_sr.ts | 10 + 10 files changed, 661 insertions(+), 71 deletions(-) diff --git a/gui/cppcheck_de.ts b/gui/cppcheck_de.ts index dbdcb3b0b..99899b8ae 100644 --- a/gui/cppcheck_de.ts +++ b/gui/cppcheck_de.ts @@ -601,6 +601,16 @@ kate -l(line) (file) Do you want to stop the checking and exit Cppcheck?. + + + XML files version 1 (*.xml) + + + + + XML files version 2 (*.xml) + + Text files (*.txt) diff --git a/gui/cppcheck_en.ts b/gui/cppcheck_en.ts index e8823d1a7..4621571d1 100644 --- a/gui/cppcheck_en.ts +++ b/gui/cppcheck_en.ts @@ -603,6 +603,16 @@ kate -l(line) (file) Do you want to stop the checking and exit Cppcheck?. + + + XML files version 1 (*.xml) + + + + + XML files version 2 (*.xml) + + Text files (*.txt) diff --git a/gui/cppcheck_fi.ts b/gui/cppcheck_fi.ts index 04e432f31..f336f63c2 100644 --- a/gui/cppcheck_fi.ts +++ b/gui/cppcheck_fi.ts @@ -605,6 +605,16 @@ kate -l(line) (file) Do you want to stop the checking and exit Cppcheck?. + + + XML files version 1 (*.xml) + + + + + XML files version 2 (*.xml) + + Text files (*.txt) diff --git a/gui/cppcheck_fr.ts b/gui/cppcheck_fr.ts index 223830438..bd9e29e7e 100644 --- a/gui/cppcheck_fr.ts +++ b/gui/cppcheck_fr.ts @@ -15,10 +15,6 @@ Cppcheck - A tool for static C/C++ code analysis. Cppcheck - Un outil d'analyse statique de code C/C++. - - Copyright (C) 2007-2010 Daniel Marjamäki and cppcheck team. - Copyright (C) 2007-2010 Daniel Marjamäki et cppcheck team. - This program is licensed under the terms of the GNU General Public License version 3 @@ -29,6 +25,10 @@ General Public License version 3 Visit Cppcheck homepage at %1 Visitez le site Cppcheck : %1 + + Copyright © 2007-2010 Daniel Marjamäki and cppcheck team. + + ApplicationDialog @@ -61,14 +61,6 @@ Les textes suivants sont remplacés avec les valeurs appropriées lorsque l&apos Example : ouvrir un fichier avec kate et position l'affichage sur la bonne ligne: kate -l(ligne) (fichier) - - Application's name - Nom de l'application - - - Application to execute - Application à exécuter - Browse Parcourir @@ -89,6 +81,14 @@ kate -l(ligne) (fichier) You must specify a name and a path for the application! Vous devez spécifier un nom et un chemin d'accès pour l'application ! + + Application's name: + + + + Command to execute: + + FileViewDialog @@ -106,10 +106,69 @@ kate -l(ligne) (fichier) - Fileview + HelpWindow - Fileview - Visualisateur de fichier + Cppcheck Help + + + + Go back + + + + Back + + + + Go forward + + + + Forward + + + + Start + + + + Home + + + + + LogView + + Checking Log + + + + &Save + + + + Clear + + + + Close + + + + Save Log + + + + Text files (*.txt *.log);;All files (*.*) + + + + Cppcheck + + + + Could not open file for writing: "%1" + @@ -126,10 +185,6 @@ kate -l(ligne) (fichier) &View &Affichage - - &Language - &Langue - &Help &Aide @@ -210,26 +265,6 @@ kate -l(ligne) (fichier) &Preferences &Préférences - - Show possible false positives - Afficher les possibles faux positifs - - - Show security errors - Afficher les erreurs de sécurité - - - Show style errors - Afficher les erreurs de style - - - Show possible style errors - Afficher les erreurs possibles de style - - - Show common errors - Afficher les erreurs - &Check all Tout &cocher @@ -246,10 +281,6 @@ kate -l(ligne) (fichier) &Expand all Tout &afficher - - &Toolbar - &Barre d'outil - &Contents &Contenu @@ -274,14 +305,6 @@ kate -l(ligne) (fichier) Select directory to check Sélectionner le répertoire à vérifier - - Cannot exit while checking. - -Stop the checking before exiting. - Ne peut pas quitter pendant une vérification. - -Arrêter la vérification avant de quitter. - License Licence @@ -290,10 +313,6 @@ Arrêter la vérification avant de quitter. Authors Auteur - - XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - Fichier XML (*.xml);;Fichier Texte (*.txt);;Fichier CSV (*.csv) - Save the report file Sauvegarder le rapport @@ -354,6 +373,253 @@ Arrêter la vérification avant de quitter. Polish Polonais + + &Toolbars + + + + Categories + + + + Check files + + + + Check directory + + + + Stop checking + + + + Style warnings + + + + Show style warnings + + + + Errors + + + + Show errors + + + + &Standard + + + + Standard items + + + + Toolbar + + + + &Categories + + + + Error categories + + + + &Open XML... + + + + Open P&roject File... + + + + &New Project File... + + + + &Log View + + + + Log View + + + + C&lose Project File + + + + &Edit Project File... + + + + &Statistics + + + + Warnings + + + + Show warnings + + + + Performance warnings + + + + Show performance warnings + + + + Show &hidden + + + + Information + + + + Show information messages + + + + Portability + + + + Show portability warnings + + + + You must close the project file before selecting new files or directories! + + + + Project: + + + + Open the report file + + + + Checking is running. + +Do you want to stop the checking and exit Cppcheck?. + + + + XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv) + + + + XML files version 1 (*.xml) + + + + XML files version 2 (*.xml) + + + + Cppcheck Help + + + + Failed to load help file (not found) + + + + Failed to load help file + + + + Project files (*.cppcheck);;All files(*.*) + + + + Select Project File + + + + Select Project Filename + + + + No project file loaded + + + + Japanese + + + + Serbian + + + + + Project + + Cppcheck + + + + Could not read the project file. + + + + Could not write the project file. + + + + + ProjectFile + + Project File + + + + Project: + + + + Paths: + + + + Browse... + + + + Include paths: + + + + Defines: + + + + + ProjectFileDialog + + Project file: %1 + + + + Select include directory + + + + Select directory to check + Sélectionner le répertoire à vérifier + QObject @@ -384,10 +650,6 @@ Arrêter la vérification avant de quitter. Line Ligne - - Message - Message - Undefined file Fichier indéterminé @@ -420,22 +682,52 @@ Please check the application path and parameters are correct. Merci de vérifier que le chemin de l'application et que les paramètres sont corrects. - - possible error - erreur possible - style erreur de style - - possible style - erreur de style possible - error erreur + + Summary + + + + Hide + + + + Could not find the file! + + + + Could not find file: +%1 +Please select the directory where file is located. + + + + Select Directory + + + + warning + + + + performance + + + + portability + + + + information + + ResultsView @@ -465,6 +757,18 @@ Pour configurer les erreurs affichées, ouvrez le menu d'affichage.Failed to save the report. Erreur lors de la sauvegarde du rapport. + + Failed to read the report. + + + + Summary + + + + Message + Message + Settings @@ -480,10 +784,6 @@ Pour configurer les erreurs affichées, ouvrez le menu d'affichage.Number of threads: Nombre de processus : - - Check all #ifdef configurations - Vérifier toutes les configurations #ifdef - Show full path of files Montrer le chemin complet des fichiers @@ -524,6 +824,38 @@ Pour configurer les erreurs affichées, ouvrez le menu d'affichage.Save full path to files in reports Sauvegarder le chemin complet des fichiers dans les rapports + + Include paths: + + + + Add... + + + + Ideal count: + + + + TextLabel + + + + Force checking all #ifdef configurations + + + + Show internal warnings in log + + + + Enable inline suppressions + + + + Language + + SettingsDialog @@ -535,5 +867,173 @@ Pour configurer les erreurs affichées, ouvrez le menu d'affichage.Modify an application Modifier une application + + N/A + + + + Select include directory + + + + + StatsDialog + + Statistics + + + + Project + + + + Project: + + + + Paths: + + + + Include paths: + + + + Defines: + + + + Previous Scan + + + + Path Selected: + + + + Number of Files Scanned: + + + + Scan Duration: + + + + Errors: + + + + Warnings: + + + + Stylistic warnings: + + + + Portability warnings: + + + + TextLabel + + + + Performance issues: + + + + Information messages: + + + + Copy to Clipboard + + + + 1 day + + + + %1 days + + + + 1 hour + + + + %1 hours + + + + 1 minute + + + + %1 minutes + + + + 1 second + + + + %1 seconds + + + + 0.%1 seconds + + + + and + + + + Project Settings + Project: %1 + Paths: %2 + Include paths: %3 + Defines: %4 +Previous Scan + Path selected: %5 + Number of files scanned: %6 + Scan duration: %7 +Statistics + Errors: %8 + Warnings: %9 + Style warnings: %10 + Portability warnings: %11 + Performance warnings: %12 + Information messages: %13 + + + + + <h3>Project Settings<h3> +<table> + <tr><th>Project:</th><td>%1</td></tr> + <tr><th>Paths:</th><td>%2</td></tr> + <tr><th>Include paths:</th><td>%3</td></tr> + <tr><th>Defines:</th><td>%4</td></tr> +</table> +<h3>Previous Scan</h3> +<table> + <tr><th>Path selected:</th><td>%5</td></tr> + <tr><th>Number of files scanned:</th><td>%6</td></tr> + <tr><th>Scan duration:</th><td>%7</td></tr> +</table> +<h3>Statistics</h3> + <tr><th>Errors:</th><td>%8</td></tr> + <tr><th>Warnings:</th><td>%9</td></tr> + <tr><th>Style warnings:</th><td>%10</td></tr> + <tr><th>Portability warnings:</th><td>%11</td></tr> + <tr><th>Performance warnings:</th><td>%12</td></tr> + <tr><th>Information messages:</th><td>%13</td></tr> +</table> + + + diff --git a/gui/cppcheck_ja.ts b/gui/cppcheck_ja.ts index f893aaa1e..12d8c80ca 100644 --- a/gui/cppcheck_ja.ts +++ b/gui/cppcheck_ja.ts @@ -591,6 +591,16 @@ Do you want to stop the checking and exit Cppcheck?. Save the report file レポートを保存 + + + XML files version 1 (*.xml) + + + + + XML files version 2 (*.xml) + + Text files (*.txt) diff --git a/gui/cppcheck_nl.ts b/gui/cppcheck_nl.ts index f2fe03251..e34529164 100644 --- a/gui/cppcheck_nl.ts +++ b/gui/cppcheck_nl.ts @@ -603,6 +603,16 @@ kate -l(line) (file) Do you want to stop the checking and exit Cppcheck?. + + + XML files version 1 (*.xml) + + + + + XML files version 2 (*.xml) + + Text files (*.txt) diff --git a/gui/cppcheck_pl.ts b/gui/cppcheck_pl.ts index 080c41565..f80b37956 100644 --- a/gui/cppcheck_pl.ts +++ b/gui/cppcheck_pl.ts @@ -578,6 +578,16 @@ kate -l(line) (file) Save the report file + + + XML files version 1 (*.xml) + + + + + XML files version 2 (*.xml) + + diff --git a/gui/cppcheck_ru.ts b/gui/cppcheck_ru.ts index 853864fd7..9bc1aecb2 100644 --- a/gui/cppcheck_ru.ts +++ b/gui/cppcheck_ru.ts @@ -593,6 +593,16 @@ kate -l(line) (file) Do you want to stop the checking and exit Cppcheck?. + + + XML files version 1 (*.xml) + + + + + XML files version 2 (*.xml) + + Text files (*.txt) diff --git a/gui/cppcheck_se.ts b/gui/cppcheck_se.ts index 7db1ab57d..593a59fa7 100644 --- a/gui/cppcheck_se.ts +++ b/gui/cppcheck_se.ts @@ -606,6 +606,16 @@ 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) diff --git a/gui/cppcheck_sr.ts b/gui/cppcheck_sr.ts index 67ccc5a4b..91eb79c7a 100644 --- a/gui/cppcheck_sr.ts +++ b/gui/cppcheck_sr.ts @@ -603,6 +603,16 @@ kate -l(line) (file) Do you want to stop the checking and exit Cppcheck?. + + + XML files version 1 (*.xml) + + + + + XML files version 2 (*.xml) + + Text files (*.txt) From 2214de7bbc37d149ae0e5dbbea0aef58b50e1481 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 5 Feb 2011 23:44:54 +0200 Subject: [PATCH 19/21] Add .obj files to gitignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e62fe2dbf..2a43f4cd9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ tools/dmake dmake tools/errmsg # VS generated files +*.obj *.ncb *.suo *.user From f7dcf2d3b927724806a96a49ad9759bfc69e5a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 6 Feb 2011 09:58:07 +0100 Subject: [PATCH 20/21] Tokenizer: Added a comment about sizeof for struct/class. We always assume that the size is 100 --- lib/tokenize.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 1ca735e53..b74eb6793 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3808,6 +3808,8 @@ void Tokenizer::simplifySizeof() { if (Token::Match(tok, "class|struct %var%")) { + // we assume that the size of structs and classes are always + // 100 bytes. _typeSize[tok->strAt(1)] = 100; } } From 2506c7db5cac7a04a143ca2f0d8fecbe0d9c22ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 6 Feb 2011 10:04:28 +0100 Subject: [PATCH 21/21] Removed the 'verify' folder --- verify/codeeditor.cpp | 138 ---------------------------------- verify/codeeditor.h | 63 ---------------- verify/cppcheck-verify.pro | 29 -------- verify/main.cpp | 28 ------- verify/mainwindow.cpp | 148 ------------------------------------- verify/mainwindow.h | 43 ----------- verify/mainwindow.ui | 75 ------------------- verify/readme.txt | 11 --- 8 files changed, 535 deletions(-) delete mode 100644 verify/codeeditor.cpp delete mode 100644 verify/codeeditor.h delete mode 100644 verify/cppcheck-verify.pro delete mode 100644 verify/main.cpp delete mode 100644 verify/mainwindow.cpp delete mode 100644 verify/mainwindow.h delete mode 100644 verify/mainwindow.ui delete mode 100644 verify/readme.txt diff --git a/verify/codeeditor.cpp b/verify/codeeditor.cpp deleted file mode 100644 index 5692172ca..000000000 --- a/verify/codeeditor.cpp +++ /dev/null @@ -1,138 +0,0 @@ -#include "codeeditor.h" -#include -#include - - -CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) -{ - lineNumberArea = new LineNumberArea(this); - - connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); - connect(this, SIGNAL(updateRequest(const QRect &, int)), this, SLOT(updateLineNumberArea(const QRect &, int))); - //connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); - - updateLineNumberAreaWidth(0); - //highlightCurrentLine(); -} - - - -int CodeEditor::lineNumberAreaWidth() -{ - int digits = 1; - int max = qMax(1, blockCount()); - while (max >= 10) - { - max /= 10; - ++digits; - } - - int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits; - - return space; -} - - - -void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */) -{ - setViewportMargins(lineNumberAreaWidth(), 0, 0, 0); -} - - - -void CodeEditor::updateLineNumberArea(const QRect &rect, int dy) -{ - if (dy) - lineNumberArea->scroll(0, dy); - else - lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height()); - - if (rect.contains(viewport()->rect())) - updateLineNumberAreaWidth(0); -} - - - -void CodeEditor::resizeEvent(QResizeEvent *e) -{ - QPlainTextEdit::resizeEvent(e); - - QRect cr = contentsRect(); - lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height())); -} - - -/* -void CodeEditor::highlightCurrentLine() -{ - QList extraSelections; - - if (!isReadOnly()) - { - QTextEdit::ExtraSelection selection; - - QColor lineColor = QColor(Qt::yellow).lighter(160); - - selection.format.setBackground(lineColor); - selection.format.setProperty(QTextFormat::FullWidthSelection, true); - selection.cursor = textCursor(); - selection.cursor.clearSelection(); - extraSelections.append(selection); - } - - setExtraSelections(extraSelections); -} -*/ - -void CodeEditor::highlightErrors(const QList &errorLines) -{ - QList extraSelections; - - for (int i = 0; i < errorLines.size(); ++i) - { - QTextEdit::ExtraSelection selection; - - QColor lineColor = QColor(Qt::red).lighter(160); - - selection.format.setBackground(lineColor); - selection.format.setProperty(QTextFormat::FullWidthSelection, true); - selection.cursor = textCursor(); - selection.cursor.clearSelection(); - selection.cursor.movePosition(QTextCursor::Start); - selection.cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, errorLines[i] - 1); - extraSelections.append(selection); - } - - setExtraSelections(extraSelections); - -} - - -void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) -{ - QPainter painter(lineNumberArea); - painter.fillRect(event->rect(), Qt::lightGray); - - - QTextBlock block = firstVisibleBlock(); - int blockNumber = block.blockNumber(); - int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top(); - int bottom = top + (int) blockBoundingRect(block).height(); - - while (block.isValid() && top <= event->rect().bottom()) - { - if (block.isVisible() && bottom >= event->rect().top()) - { - QString number = QString::number(blockNumber + 1); - painter.setPen(Qt::black); - painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(), - Qt::AlignRight, number); - } - - block = block.next(); - top = bottom; - bottom = top + (int) blockBoundingRect(block).height(); - ++blockNumber; - } -} diff --git a/verify/codeeditor.h b/verify/codeeditor.h deleted file mode 100644 index be5b25511..000000000 --- a/verify/codeeditor.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef CODEEDITOR_H -#define CODEEDITOR_H - -#include -#include -#include - -class QPaintEvent; -class QResizeEvent; -class QSize; -class QWidget; - -class LineNumberArea; - - -class CodeEditor : public QPlainTextEdit -{ - Q_OBJECT - -public: - CodeEditor(QWidget *parent = 0); - - void lineNumberAreaPaintEvent(QPaintEvent *event); - int lineNumberAreaWidth(); - - void highlightErrors(const QList &errorLines); - -protected: - void resizeEvent(QResizeEvent *event); - -private slots: - void updateLineNumberAreaWidth(int newBlockCount); - //void highlightCurrentLine(); - void updateLineNumberArea(const QRect &, int); - -private: - QWidget *lineNumberArea; -}; - - -class LineNumberArea : public QWidget -{ -public: - LineNumberArea(CodeEditor *editor) : QWidget(editor) - { - codeEditor = editor; - } - - QSize sizeHint() const - { - return QSize(codeEditor->lineNumberAreaWidth(), 0); - } - -protected: - void paintEvent(QPaintEvent *event) - { - codeEditor->lineNumberAreaPaintEvent(event); - } - -private: - CodeEditor *codeEditor; -}; -#endif // CODEEDITOR_H diff --git a/verify/cppcheck-verify.pro b/verify/cppcheck-verify.pro deleted file mode 100644 index 15373457b..000000000 --- a/verify/cppcheck-verify.pro +++ /dev/null @@ -1,29 +0,0 @@ -TARGET = cppcheck-verify -TEMPLATE = app -INCLUDEPATH += ../lib -SOURCES += main.cpp \ - mainwindow.cpp \ - ../lib/tokenize.cpp \ - ../lib/token.cpp \ - ../lib/settings.cpp \ - ../lib/preprocessor.cpp \ - ../lib/path.cpp \ - ../lib/mathlib.cpp \ - ../lib/filelister_win32.cpp \ - ../lib/filelister_unix.cpp \ - ../lib/filelister.cpp \ - ../lib/errorlogger.cpp \ - codeeditor.cpp -HEADERS += mainwindow.h \ - ../lib/tokenize.h \ - ../lib/token.h \ - ../lib/settings.h \ - ../lib/preprocessor.h \ - ../lib/path.h \ - ../lib/mathlib.h \ - ../lib/filelister_win32.h \ - ../lib/filelister_unix.h \ - ../lib/filelister.h \ - ../lib/errorlogger.h \ - codeeditor.h -FORMS += mainwindow.ui diff --git a/verify/main.cpp b/verify/main.cpp deleted file mode 100644 index 16ea79c93..000000000 --- a/verify/main.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2010 Daniel Marjamäki and Cppcheck team. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/verify/mainwindow.cpp b/verify/mainwindow.cpp deleted file mode 100644 index 77e0d49d1..000000000 --- a/verify/mainwindow.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2010 Daniel Marjamäki and Cppcheck team. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "mainwindow.h" -#include "ui_mainwindow.h" - -#include "preprocessor.h" -#include "tokenize.h" - -#include -#include -#include -#include -#include - -#include - -static void arrayIndex(const Tokenizer &tokenizer, std::set &errorlines); - -static unsigned char readChar(std::istream &istr) -{ - unsigned char ch = (unsigned char)istr.get(); - - // Handling of newlines.. - if (ch == '\r') - { - ch = '\n'; - if ((char)istr.peek() == '\n') - (void)istr.get(); - } - - return ch; -} - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent), ui(new Ui::MainWindow) -{ - ui->setupUi(this); - connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open())); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::open() -{ - const std::string fileName = QFileDialog::getOpenFileName(this, - tr("Open File"), - "", - "cpp files (*.cpp)").toStdString(); - if (fileName.empty()) - return; - - setWindowTitle(fileName.c_str()); - - Tokenizer tokenizer; - - { - // Preprocess the file.. - Preprocessor preprocessor; - std::ifstream fin(fileName.c_str()); - std::string filedata; - std::list configurations; - std::list includePaths; - preprocessor.preprocess(fin, - filedata, - configurations, - fileName, - includePaths); - filedata = Preprocessor::getcode(filedata, "", fileName, NULL, NULL); - - // Tokenize the preprocessed code.. - std::istringstream istr(filedata); - tokenizer.tokenize(istr, fileName.c_str(), ""); - } - - // Check the tokens.. - std::set errorlines; - arrayIndex(tokenizer, errorlines); - - // show report.. - { - std::ostringstream report; - std::ifstream fin(fileName.c_str()); - for (unsigned char c = readChar(fin); fin.good(); c = readChar(fin)) - { - if (c & 0x80) - continue; - report << c; - } - ui->codeEditor->setPlainText(QString::fromStdString(report.str())); - - QList errorLines; - for (std::set::const_iterator it = errorlines.begin(); it != errorlines.end(); ++it) - errorLines.push_back(*it); - ui->codeEditor->highlightErrors(errorLines); - } - -} - - - -/** - * Check that array indexes are within bounds - * 1. Locate array access through: [ .. ] - * 2. Try to determine if index is within bounds. - * 3. If it fails to determine that the index is within bounds then write warning - * \param tokenizer The tokenizer - * \param errout output stream to write warnings to - */ - -static void arrayIndex(const Tokenizer &tokenizer, std::set &errorlines) -{ - for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) - { - // 1. Locate array access through: [ .. ] - if (tok->fileIndex() == 0 && tok->str() == "[") - { - // 2. try to determine if the array index is within bounds - - // array declaration - if (Token::simpleMatch(tok, "[ ]")) - continue; - if (Token::Match(tok->tokAt(-2), "%type% %var% [ %num% ] ;|=")) - continue; - - // 3. If it fails to determine that the index is within bounds then write warning - errorlines.insert(tok->linenr()); - } - } -} diff --git a/verify/mainwindow.h b/verify/mainwindow.h deleted file mode 100644 index 4866421cf..000000000 --- a/verify/mainwindow.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2010 Daniel Marjamäki and Cppcheck team. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -namespace Ui -{ -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = 0); - ~MainWindow(); - -private slots: - void open(); - -private: - Ui::MainWindow *ui; -}; -#endif // MAINWINDOW_H diff --git a/verify/mainwindow.ui b/verify/mainwindow.ui deleted file mode 100644 index c639257e7..000000000 --- a/verify/mainwindow.ui +++ /dev/null @@ -1,75 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 600 - 400 - - - - Cppcheck-Verify - - - - - - - QPlainTextEdit::NoWrap - - - true - - - 4 - - - - - - - - - 0 - 0 - 600 - 25 - - - - - File - - - - - - - - TopToolBarArea - - - false - - - - - - Open.. - - - - - - - CodeEditor - QPlainTextEdit -
codeeditor.h
-
-
- - -
diff --git a/verify/readme.txt b/verify/readme.txt deleted file mode 100644 index fc9e726ae..000000000 --- a/verify/readme.txt +++ /dev/null @@ -1,11 +0,0 @@ - -cppcheck-verify -=============== - -Experimental subproject for Cppcheck. - -The goal is no false negatives. - -Just use 'make' to build. - -