mirror of
https://github.com/ThrowTheSwitch/CMock
synced 2025-05-23 02:49:33 -04:00
Improve handling of brackets in function params
During header parsing, #define substitutions in fixed-length array function parameters can have parentheses in them which can cause a failure in the bracket->asterisk conversion that happens during the mocking process. This change updates the regex to also match for parentheses in the function parameter brackets to ensure they get swapped out.
This commit is contained in:
parent
42a937a097
commit
a55efdba19
@ -187,9 +187,9 @@ class CMockHeaderParser
|
||||
return 'void'
|
||||
else
|
||||
c=0
|
||||
arg_list.gsub!(/(\w+)(?:\s*\[[\s\d\w+-]*\])+/,'*\1') # magically turn brackets into asterisks
|
||||
arg_list.gsub!(/\s+\*/,'*') # remove space to place asterisks with type (where they belong)
|
||||
arg_list.gsub!(/\*(\w)/,'* \1') # pull asterisks away from arg to place asterisks with type (where they belong)
|
||||
arg_list.gsub!(/(\w+)(?:\s*\[\(*[\s\d\w+-]*\)*\])+/,'*\1') # magically turn brackets into asterisks, also match for parentheses that come from macros
|
||||
arg_list.gsub!(/\s+\*/,'*') # remove space to place asterisks with type (where they belong)
|
||||
arg_list.gsub!(/\*(\w)/,'* \1') # pull asterisks away from arg to place asterisks with type (where they belong)
|
||||
|
||||
#scan argument list for function pointers and replace them with custom types
|
||||
arg_list.gsub!(/([\w\s\*]+)\(+\s*\*[\*\s]*([\w\s]*)\s*\)+\s*\(((?:[\w\s\*]*,?)*)\s*\)*/) do |m|
|
||||
|
@ -64,6 +64,7 @@
|
||||
|
||||
void oh_brackets1(int fudge[5]);
|
||||
void oh_brackets2(int caramel[]);
|
||||
void oh_brackets3(int toffee[(32)]);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user