diff options
author | David Mitchell <davem@iabyn.com> | 2017-06-30 09:55:32 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-07-02 21:24:13 +0100 |
commit | 6e12f832ea033e57dcca8b75bd3a1d75389074c6 (patch) | |
tree | 8f5dcfb0fdedfa96eb4df394c2a4a65833bbba5b /regcomp.c | |
parent | 11683ecb8678a801ac36414c33c4f730f2c18cdf (diff) | |
download | perl-6e12f832ea033e57dcca8b75bd3a1d75389074c6.tar.gz |
regcomp: set fixed max_offset to min_offset
previously scan_data_t had the three fields
offset_fixed
offset_float_min
offset_float_max
a few commits ago that was converted into a 2 element array (for fixed
and float), each with the fields
min_offset
max_offset
where the max_offset was unused in fixed (substrs[0]) case.
Instead, set it equal to min_offset
This makes the fixed and float code paths more similar.
At the same time expand a few of the 'float_max_offset' type macros
to make it clearer what's going on.
Diffstat (limited to 'regcomp.c')
-rw-r--r-- | regcomp.c | 31 |
1 files changed, 23 insertions, 8 deletions
@@ -404,6 +404,7 @@ struct RExC_state_t { Only used for floating strings. This is the rightmost point that the string can appear at. If set to SSize_t_MAX it indicates that the string can occur infinitely far to the right. + For fixed strings, it is equal to min_offset. - minlenp A pointer to the minimum number of characters of the pattern that the @@ -1282,6 +1283,7 @@ S_scan_commit(pTHX_ const RExC_state_t *pRExC_state, scan_data_t *data, SvSetMagicSV(longest_sv, data->last_found); if (data->longest == 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) data->substrs[0].flags |= (data->flags & SF_BEFORE_EOL); else @@ -5770,6 +5772,7 @@ Perl_re_printf( aTHX_ "LHS=%" UVuf " RHS=%" UVuf "\n", if (data_fake.substrs[0].minlenp != minlenp) { data->substrs[0].min_offset = data_fake.substrs[0].min_offset; + data->substrs[0].max_offset = data_fake.substrs[0].max_offset; data->substrs[0].minlenp = data_fake.substrs[0].minlenp; data->substrs[0].lookbehind += scan->flags; } @@ -7606,10 +7609,13 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count, &(data.substrs[1]), longest_float_length)) { - r->float_min_offset = data.substrs[1].min_offset - data.substrs[1].lookbehind; - r->float_max_offset = data.substrs[1].max_offset; + r->substrs->data[1].min_offset = + data.substrs[1].min_offset - data.substrs[1].lookbehind; + + r->substrs->data[1].max_offset = data.substrs[1].max_offset; if (data.substrs[1].max_offset < SSize_t_MAX) /* Don't offset infinity */ - r->float_max_offset -= data.substrs[1].lookbehind; + r->substrs->data[1].max_offset -= data.substrs[1].lookbehind; + SvREFCNT_inc_simple_void_NN(data.substrs[1].str); } else { @@ -7626,7 +7632,15 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count, &(data.substrs[0]), longest_fixed_length)) { - r->anchored_offset = data.substrs[0].min_offset - data.substrs[0].lookbehind; + r->substrs->data[0].min_offset = + data.substrs[0].min_offset - data.substrs[0].lookbehind; + /* XXX this calc isn't necessary for anchored, but is done + * for consistency with float code path */ + r->substrs->data[0].max_offset = data.substrs[0].max_offset; + + if (data.substrs[0].max_offset < SSize_t_MAX) /* Don't offset infinity */ + r->substrs->data[0].max_offset -= data.substrs[0].lookbehind; + SvREFCNT_inc_simple_void_NN(data.substrs[0].str); } else { @@ -7669,7 +7683,8 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count, r->check_end_shift = r->anchored_end_shift; r->check_substr = r->anchored_substr; r->check_utf8 = r->anchored_utf8; - r->check_offset_min = r->check_offset_max = r->anchored_offset; + r->check_offset_min = r->substrs->data[0].min_offset; + r->check_offset_max = r->substrs->data[0].max_offset; if (r->intflags & (PREGf_ANCH_SBOL|PREGf_ANCH_GPOS)) r->intflags |= PREGf_NOSCAN; } @@ -7678,15 +7693,15 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count, r->check_end_shift = r->float_end_shift; r->check_substr = r->float_substr; r->check_utf8 = r->float_utf8; - r->check_offset_min = r->float_min_offset; - r->check_offset_max = r->float_max_offset; + r->check_offset_min = r->substrs->data[1].min_offset; + r->check_offset_max = r->substrs->data[1].max_offset; } + if ((r->check_substr || r->check_utf8) ) { r->extflags |= RXf_USE_INTUIT; if (SvTAIL(r->check_substr ? r->check_substr : r->check_utf8)) r->extflags |= RXf_INTUIT_TAIL; } - r->substrs->data[0].max_offset = r->substrs->data[0].min_offset; /* XXX Unneeded? dmq (shouldn't as this is handled elsewhere) if ( (STRLEN)minlen < longest_float_length ) |