From 07776e90adb94da364579ed7c33162d9be66c5af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 5 Jan 2012 18:37:15 +0100 Subject: [PATCH] Preprocessor: cleanup --- lib/preprocessor.cpp | 10 ++++---- lib/preprocessor.h | 2 +- test/testpreprocessor.cpp | 50 +++++++++++++++++++-------------------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 366a26e1a..11f9d231d 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -104,7 +104,7 @@ static std::string unify(const std::string &s, char separator) } /** Just read the code into a string. Perform simple cleanup of the code */ -std::string Preprocessor::read(std::istream &istr, const std::string &filename, Settings *settings) +std::string Preprocessor::read(std::istream &istr, const std::string &filename) { // ------------------------------------------------------------------------------------------ // @@ -164,7 +164,7 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename, // ------------------------------------------------------------------------------------------ // // Remove all comments.. - result = removeComments(result, filename, settings); + result = removeComments(result, filename, _settings); // ------------------------------------------------------------------------------------------ // @@ -756,7 +756,7 @@ void Preprocessor::preprocess(std::istream &srcCodeStream, std::string &processe if (file0.empty()) file0 = filename; - processedFile = read(srcCodeStream, filename, _settings); + processedFile = read(srcCodeStream, filename); // Remove asm(...) removeAsm(processedFile); @@ -1836,7 +1836,7 @@ std::string Preprocessor::handleIncludes(const std::string &code, const std::str includes.push_back(filename); ostr << "#file \"" << filename << "\"\n" - << handleIncludes(read(fin, filename, NULL), filename, includePaths, defs, includes) << std::endl + << handleIncludes(read(fin, filename), filename, includePaths, defs, includes) << std::endl << "#endfile\n"; continue; } @@ -1909,7 +1909,7 @@ void Preprocessor::handleIncludes(std::string &code, const std::string &filePath } handledFiles.insert(tempFile); - processedFile = Preprocessor::read(fin, filename, _settings); + processedFile = Preprocessor::read(fin, filename); fin.close(); } diff --git a/lib/preprocessor.h b/lib/preprocessor.h index b9d5b468c..f14d36515 100644 --- a/lib/preprocessor.h +++ b/lib/preprocessor.h @@ -86,7 +86,7 @@ public: void preprocess(std::istream &srcCodeStream, std::string &processedFile, std::list &resultConfigurations, const std::string &filename, const std::list &includePaths); /** Just read the code into a string. Perform simple cleanup of the code */ - std::string read(std::istream &istr, const std::string &filename, Settings *settings); + std::string read(std::istream &istr, const std::string &filename); /** * Get preprocessed code for a given configuration diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index ecdc380e3..b38ae8f44 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -256,7 +256,7 @@ private: Settings settings; Preprocessor preprocessor(&settings, this); std::istringstream istr(code); - std::string codestr(preprocessor.read(istr,"test.c",0)); + std::string codestr(preprocessor.read(istr,"test.c")); ASSERT_EQUALS("a\n#aa b\n", codestr); } @@ -265,7 +265,7 @@ private: Settings settings; Preprocessor preprocessor(&settings, this); std::istringstream istr(code); - std::string codestr(preprocessor.read(istr,"test.c",0)); + std::string codestr(preprocessor.read(istr,"test.c")); ASSERT_EQUALS("\" \\\" /* abc */ \\n\"\n", codestr); } @@ -450,7 +450,7 @@ private: std::istringstream istr(filedata); Settings settings; Preprocessor preprocessor(&settings, this); - const std::string actual(preprocessor.read(istr, "test.c", 0)); + const std::string actual(preprocessor.read(istr, "test.c")); // Compare results.. ASSERT_EQUALS("#if A\n#if A\n#if A\n#if defined(A)\n#elif defined(A)\n", actual); @@ -648,7 +648,7 @@ private: std::istringstream istr(filedata); Settings settings; Preprocessor preprocessor(&settings, this); - ASSERT_EQUALS("#error\n\n123", preprocessor.read(istr,"test.c",0)); + ASSERT_EQUALS("#error\n\n123", preprocessor.read(istr,"test.c")); } @@ -692,13 +692,13 @@ private: "A\n" "#endif\n" "B\n"); - ASSERT_EQUALS("#if 0\n\n#endif\nB\n", preprocessor.read(code,"",NULL)); + ASSERT_EQUALS("#if 0\n\n#endif\nB\n", preprocessor.read(code,"")); std::istringstream code2("#if (0)\n" "A\n" "#endif\n" "B\n"); - ASSERT_EQUALS("#if 0\n\n#endif\nB\n", preprocessor.read(code2,"",NULL)); + ASSERT_EQUALS("#if 0\n\n#endif\nB\n", preprocessor.read(code2,"")); } void if0_whitespace() { @@ -709,7 +709,7 @@ private: "A\n" " # endif \n" "B\n"); - ASSERT_EQUALS("#if 0\n\n#endif\nB\n", preprocessor.read(code,"",NULL)); + ASSERT_EQUALS("#if 0\n\n#endif\nB\n", preprocessor.read(code,"")); } void if0_else() { @@ -722,7 +722,7 @@ private: "B\n" "#endif\n" "C\n"); - ASSERT_EQUALS("#if 0\n\n#else\nB\n#endif\nC\n", preprocessor.read(code,"",NULL)); + ASSERT_EQUALS("#if 0\n\n#else\nB\n#endif\nC\n", preprocessor.read(code,"")); std::istringstream code2("#if 1\n" "A\n" @@ -731,7 +731,7 @@ private: "#endif\n" "C\n"); TODO_ASSERT_EQUALS("#if 1\nA\n#else\n\n#endif\nC\n", - "#if 1\nA\n#else\nB\n#endif\nC\n", preprocessor.read(code2,"",NULL)); + "#if 1\nA\n#else\nB\n#endif\nC\n", preprocessor.read(code2,"")); } void if0_elif() { @@ -744,7 +744,7 @@ private: "B\n" "#endif\n" "C\n"); - ASSERT_EQUALS("#if 0\n\n#elif 1\nB\n#endif\nC\n", preprocessor.read(code,"",NULL)); + ASSERT_EQUALS("#if 0\n\n#elif 1\nB\n#endif\nC\n", preprocessor.read(code,"")); } void if0_include_1() { @@ -755,7 +755,7 @@ private: "#include \"a.h\"\n" "#endif\n" "AB\n"); - ASSERT_EQUALS("#if 0\n\n#endif\nAB\n", preprocessor.read(code,"",NULL)); + ASSERT_EQUALS("#if 0\n\n#endif\nAB\n", preprocessor.read(code,"")); } void if0_include_2() { @@ -769,7 +769,7 @@ private: "#endif\n" "#endif\n" "AB\n"); - ASSERT_EQUALS("#if 0\n\n#ifdef WIN32\n#else\n#endif\n#endif\nAB\n", preprocessor.read(code,"",NULL)); + ASSERT_EQUALS("#if 0\n\n#ifdef WIN32\n#else\n#endif\n#endif\nAB\n", preprocessor.read(code,"")); } void includeguard1() { @@ -851,7 +851,7 @@ private: std::istringstream istr(filedata); Settings settings; Preprocessor preprocessor(&settings, this); - ASSERT_EQUALS("\n\n\n", preprocessor.read(istr, "test.c", 0)); + ASSERT_EQUALS("\n\n\n", preprocessor.read(istr, "test.c")); } @@ -1477,7 +1477,7 @@ private: std::istringstream istr(filedata); Settings settings; Preprocessor preprocessor(&settings, this); - ASSERT_EQUALS("#define str \"abc\" \"def\"\n\nabcdef = str;\n", preprocessor.read(istr, "test.c", 0)); + ASSERT_EQUALS("#define str \"abc\" \"def\"\n\nabcdef = str;\n", preprocessor.read(istr, "test.c")); } void multiline2() { @@ -1489,7 +1489,7 @@ private: std::istringstream istr(filedata); Settings settings; Preprocessor preprocessor(&settings, this); - ASSERT_EQUALS("#define sqr(aa) aa * aa\n\nsqr(5);\n", preprocessor.read(istr, "test.c", 0)); + ASSERT_EQUALS("#define sqr(aa) aa * aa\n\nsqr(5);\n", preprocessor.read(istr, "test.c")); } void multiline3() { @@ -1501,7 +1501,7 @@ private: std::istringstream istr(filedata); Settings settings; Preprocessor preprocessor(&settings, this); - ASSERT_EQUALS("const char *str = \"abcdefghi\"\n\n\n", preprocessor.read(istr, "test.c", 0)); + ASSERT_EQUALS("const char *str = \"abcdefghi\"\n\n\n", preprocessor.read(istr, "test.c")); } void multiline4() { @@ -2279,7 +2279,7 @@ private: errout.str(""); Settings settings; Preprocessor preprocessor(&settings, this); - preprocessor.read(istr, "test.cpp", 0); + preprocessor.read(istr, "test.cpp"); ASSERT_EQUALS("[test.cpp:1]: (error) The code contains characters that are unhandled. Neither unicode nor extended ASCII are supported. (line=1, character code=c8)\n", errout.str()); } @@ -2288,7 +2288,7 @@ private: std::istringstream istr(filedata); Settings settings; Preprocessor preprocessor(&settings, this); - ASSERT_EQUALS("", preprocessor.read(istr, "test.cpp", 0)); + ASSERT_EQUALS("", preprocessor.read(istr, "test.cpp")); } void unicodeInString() { @@ -2296,7 +2296,7 @@ private: std::istringstream istr(filedata); Settings settings; Preprocessor preprocessor(&settings, this); - ASSERT_EQUALS(filedata, preprocessor.read(istr, "test.cpp", 0)); + ASSERT_EQUALS(filedata, preprocessor.read(istr, "test.cpp")); } @@ -2710,7 +2710,7 @@ private: std::istringstream istr(filedata); Settings settings; Preprocessor preprocessor(&settings, this); - ASSERT_EQUALS("#define FOO 1020", preprocessor.read(istr, "test.cpp", 0)); + ASSERT_EQUALS("#define FOO 1020", preprocessor.read(istr, "test.cpp")); } void testPreprocessorRead2() { @@ -2718,7 +2718,7 @@ private: std::istringstream istr(filedata); Settings settings; Preprocessor preprocessor(&settings, this); - ASSERT_EQUALS("\"foo\\bar\"", preprocessor.read(istr, "test.cpp", 0)); + ASSERT_EQUALS("\"foo\\bar\"", preprocessor.read(istr, "test.cpp")); } void testPreprocessorRead3() { @@ -2726,7 +2726,7 @@ private: std::istringstream istr(filedata); Settings settings; Preprocessor preprocessor(&settings, this); - ASSERT_EQUALS(filedata, preprocessor.read(istr, "test.cpp", 0)); + ASSERT_EQUALS(filedata, preprocessor.read(istr, "test.cpp")); } void testPreprocessorRead4() { @@ -2736,7 +2736,7 @@ private: std::istringstream istr(filedata); Settings settings; Preprocessor preprocessor(&settings, this); - ASSERT_EQUALS("#define A \" \\\\\" \" \"", preprocessor.read(istr, "test.cpp", 0)); + ASSERT_EQUALS("#define A \" \\\\\" \" \"", preprocessor.read(istr, "test.cpp")); } { @@ -2745,7 +2745,7 @@ private: std::istringstream istr(filedata); Settings settings; Preprocessor preprocessor(&settings, this); - ASSERT_EQUALS("#define A \" \\\\\\\" \"", preprocessor.read(istr, "test.cpp", 0)); + ASSERT_EQUALS("#define A \" \\\\\\\" \"", preprocessor.read(istr, "test.cpp")); } { @@ -2754,7 +2754,7 @@ private: std::istringstream istr(filedata); Settings settings; Preprocessor preprocessor(&settings, this); - ASSERT_EQUALS("#define A \" \\\\\\\\\" \" \"", preprocessor.read(istr, "test.cpp", 0)); + ASSERT_EQUALS("#define A \" \\\\\\\\\" \" \"", preprocessor.read(istr, "test.cpp")); } }