From: Dave Mitchell Date: Tue, 18 Apr 2006 17:03:15 +0000 (+0000) Subject: regmatch: fix a || vs | typo in CACHEsayYES and add a test from Hugo. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7409bbd3a4107bc6a3bbf2564b61619917eefa19;p=p5sagit%2Fp5-mst-13.2.git regmatch: fix a || vs | typo in CACHEsayYES and add a test from Hugo. Also defer altering the cache bit until CACHEsayYES/NO is called p4raw-id: //depot/perl@27893 --- diff --git a/regexec.c b/regexec.c index 50f164f..53ec117 100644 --- a/regexec.c +++ b/regexec.c @@ -2242,11 +2242,17 @@ typedef union re_unwind_t { #define POSCACHE_SUCCESS 0 /* caching success rather than failure */ #define POSCACHE_SEEN 1 /* we know what we're caching */ #define POSCACHE_START 2 /* the real cache: this bit maps to pos 0 */ + #define CACHEsayYES STMT_START { \ if (st->u.whilem.cache_offset | st->u.whilem.cache_bit) { \ - if (!(PL_reg_poscache[0] & (1<u.whilem.cache_offset] |= (1<u.whilem.cache_bit); \ + } \ + else if (PL_reg_poscache[0] & (1<u.whilem.cache_offset] |= (1<u.whilem.cache_bit); \ + } \ + else { \ /* cache records failure, but this is success */ \ DEBUG_r( \ PerlIO_printf(Perl_debug_log, \ @@ -2258,11 +2264,17 @@ typedef union re_unwind_t { } \ sayYES; \ } STMT_END + #define CACHEsayNO STMT_START { \ if (st->u.whilem.cache_offset | st->u.whilem.cache_bit) { \ - if (!(PL_reg_poscache[0] & (1<u.whilem.cache_offset] |= (1<u.whilem.cache_bit); \ + } \ + else if (!(PL_reg_poscache[0] & (1<u.whilem.cache_offset] |= (1<u.whilem.cache_bit); \ + } \ + else { \ /* cache records success, but this is failure */ \ DEBUG_r( \ PerlIO_printf(Perl_debug_log, \ @@ -3690,7 +3702,6 @@ S_regmatch(pTHX_ const regmatch_info *reginfo, regnode *prog) /* cache records failure */ sayNO_SILENT; } - PL_reg_poscache[st->u.whilem.cache_offset] |= (1<u.whilem.cache_bit); } } diff --git a/t/op/re_tests b/t/op/re_tests index 4b9ae61..a87f81c 100644 --- a/t/op/re_tests +++ b/t/op/re_tests @@ -961,3 +961,4 @@ x(?# x c - Sequence (?#... not terminated ^(.)\s+.$(?(1)) A B y $1 A # [perl #37688] (?:r?)*?r|(.{2,4}) abcde y $1 abcd (?!)+?|(.{2,4}) abcde y $1 abcd +^(a*?)(?!(a{6}|a{5})*$) aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa y $+[1] 12 # super-linear cache bug may return 18