regcomp.c: Need to account for delta sizes
authorKarl Williamson <public@khwilliamson.com>
Sat, 24 Dec 2011 02:13:24 +0000 (19:13 -0700)
committerKarl Williamson <public@khwilliamson.com>
Thu, 19 Jan 2012 18:58:18 +0000 (11:58 -0700)
When a node can match varying sizes, the delta variable in the optimizer
needs to change to account for that, and it can no longer match a fixed
length string.

This code was adapted from the existing code for the FOLDCHAR node that
has to deal with the same problem.

regcomp.c

index 11f1ca4..79acca6 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -3291,11 +3291,16 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
             if (min < 0) {
                 min = 0;
             }
+            delta += abs(min_change);
            if (flags & SCF_DO_SUBSTR) {
                data->pos_min += l + min_change;
                if (data->pos_min < 0) {
                     data->pos_min = 0;
                 }
+                data->pos_delta += abs(min_change);
+               if (min_change) {
+                   data->longest = &(data->longest_float);
+               }
            }
            if (flags & SCF_DO_STCLASS_AND) {
                /* Check whether it is compatible with what we know already! */