diff --git a/lib/cmock_header_parser.rb b/lib/cmock_header_parser.rb index 69ab323..c910052 100644 --- a/lib/cmock_header_parser.rb +++ b/lib/cmock_header_parser.rb @@ -94,7 +94,14 @@ class CMockHeaderParser end # remove nested pairs of braces because no function declarations will be inside of them (leave outer pair for function definition detection) - source.gsub!(/\{([^\{\}]*|\g<0>)*\}/m, '{ }') + if (RUBY_VERSION.split('.')[0].to_i > 1) + #we assign a string first because (no joke) if Ruby 1.9.3 sees this line as a regex, it will crash. + r = "\\{([^\\{\\}]*|\\g<0>)*\\}" + source.gsub!(/#{r}/m, '{ }') + else + while source.gsub!(/\{[^\{\}]*\{[^\{\}]*\}[^\{\}]*\}/m, '{ }') + end + end # remove function definitions by stripping off the arguments right now source.gsub!(/\([^\)]*\)\s*\{[^\}]*\}/m, ";")