Whoops. Fixed last issue.

This commit is contained in:
Mark VanderVoord
2026-07-01 10:41:29 -04:00
parent 847e87e71e
commit 922ebfa699
+6 -4
View File
@@ -118,11 +118,13 @@ class CMockHeaderParser
def remove_nested_pairs_of_braces(source) def remove_nested_pairs_of_braces(source)
# remove nested pairs of braces because no function declarations will be inside of them (leave outer pair for function definition detection) # remove nested pairs of braces because no function declarations will be inside of them (leave outer pair for function definition detection)
# Use iterative approach for all Ruby versions: the recursive regex \{([^\{\}]*|\g<0>)*\} # Collapse innermost brace pairs first using a brace-free sentinel (\x00), working
# is exponential on unbalanced brace inputs (catastrophic backtracking on Ruby < 3.2). # outward until no balanced pairs remain. This avoids the catastrophic backtracking
while source.gsub!(/\{[^{}]*\{[^{}]*\}[^{}]*\}/m, '{ }') # of the recursive regex \{([^\{\}]*|\g<0>)*\} on Ruby < 3.2 while preserving
# Keep doing it! # identical semantics: every balanced brace structure is collapsed to '{ }'.
while source.gsub!(/\{[^{}]*\}/m, "\x00")
end end
source.gsub!("\x00", '{ }')
source source
end end