Skip to content

Commit

Permalink
[perl #121484] /m causing false negative
Browse files Browse the repository at this point in the history
My recent commit d0d4464 in re_intuit_start() reduced the
scope of a 'skip if multiline' check, so that certain optimisations
weren't being unnecessarily skipped. Unfortunately it didn't reduce the
scope enough, so a vital slen-- was being skipped in the
SvTAIL-but-don't-fail case.

This commit just moves the !multiline test further down, and updates the
commentary and condition formatting a bit.
  • Loading branch information
iabyn committed Mar 24, 2014
1 parent 18ae2ab commit 7742aa6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
15 changes: 9 additions & 6 deletions regexec.c
Expand Up @@ -804,12 +804,15 @@ Perl_re_intuit_start(pTHX_
" Looking for check substr at fixed offset %"IVdf"...\n",
(IV)prog->check_offset_min));

if (SvTAIL(check) && !multiline) {
/* In this case, the regex is anchored at the end too,
* so the lengths must match exactly, give or take a \n.
* NB: slen >= 1 since the last char of check is \n */
if ( strend - s > slen || strend - s < slen - 1
|| (strend - s == slen && strend[-1] != '\n'))
if (SvTAIL(check)) {
/* In this case, the regex is anchored at the end too.
* Unless it's a multiline match, the lengths must match
* exactly, give or take a \n. NB: slen >= 1 since
* the last char of check is \n */
if (!multiline
&& ( strend - s > slen
|| strend - s < slen - 1
|| (strend - s == slen && strend[-1] != '\n')))
{
DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
" String too long...\n"));
Expand Down
1 change: 1 addition & 0 deletions t/re/re_tests
Expand Up @@ -1883,6 +1883,7 @@ A+(*PRUNE)BC(?{}) AAABC y $& AAABC
\d<(.*?)> a<> n - -
[bcd].{2,3}aaaa XbXaaaaa y - -
[bcd].{2,3}aaaa Xb\x{100}aaaaa y - -
'\Awibble\z'm wibble y - -

# Keep these lines at the end of the file
# vim: softtabstop=0 noexpandtab

0 comments on commit 7742aa6

Please sign in to comment.