From ebf4ae274adfcb2d5f8650115c8d3615395de8b5 Mon Sep 17 00:00:00 2001 From: Andrew Setter Date: Fri, 3 Mar 2017 13:30:22 -0500 Subject: [PATCH] Allow for whitespace between parens and brackets --- lib/cmock_header_parser.rb | 6 +++--- test/system/test_interactions/parsing_challenges.yml | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/cmock_header_parser.rb b/lib/cmock_header_parser.rb index d989fa6..b37419c 100644 --- a/lib/cmock_header_parser.rb +++ b/lib/cmock_header_parser.rb @@ -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, 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) + arg_list.gsub!(/(\w+)(?:\s*\[\s*\(*[\s\d\w+-]*\)*\s*\])+/,'*\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| diff --git a/test/system/test_interactions/parsing_challenges.yml b/test/system/test_interactions/parsing_challenges.yml index 9ecc04a..77e857d 100644 --- a/test/system/test_interactions/parsing_challenges.yml +++ b/test/system/test_interactions/parsing_challenges.yml @@ -65,6 +65,7 @@ void oh_brackets1(int fudge[5]); void oh_brackets2(int caramel[]); void oh_brackets3(int toffee[(32)]); + void oh_brackets4(int taffy[ (64) ]); #ifdef __cplusplus } #endif