Skip to content

Commit

Permalink
truffle workaround #1484
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxLap committed Mar 20, 2019
1 parent 04dbfe7 commit bdf9c75
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core_gem/lib/deep_cover/tools/scan_match_datas.rb
Expand Up @@ -4,7 +4,16 @@ module DeepCover
module Tools::ScanMatchDatas
# Like String#scan, but return the MatchData object instead
def scan_match_datas(source, matcher)
source.to_enum(:scan, matcher).map { Regexp.last_match }
# This has wrong behavior in truffleruby
# source.to_enum(:scan, matcher).map { Regexp.last_match }
# This is the fool-proof way of doing it. Maybe some checks for perf should be done
start_at = 0
matches = []
while (match = source.match(matcher, start_at))
matches.push(match)
start_at = match.end(0)
end
matches
end
end
end

0 comments on commit bdf9c75

Please sign in to comment.