fix: Don't smush macros which have an escaped empty line at the end

nanopb has a habit of generating macros which end with an escaped empty line (for example for messages which are empty). They look like this:

   #define some_msg_t_FIELDLIST(X, a) \

   #define some_msg_t_CALLBACK NULL

This caused CMock to strip all of the newlines after the backslash instead of only one, which the backslash was escaping.
This in turn caused both the macros to be in one line, causing a compile error in the generated mock.
This commit is contained in:
alufers
2023-04-26 14:16:41 +02:00
parent 379a9a8d5d
commit 3caf511b8f
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.