Skip to content
Myr

Advance past the whole codepoint after a zero-width regex match (#3586)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by WinkleMad · committed by GitHub · parent dbcaa9d · Browse files · 2 files+21 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+21 added−2 removed

  • tests:+13 added−0 removed
  • other:+8 added−2 removed

2 files+21 added−2 removed

modified:src/builtin.c+8 added-2 removed
1084 unmodified lines
1085 }1086 onig_foreach_name(reg, f_match_name_iter, &captures);1087 match = jv_object_set(match, jv_string("captures"), captures);1088 result = jv_array_append(result, match);1089 // ensure '"qux" | match("(?=u)"; "g")' matches just once1090 start = (const UChar*)(input_string+region->end[0]+1);1089 // ensure '"qux" | match("(?=u)"; "g")' matches just once; advance the1090 // search start past the whole codepoint, not a single byte, so we don't1091 // land in the middle of a multibyte character (which would yield a1092 // spurious duplicate match at the same offset).1093 start = (const UChar*)(input_string + region->end[0] +1094 ((size_t)region->end[0] < length1095 ? jvp_utf8_decode_length(input_string[region->end[0]])1096 : 1));1097 continue;1098 }10991100 unsigned long idx;
1057 unmodified lines
modified:tests/onig.test+13 added
9 unmodified lines
10[match(""; "g")]11"ab"12[{"offset":0,"length":0,"string":"","captures":[]},{"offset":1,"length":0,"string":"","captures":[]},{"offset":2,"length":0,"string":"","captures":[]}]1314# global zero-width matches must not land inside a multibyte character15[match(""; "g") | .offset]16"aé€🚀b"17[0,1,2,3,4,5]1819gsub(""; "-")20"aé"21"-a-é-"2223[splits("")]24"aé"25["","a","é",""]2627[match("a"; "gi")]28"āáàä"29[]30
194 unmodified lines