diff options
-rw-r--r-- | lib.c | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -4049,8 +4049,9 @@ val tok_where(val str, val tok_regex) { list_collect_decl (out, iter); val pos = zero; + int prev_empty = 1; - for (;;) { + if (opt_compat && opt_compat <= 155) for (;;) { val range = range_regex(str, tok_regex, pos, nil); if (range) { @@ -4066,6 +4067,27 @@ val tok_where(val str, val tok_regex) } break; + } else for (;;) { + val range = range_regex(str, tok_regex, pos, nil); + + if (range) { + range_bind (match_start, match_end, range); + + if (match_end != match_start || prev_empty) { + iter = list_collect(iter, range); + prev_empty = (match_end == match_start); + } else { + prev_empty = 1; + } + + pos = match_end; + + if (match_end == match_start) + pos = plus(pos, one); + continue; + } + + break; } return out; |