Support version 1.9.3 again (with slightly less awesome brace matching)

This commit is contained in:
Mark VanderVoord
2017-08-18 23:46:15 -04:00
parent c61a35d2a5
commit 0b303dba29
+8 -1
View File
@@ -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, ";")