diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-10-08 11:16:03 +0800 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-11-01 14:05:14 +0800 |
| commit | 08ea68dc1f3ffc387796addaacaeb40e4e566763 (patch) | |
| tree | 99ee29f24ef5a90d3972e41e1b0e5267a5b2d321 /src | |
| parent | 9ec376135bba2584cec0c08e767055b256f6d7e3 (diff) | |
Regex: Fix handling of match_prev_avail for boost regex
We were passing around iterators that were not allowed to
go before the begin iterator.
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex.hh | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/regex.hh b/src/regex.hh index 3d067b0b..eecb947d 100644 --- a/src/regex.hh +++ b/src/regex.hh @@ -180,7 +180,8 @@ bool regex_search(It begin, It end, const Regex& re, { try { - bool matched = boost::regex_search<RegexUtf8It<It>>({begin, begin, end}, {end, begin, end}, re, flags); + auto first = (flags & RegexConstant::match_prev_avail) ? begin-1 : begin; + bool matched = boost::regex_search<RegexUtf8It<It>>({begin, first, end}, {end, first, end}, re, flags); if (re.impl() and matched != regex_search(begin, end, *re.impl(), convert_flags(flags))) regex_mismatch(re); return matched; @@ -197,7 +198,8 @@ bool regex_search(It begin, It end, MatchResults<It>& res, const Regex& re, { try { - bool matched = boost::regex_search<RegexUtf8It<It>>({begin, begin, end}, {end, begin, end}, res, re, flags); + auto first = (flags & RegexConstant::match_prev_avail) ? begin-1 : begin; + bool matched = boost::regex_search<RegexUtf8It<It>>({begin, first, end}, {end, first, end}, res, re, flags); Vector<It> captures; if (re.impl() and matched != regex_search(begin, end, captures, *re.impl(), convert_flags(flags))) regex_mismatch(re); |
