scan_data_t: rename 'longest' field
authorDavid Mitchell <davem@iabyn.com>
Fri, 30 Jun 2017 11:43:00 +0000 (12:43 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sun, 2 Jul 2017 20:24:13 +0000 (21:24 +0100)
.. to 'cur_is_floating'

It's an index into either the fixed or float substring info; the
information it provides is whether the currently being captured substring
is fixed or floating; it's nothing to do with whether the fixed or the
floating is currently the longest.

regcomp.c

index 6278d44..06e1433 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -462,7 +462,9 @@ typedef struct scan_data_t {
     SSize_t last_end;      /* min value, <0 unless valid. */
     SSize_t last_start_min;
     SSize_t last_start_max;
-    U8 longest;                    /* 0 = fixed is longest, 1 = float is longest */
+    U8      cur_is_floating; /* whether the last_* values should be set as
+                              * the next fixed (0) or floating (1)
+                              * substring */
 
     /* [0] is longest fixed substring so far, [1] is longest float so far */
     struct scan_data_substrs  substrs[2];
@@ -1039,7 +1041,7 @@ S_debug_studydata(pTHX_ const char *where, scan_data_t *data,
 
             Perl_re_printf(aTHX_
                 " %sFixed:'%s' @ %" IVdf,
-                data->longest == 0 ? "*" : "",
+                data->cur_is_floating == 0 ? "*" : "",
                 SvPVX_const(data->substrs[0].str),
                 (IV)data->substrs[0].min_offset
             );
@@ -1047,7 +1049,7 @@ S_debug_studydata(pTHX_ const char *where, scan_data_t *data,
 
             Perl_re_printf(aTHX_
                 " %sFloat: '%s' @ %" IVdf "/%" IVdf,
-                data->longest == 1 ? "*" : "",
+                data->cur_is_floating == 1 ? "*" : "",
                 SvPVX_const(data->substrs[1].str),
                 (IV)data->substrs[1].min_offset,
                 (IV)data->substrs[1].max_offset
@@ -1273,7 +1275,7 @@ S_scan_commit(pTHX_ const RExC_state_t *pRExC_state, scan_data_t *data,
                     SSize_t *minlenp, int is_inf)
 {
     const STRLEN l = CHR_SVLEN(data->last_found);
-    SV * const longest_sv = data->substrs[data->longest].str;
+    SV * const longest_sv = data->substrs[data->cur_is_floating].str;
     const STRLEN old_l = CHR_SVLEN(longest_sv);
     GET_RE_DEBUG_FLAGS_DECL;
 
@@ -1281,7 +1283,7 @@ S_scan_commit(pTHX_ const RExC_state_t *pRExC_state, scan_data_t *data,
 
     if ((l >= old_l) && ((l > old_l) || (data->flags & SF_BEFORE_EOL))) {
        SvSetMagicSV(longest_sv, data->last_found);
-       if (data->longest == 0) { /* fixed */
+       if (data->cur_is_floating == 0) { /* fixed */
            data->substrs[0].min_offset = l ? data->last_start_min : data->pos_min;
            data->substrs[0].max_offset = data->substrs[0].min_offset;
            if (data->flags & SF_BEFORE_EOL)
@@ -4398,7 +4400,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
                    else
                        data->pos_delta += max1 - min1;
                    if (max1 != min1 || is_inf)
-                       data->longest = 1 /*float*/;
+                       data->cur_is_floating = 1;
                }
                min += min1;
                if (delta == SSize_t_MAX
@@ -4845,7 +4847,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
                      * */
                     if (flags & SCF_DO_SUBSTR) {
                         scan_commit(pRExC_state, data, minlenp, is_inf);
-                        data->longest = 1; /* float */
+                        data->cur_is_floating = 1;
                     }
                     is_inf = is_inf_internal = 1;
                     if (flags & SCF_DO_STCLASS_OR) /* Allow everything */
@@ -4973,7 +4975,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
                 }
                 data->pos_delta += min_subtract;
                if (min_subtract) {
-                   data->longest = 1; /* float */
+                   data->cur_is_floating = 1; /* float */
                }
            }
 
@@ -5040,7 +5042,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
                if (flags & SCF_DO_SUBSTR) {
                     scan_commit(pRExC_state, data, minlenp, is_inf);
                     /* Cannot extend fixed substrings */
-                   data->longest = 1; /* float */
+                   data->cur_is_floating = 1; /* float */
                }
                 is_inf = is_inf_internal = 1;
                 scan = regnext(scan);
@@ -5378,7 +5380,7 @@ Perl_re_printf( aTHX_  "LHS=%" UVuf " RHS=%" UVuf "\n",
                                ? SSize_t_MAX
                                : data->pos_min + data->pos_delta - last_chrs;
                        }
-                       data->longest = 1; /* float */
+                       data->cur_is_floating = 1; /* float */
                    }
                    SvREFCNT_dec(last_str);
                }
@@ -5402,7 +5404,7 @@ Perl_re_printf( aTHX_  "LHS=%" UVuf " RHS=%" UVuf "\n",
                if (flags & SCF_DO_SUBSTR) {
                     /* Cannot expect anything... */
                     scan_commit(pRExC_state, data, minlenp, is_inf);
-                   data->longest = 1; /* float */
+                   data->cur_is_floating = 1; /* float */
                }
                is_inf = is_inf_internal = 1;
                if (flags & SCF_DO_STCLASS_OR) {
@@ -5449,7 +5451,7 @@ Perl_re_printf( aTHX_  "LHS=%" UVuf " RHS=%" UVuf "\n",
                 scan_commit(pRExC_state, data, minlenp, is_inf);
                data->pos_min += 1;
                data->pos_delta += 1;
-               data->longest = 1; /* float */
+               data->cur_is_floating = 1; /* float */
            }
        }
        else if (REGNODE_SIMPLE(OP(scan))) {
@@ -5824,7 +5826,7 @@ Perl_re_printf( aTHX_  "LHS=%" UVuf " RHS=%" UVuf "\n",
        {
                if (flags & SCF_DO_SUBSTR) {
                     scan_commit(pRExC_state, data, minlenp, is_inf);
-                   data->longest = 1; /* float */
+                   data->cur_is_floating = 1; /* float */
                }
                is_inf = is_inf_internal = 1;
                if (flags & SCF_DO_STCLASS_OR) /* Allow everything */
@@ -5935,7 +5937,7 @@ Perl_re_printf( aTHX_  "LHS=%" UVuf " RHS=%" UVuf "\n",
                 data->pos_min += min1;
                 data->pos_delta += max1 - min1;
                 if (max1 != min1 || is_inf)
-                    data->longest = 1; /* float */
+                    data->cur_is_floating = 1; /* float */
             }
             min += min1;
             if (delta != SSize_t_MAX)
@@ -5979,7 +5981,7 @@ Perl_re_printf( aTHX_  "LHS=%" UVuf " RHS=%" UVuf "\n",
                data->pos_min += trie->minlen;
                data->pos_delta += (trie->maxlen - trie->minlen);
                if (trie->maxlen != trie->minlen)
-                   data->longest = 1; /* float */
+                   data->cur_is_floating = 1; /* float */
            }
            if (trie->jump) /* no more substrings -- for now /grr*/
                flags &= ~SCF_DO_SUBSTR;
@@ -7561,7 +7563,7 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
        data.substrs[0].str = newSVpvs("");
        data.substrs[1].str = newSVpvs("");
        data.last_found = newSVpvs("");
-       data.longest = 0; /* fixed */
+       data.cur_is_floating = 0; /* initially any found substring is fixed */
        ENTER_with_name("study_chunk");
        SAVEFREESV(data.substrs[0].str);
        SAVEFREESV(data.substrs[1].str);
@@ -7587,7 +7589,7 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
         CHECK_RESTUDY_GOTO_butfirst(LEAVE_with_name("study_chunk"));
 
 
-       if ( RExC_npar == 1 && data.longest == 0 /*fixed */
+       if ( RExC_npar == 1 && !data.cur_is_floating
             && data.last_start_min == 0 && data.last_end > 0
             && !RExC_seen_zerolen
              && !(RExC_seen & REG_VERBARG_SEEN)