This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Get rid of meaningless test
authorKarl Williamson <khw@cpan.org>
Mon, 2 Mar 2020 17:15:25 +0000 (10:15 -0700)
committerKarl Williamson <khw@cpan.org>
Mon, 2 Mar 2020 23:17:58 +0000 (16:17 -0700)
Since ea3daa5, parts of this test became nonsensical as max_offset
cannot be larger than OPTIMIZE_INFIINITY.  (I don't know why compilers
didn't say that this branch is always false.)

Hugo van der Sanden suggested something like this commit to keep the
still valid part of the test.

regcomp.c

index fbd0df2..169369c 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -1491,14 +1491,14 @@ S_scan_commit(pTHX_ const RExC_state_t *pRExC_state, scan_data_t *data,
        if (!i) /* fixed */
            data->substrs[0].max_offset = data->substrs[0].min_offset;
        else { /* float */
-           data->substrs[1].max_offset = (l
+           data->substrs[1].max_offset =
+                      (is_inf)
+                       ? OPTIMIZE_INFTY
+                       : (l
                           ? data->last_start_max
                           : (data->pos_delta > OPTIMIZE_INFTY - data->pos_min
                                         ? OPTIMIZE_INFTY
                                         : data->pos_min + data->pos_delta));
-           if (is_inf
-                || (STRLEN)data->substrs[1].max_offset > (STRLEN)OPTIMIZE_INFTY)
-               data->substrs[1].max_offset = OPTIMIZE_INFTY;
         }
 
         if (data->flags & SF_BEFORE_EOL)