In perl.git, the branch blead has been updated

<https://perl5.git.perl.org/perl.git/commitdiff/4288c5b93b3823465d8a11e569547afd41b5d1b8?hp=3f4fa0ec3529fd97b13e5f6deb3de59bb9dc0363>

- Log -----------------------------------------------------------------
commit 4288c5b93b3823465d8a11e569547afd41b5d1b8
Author: Karl Williamson <k...@cpan.org>
Date:   Sun Sep 30 12:10:17 2018 -0600

    Change REG_INFTY to 2**16-1, instead of 2**15-1
    
    This commit doubles the upper limit that unbounded regular expression
    quantifiers can match up to.  Things like {m,} "+" and "*" now can match
    up to U16_MAX times.
    
    We probably should make this a 32 bit value, but doing this doubling was
    easy and has fewer potential implications.
    
    See http://nntp.perl.org/group/perl.perl5.porters/251413 and
    followups

-----------------------------------------------------------------------

Summary of changes:
 pod/perldelta.pod |  6 ++++++
 regcomp.h         | 14 +++++++-------
 t/re/pat.t        |  2 +-
 t/re/reg_mesg.t   |  2 +-
 4 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 1da8804404..9f6683f23f 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -27,6 +27,12 @@ here, but most should go in the L</Performance Enhancements> 
section.
 
 [ List each enhancement as a =head2 entry ]
 
+=head2 The maximum number of times a pattern can match has been doubled
+to 65535
+
+This means if you specify C<qr/a+/> that there can be anywhere from 1
+through 65535 C<"a">'s in a row, instead of 32267 as previously.
+
 =head1 Security
 
 XXX Any security-related notices go here.  In particular, any security
diff --git a/regcomp.h b/regcomp.h
index ea3a0661d9..0c52226921 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -265,22 +265,22 @@ struct regnode_ssc {
    Impose a limit of REG_INFTY on various pattern matching operations
    to limit stack growth and to avoid "infinite" recursions.
 */
-/* The default size for REG_INFTY is I16_MAX, which is the same as
-   SHORT_MAX (see perl.h).  Unfortunately I16 isn't necessarily 16 bits
-   (see handy.h).  On the Cray C90, sizeof(short)==4 and hence I16_MAX is
-   ((1<<31)-1), while on the Cray T90, sizeof(short)==8 and I16_MAX is
-   ((1<<63)-1).  To limit stack growth to reasonable sizes, supply a
+/* The default size for REG_INFTY is U16_MAX, which is the same as
+   USHORT_MAX (see perl.h).  Unfortunately U16 isn't necessarily 16 bits
+   (see handy.h).  On the Cray C90, sizeof(short)==4 and hence U16_MAX is
+   ((1<<32)-1), while on the Cray T90, sizeof(short)==8 and U16_MAX is
+   ((1<<64)-1).  To limit stack growth to reasonable sizes, supply a
    smaller default.
        --Andy Dougherty  11 June 1998
 */
 #if SHORTSIZE > 2
 #  ifndef REG_INFTY
-#    define REG_INFTY ((1<<15)-1)
+#    define REG_INFTY ((1<<16)-1)
 #  endif
 #endif
 
 #ifndef REG_INFTY
-#  define REG_INFTY I16_MAX
+#  define REG_INFTY U16_MAX
 #endif
 
 #define ARG_VALUE(arg) (arg)
diff --git a/t/re/pat.t b/t/re/pat.t
index 1d98fe77d7..3e15d8c583 100644
--- a/t/re/pat.t
+++ b/t/re/pat.t
@@ -319,7 +319,7 @@ sub run_tests {
 
        #  Defaults assumed if this fails
        eval { require Config; };
-        $::reg_infty   = $Config::Config{reg_infty} // 32767;
+        $::reg_infty   = $Config::Config{reg_infty} // 65535;
         $::reg_infty_m = $::reg_infty - 1;
         $::reg_infty_p = $::reg_infty + 1;
         $::reg_infty_m = $::reg_infty_m;   # Suppress warning.
diff --git a/t/re/reg_mesg.t b/t/re/reg_mesg.t
index 3ab9a69e56..36b674746f 100644
--- a/t/re/reg_mesg.t
+++ b/t/re/reg_mesg.t
@@ -102,7 +102,7 @@ sub mark_as_utf8 {
     return @ret;
 }
 
-my $inf_m1 = ($Config::Config{reg_infty} || 32767) - 1;
+my $inf_m1 = ($Config::Config{reg_infty} || 65535) - 1;
 my $inf_p1 = $inf_m1 + 2;
 
 my $B_hex = sprintf("\\x%02X", ord "B");

-- 
Perl5 Master Repository

Reply via email to