diff --git a/simplecpp.cpp b/simplecpp.cpp index 2b7b8b00..85399150 100755 --- a/simplecpp.cpp +++ b/simplecpp.cpp @@ -2864,8 +2864,6 @@ static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const if (systemheader) { ret = openHeaderIncludePath(f, dui, header); - if (ret.empty()) - return openHeaderRelative(f, sourcefile, header); return ret; } @@ -2894,8 +2892,8 @@ static std::string getFileName(const std::mapop == '<'); + const bool systemheader = (inctok->str()[0] == '<'); const std::string header(realFilename(inctok->str().substr(1U, inctok->str().size() - 2U))); std::string header2 = getFileName(filedata, rawtok->location.file(), header, dui, systemheader); if (header2.empty()) { diff --git a/test.cpp b/test.cpp index 2e8f1549..c8323c85 100644 --- a/test.cpp +++ b/test.cpp @@ -1653,6 +1653,22 @@ static void nestedInclude() ASSERT_EQUALS("file0,1,include_nested_too_deeply,#include nested too deeply\n", toString(outputList)); } +static void systemInclude() +{ + const char code[] = "#include \n"; + std::vector files; + simplecpp::TokenList rawtokens = makeTokenList(code,files,"local/limits.h"); + std::map filedata; + filedata["limits.h"] = nullptr; + filedata["local/limits.h"] = &rawtokens; + + simplecpp::OutputList outputList; + simplecpp::TokenList tokens2(files); + simplecpp::preprocess(tokens2, rawtokens, files, filedata, simplecpp::DUI(), &outputList); + + ASSERT_EQUALS("", toString(outputList)); +} + static void multiline1() { const char code[] = "#define A \\\n" @@ -2566,6 +2582,7 @@ int main(int argc, char **argv) TEST_CASE(missingHeader2); TEST_CASE(missingHeader3); TEST_CASE(nestedInclude); + TEST_CASE(systemInclude); TEST_CASE(nullDirective1); TEST_CASE(nullDirective2);