This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
make REG_INFTY default to something saner when sizeof(short) > 2
authorAndy Dougherty <doughera@lafayette.edu>
Thu, 11 Jun 1998 11:50:07 +0000 (07:50 -0400)
committerGurusamy Sarathy <gsar@cpan.org>
Thu, 11 Jun 1998 17:42:07 +0000 (17:42 +0000)
Message-Id: <Pine.SUN.3.96.980611114241.18493H-100000@newton.phys>
Subject: Re: [PATCH for tests] Regexp fails on long string

p4raw-id: //depot/perl@1119

regcomp.h

index 7b0a12e..c9742e8 100644 (file)
--- a/regcomp.h
+++ b/regcomp.h
@@ -271,7 +271,25 @@ struct regnode_2 {
 
 #endif 
 
-#ifndef
+/* XXX fix this description.
+   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
+   smaller default.
+       --Andy Dougherty  11 June 1998
+*/
+#if SHORTSIZE > 2
+#  ifndef REG_INFTY
+#    define REG_INFTY ((1<<15)-1)
+#  endif
+#endif
+
+#ifndef REG_INFTY
 #  define REG_INFTY I16_MAX
 #endif
 
@@ -453,4 +471,3 @@ const static char reg_off_by_arg[] = {
 #define REG_SEEN_LOOKBEHIND    2
 #define REG_SEEN_GPOS          4
 #define REG_SEEN_EVAL          8
-