On Tue Apr 28 14:27:34 2015, demerphq wrote: > On 28 April 2015 at 22:28, Karl Williamson <public@khwilliamson.com> wrote: > > I haven't ever looked at the \K code; I was hoping someone else would look > > at this. > > Ok, then I will try to find time to address this. What's the intended behaviour of \K in a look-(ahead|behind)? My first thught was that it should be ignored, something like: --- a/regcomp.c +++ b/regcomp.c @@ -11787,15 +11787,23 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, *flagp |= SIMPLE; goto finish_meta_pat; case 'K': - RExC_seen_zerolen++; - ret = reg_node(pRExC_state, KEEPS); - *flagp |= SIMPLE; - /* XXX:dmq : disabling in-place substitution seems to - * be necessary here to avoid cases of memory corruption, as - * with: C<$_="x" x 80; s/x\K/y/> -- rgs - */ - RExC_seen |= REG_LOOKBEHIND_SEEN; - goto finish_meta_pat; + if (!RExC_in_lookbehind) { + RExC_seen_zerolen++; + ret = reg_node(pRExC_state, KEEPS); + *flagp |= SIMPLE; + /* XXX:dmq : disabling in-place substitution seems to + * be necessary here to avoid cases of memory corruption, as + * with: C<$_="x" x 80; s/x\K/y/> -- rgs + */ + RExC_seen |= REG_LOOKBEHIND_SEEN; + goto finish_meta_pat; + } + else { + ++RExC_parse; + if (PASS2) + ckWARNreg(RExC_parse, "\\K useless in lookbehind"); + goto tryagain; + } (with some extra code needed to handle look-aheads.) Or should it control the region matched, so \K in the example would set $& to "a", as it does now? Tony --- via perlbug: queue: perl5 status: open https://rt.perl.org/Ticket/Display.html?id=124256Thread Previous | Thread Next