Merge pull request #437 from alufers/master

fix: Don't smush macros which have an escaped empty line at the end
This commit is contained in:
Mark VanderVoord
2023-05-08 09:18:03 -04:00
committed by GitHub
2 changed files with 15 additions and 1 deletions
+1 -1
View File
@@ -137,7 +137,7 @@ class CMockHeaderParser
# If the user uses a macro to declare an inline function,
# smushing the macros makes it easier to recognize them as a macro and if required,
# remove them later on in this function
source.gsub!(/\s*\\\s*/m, ' ')
source.gsub!(/\s*\\(\n|\s*)/m, ' ')
# Just looking for static|inline in the gsub is a bit too aggressive (functions that are named like this, ...), so we try to be a bit smarter
# Instead, look for an inline pattern (f.e. "static inline") and parse it.
+14
View File
@@ -2867,5 +2867,19 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
assert_equal(expected, @parser.transform_inline_functions(source))
end
it "Transform macros with escapes of empty lines" do
source =
"#define some_msg_t_FIELDLIST(X, a) \\\n" +
"\n" +
"#define some_msg_t_CALLBACK NULL\n"
expected =
"#define some_msg_t_FIELDLIST(X, a) \n" +
"#define some_msg_t_CALLBACK NULL\n"
@parser.treat_inlines = :include
assert_equal(expected, @parser.transform_inline_functions(source))
end
end