re_intuit_start(): MBOL use char for float max
authorDavid Mitchell <davem@iabyn.com>
Fri, 7 Feb 2014 22:25:40 +0000 (22:25 +0000)
committerDavid Mitchell <davem@iabyn.com>
Sat, 8 Feb 2014 14:04:55 +0000 (14:04 +0000)
Do the "maximum place \n can appear within the float range" calculation
in chars rather than bytes. Doing it in bytes is logically incorrect,
although I think the worst outcome is that a string is falsely accepted
by intuit then has to be failed by a full run of the regex engine.
But I couldn't think of a test that would show a significant performance
difference.

regexec.c

index f9cfc89..213bf9f 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -1112,9 +1112,12 @@ Perl_re_intuit_start(pTHX_
             goto fail_finish;
         }
 
+        /* since *t == '\n', it's safe to do +1 here rather than HOP(t,1) */
         rx_origin = t + 1; /* earliest possible origin is after the \n */
 
-        if (t >= check_at - prog->check_offset_min) {
+        if (prog->substrs->check_ix == 0  /* check is anchored */
+            || t >= HOP3c(check_at,  - prog->check_offset_min, strpos))
+        {
             /* Position contradicts check-string; either because
              * check was anchored (and thus has no wiggle room),
              * or check was float and t is above the float range */