diff options
author | Kasumi Hanazuki <kasumi@rollingapple.net> | 2020-08-11 09:32:02 +0000 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-08-12 10:01:39 +0900 |
commit | e79cdcf61b0665d8a9bb309a607227de43e95673 (patch) | |
tree | cd0ef903162b7ba737a2734a639a962b5f014752 /string.c | |
parent | 66efe373116d510c05d57964b5ffa47f1c6e565c (diff) | |
download | ruby-e79cdcf61b0665d8a9bb309a607227de43e95673.tar.gz |
string.c(rb_str_split_m): Handle /\K/ correctly
Use BEG(0) instead of the result of rb_reg_search to handle the cases
when the separator Regexp contains /\K/ (lookbehind) operator.
Fixes [Bug #17113]
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -8216,11 +8216,12 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str) struct re_registers *regs; VALUE match = 0; - for (; (end = rb_reg_search(spat, str, start, 0)) >= 0; + for (; rb_reg_search(spat, str, start, 0) >= 0; (match ? (rb_match_unbusy(match), rb_backref_set(match)) : (void)0)) { match = rb_backref_get(); if (!result) rb_match_busy(match); regs = RMATCH_REGS(match); + end = BEG(0); if (start == end && BEG(0) == END(0)) { if (!ptr) { SPLIT_STR(0, 0); |