From 5ddce9cc34ca97f02521935c0d48c1cc6f1dc9e5 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:06:00 +0200 Subject: [PATCH 1/4] Update simplecpp.cpp --- simplecpp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplecpp.cpp b/simplecpp.cpp index 2dae2f20..5bd5caca 100755 --- a/simplecpp.cpp +++ b/simplecpp.cpp @@ -3480,7 +3480,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL inc2.takeTokens(inc1); } - if (!inc2.empty() && inc2.cfront()->op == '<' && inc2.cback()->op == '>') { + if (!inc1.empty() && !inc2.empty() && inc2.cfront()->op == '<' && inc2.cback()->op == '>') { TokenString hdr; // TODO: Sometimes spaces must be added in the string // Somehow preprocessToken etc must be told that the location should be source location not destination location From 87dce498ac2925dff85b5b227c85c9aba88ee9b6 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:09:59 +0200 Subject: [PATCH 2/4] Update test.cpp --- test.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test.cpp b/test.cpp index 1f979dd3..07985a5e 100644 --- a/test.cpp +++ b/test.cpp @@ -1829,6 +1829,14 @@ static void missingHeader3() ASSERT_EQUALS("", toString(outputList)); } +static void missingHeader4() +{ + const char code[] = "#/**/include <>\n"; + simplecpp::OutputList outputList; + ASSERT_EQUALS("", preprocess(code, &outputList)); + ASSERT_EQUALS("", toString(outputList)); +} + static void nestedInclude() { const char code[] = "#include \"test.h\"\n"; @@ -3057,6 +3065,7 @@ int main(int argc, char **argv) TEST_CASE(missingHeader1); TEST_CASE(missingHeader2); TEST_CASE(missingHeader3); + TEST_CASE(missingHeader4); TEST_CASE(nestedInclude); TEST_CASE(systemInclude); From b823993264e8a5287e9fea6bfb6562c685c86857 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:12:12 +0200 Subject: [PATCH 3/4] Update test.cpp --- test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.cpp b/test.cpp index 07985a5e..63072a76 100644 --- a/test.cpp +++ b/test.cpp @@ -1834,7 +1834,7 @@ static void missingHeader4() const char code[] = "#/**/include <>\n"; simplecpp::OutputList outputList; ASSERT_EQUALS("", preprocess(code, &outputList)); - ASSERT_EQUALS("", toString(outputList)); + ASSERT_EQUALS("actual:file0,1,syntax_error,No header in #include\n", toString(outputList)); } static void nestedInclude() From 4df52e3fa4e4194c5646a0a1071c87baa9def60a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:13:48 +0200 Subject: [PATCH 4/4] Update test.cpp --- test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.cpp b/test.cpp index 63072a76..d8e359e5 100644 --- a/test.cpp +++ b/test.cpp @@ -1834,7 +1834,7 @@ static void missingHeader4() const char code[] = "#/**/include <>\n"; simplecpp::OutputList outputList; ASSERT_EQUALS("", preprocess(code, &outputList)); - ASSERT_EQUALS("actual:file0,1,syntax_error,No header in #include\n", toString(outputList)); + ASSERT_EQUALS("file0,1,syntax_error,No header in #include\n", toString(outputList)); } static void nestedInclude()