mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-09-17 07:39:57 +00:00
Whoops. Fixed last issue.
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user