From 046db9b2bbfda2c9a4e48ebd5ebaee13d140b383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 6 Dec 2009 19:53:17 +0100 Subject: [PATCH] Preprocessor: Fix so the unit tests work again --- lib/preprocessor.cpp | 2 +- lib/preprocessor.h | 6 ++++++ test/testpreprocessor.cpp | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 7c77072b7..c53b71186 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -201,7 +201,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri if (i == std::string::npos) break; - if (settings->_inlineSuppressions) + if (settings && settings->_inlineSuppressions) { std::string comment(str, commentStart, i - commentStart); std::istringstream iss(comment); diff --git a/lib/preprocessor.h b/lib/preprocessor.h index 4e052b3b4..12a46b514 100644 --- a/lib/preprocessor.h +++ b/lib/preprocessor.h @@ -72,6 +72,12 @@ public: /** Just read the code into a string. Perform simple cleanup of the code */ static std::string read(std::istream &istr, const std::string &filename, Settings *settings); + /** Just read the code into a string. Perform simple cleanup of the code */ + static std::string read(std::istream &istr) + { + return read(istr, "", 0); + } + /** * Get preprocessed code for a given configuration */ diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 0b4f9d1ca..31356195c 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -793,7 +793,7 @@ private: // Preprocess => actual result.. std::istringstream istr(filedata); std::map actual; - const Settings settings; + Settings settings; Preprocessor preprocessor(&settings, this); preprocessor.preprocess(istr, actual, "file.c"); @@ -811,7 +811,7 @@ private: // Preprocess => actual result.. std::istringstream istr(filedata); std::map actual; - const Settings settings; + Settings settings; Preprocessor preprocessor(&settings, this); preprocessor.preprocess(istr, actual, "file.c");