Skip to content

Commit ed29ce3

Browse files
authored
Merge pull request #437 from alufers/master
fix: Don't smush macros which have an escaped empty line at the end
2 parents 379a9a8 + 3caf511 commit ed29ce3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/cmock_header_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def transform_inline_functions(source)
137137
# If the user uses a macro to declare an inline function,
138138
# smushing the macros makes it easier to recognize them as a macro and if required,
139139
# remove them later on in this function
140-
source.gsub!(/\s*\\\s*/m, ' ')
140+
source.gsub!(/\s*\\(\n|\s*)/m, ' ')
141141

142142
# 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
143143
# Instead, look for an inline pattern (f.e. "static inline") and parse it.

test/unit/cmock_header_parser_test.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,5 +2867,19 @@ class Classy {
28672867
assert_equal(expected, @parser.transform_inline_functions(source))
28682868
end
28692869

2870+
it "Transform macros with escapes of empty lines" do
2871+
source =
2872+
"#define some_msg_t_FIELDLIST(X, a) \\\n" +
2873+
"\n" +
2874+
"#define some_msg_t_CALLBACK NULL\n"
2875+
2876+
expected =
2877+
"#define some_msg_t_FIELDLIST(X, a) \n" +
2878+
"#define some_msg_t_CALLBACK NULL\n"
2879+
2880+
@parser.treat_inlines = :include
2881+
assert_equal(expected, @parser.transform_inline_functions(source))
2882+
end
2883+
28702884

28712885
end

0 commit comments

Comments
 (0)