Fix \K within recursion bug in interpreter.

This commit is contained in:
Philip.Hazel 2021-02-18 09:46:08 +00:00
parent b6acebe497
commit 2c4d3942e4
4 changed files with 14 additions and 1 deletions

View File

@ -35,6 +35,10 @@ now runs clean and the resulting "configure" seems to work, so I hope nothing
is broken. Later: the requirement for autoconf 2.70 broke some automatic test is broken. Later: the requirement for autoconf 2.70 broke some automatic test
robots. It doesn't seem to be necessary: trying a reduction to 2.60. robots. It doesn't seem to be necessary: trying a reduction to 2.60.
6. The pattern /a\K.(?0)*/ when matched against "abac" by the interpreter gave
the answer "bac", whereas Perl and JIT both yield "c". This was because the
effect of \K was not propagating back from the recursion. This is now fixed.
Version 10.36 04-December-2020 Version 10.36 04-December-2020
------------------------------ ------------------------------

View File

@ -818,10 +818,12 @@ fprintf(stderr, "++ op=%d\n", *Fecode);
/* N is now the frame of the recursion; the previous frame is at the /* N is now the frame of the recursion; the previous frame is at the
OP_RECURSE position. Go back there, copying the current subject position OP_RECURSE position. Go back there, copying the current subject position
and mark, and move on past the OP_RECURSE. */ and mark, and the start_match position (\K might have changed it), and
then move on past the OP_RECURSE. */
P->eptr = Feptr; P->eptr = Feptr;
P->mark = Fmark; P->mark = Fmark;
P->start_match = Fstart_match;
F = P; F = P;
Fecode += 1 + LINK_SIZE; Fecode += 1 + LINK_SIZE;
continue; continue;

3
testdata/testinput1 vendored
View File

@ -6429,4 +6429,7 @@ ef) x/x,mark
/a{65536/ /a{65536/
>a{65536< >a{65536<
/a\K.(?0)*/
abac
# End of testinput1 # End of testinput1

View File

@ -10188,4 +10188,8 @@ No match
>a{65536< >a{65536<
0: a{65536 0: a{65536
/a\K.(?0)*/
abac
0: c
# End of testinput1 # End of testinput1