From: Andy Dougherty Date: Thu, 11 Jun 1998 11:50:07 +0000 (-0400) Subject: make REG_INFTY default to something saner when sizeof(short) > 2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9c7e81e8284418a8170662b2b8ec04f26145e65e;p=p5sagit%2Fp5-mst-13.2.git make REG_INFTY default to something saner when sizeof(short) > 2 Message-Id: Subject: Re: [PATCH for tests] Regexp fails on long string p4raw-id: //depot/perl@1119 --- diff --git a/regcomp.h b/regcomp.h index 7b0a12e..c9742e8 100644 --- 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 -