Make absent operator work at the end of the input string

https://bugs.ruby-lang.org/issues/19104#change-100542
This commit is contained in:
Yusuke Endoh 2022-12-09 14:17:35 +09:00
parent f093b619a4
commit b8e542b463
Notes: git 2022-12-12 05:26:56 +00:00
2 changed files with 8 additions and 0 deletions

View File

@ -3774,6 +3774,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
DATA_ENSURE(0);
p += addr;
}
else if (s == end) {
/* At the end of the string, just match with it */
DATA_ENSURE(0);
p += addr;
}
else {
STACK_PUSH_ALT(p + addr, s, sprev, pkeep); /* Push possible point. */
n = enclen(encode, s, end);

View File

@ -1525,6 +1525,9 @@ class TestRegexp < Test::Unit::TestCase
assert_equal(0, /(?~(a)c)/ =~ "abb")
assert_nil($1)
assert_equal(0, /(?~(a))/ =~ "")
assert_nil($1)
end
def test_backref_overrun