regexec.c: invalidate previously matched position

* regexec.c (match_at): invalidate end position not yet matched
  when new start position is pushed, to dispose previously stored
  position.  [ruby-core:83743] [Bug #14101]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-11-13 05:50:54 +00:00
Родитель 0c467565ca
Коммит 24d38cc447
2 изменённых файлов: 4 добавлений и 0 удалений

Просмотреть файл

@ -2506,6 +2506,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
CASE(OP_MEMORY_START) MOP_IN(OP_MEMORY_START);
GET_MEMNUM_INC(mem, p);
mem_start_stk[mem] = (OnigStackIndex )((void* )s);
mem_end_stk[mem] = INVALID_STACK_INDEX;
MOP_OUT;
JUMP;

Просмотреть файл

@ -1238,6 +1238,9 @@ class TestRegexp < Test::Unit::TestCase
assert_equal(0, /\/\*((?~\*\/))\*\// =~ "/*abc*def/xyz*/ /* */")
assert_equal("abc*def/xyz", $1)
assert_equal(0, /(?~(a)c)/ =~ "abb")
assert_nil($1)
end
# This assertion is for porting x2() tests in testpy.py of Onigmo.