From: Gurusamy Sarathy Date: Tue, 28 Dec 1999 03:44:10 +0000 (+0000) Subject: fix for /(^|a)b/ breakage from Ilya Zakharevich X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=de0c8cb881313fb53ccecc309c3a182787a8a527;p=p5sagit%2Fp5-mst-13.2.git fix for /(^|a)b/ breakage from Ilya Zakharevich p4raw-id: //depot/perl@4724 --- diff --git a/regcomp.c b/regcomp.c index f935190..3e7c012 100644 --- a/regcomp.c +++ b/regcomp.c @@ -545,9 +545,21 @@ S_study_chunk(pTHX_ regnode **scanp, I32 *deltap, regnode *last, scan_data_t *da } } else if (flags & SCF_DO_STCLASS_AND) { - cl_and(data->start_class, &accum); - if (min1) + if (min1) { + cl_and(data->start_class, &accum); flags &= ~SCF_DO_STCLASS; + } + else { + /* Switch to OR mode: cache the old value of + * data->start_class */ + StructCopy(data->start_class, &and_with, + struct regnode_charclass_class); + flags &= ~SCF_DO_STCLASS_AND; + StructCopy(&accum, data->start_class, + struct regnode_charclass_class); + flags |= SCF_DO_STCLASS_OR; + data->start_class->flags |= ANYOF_EOS; + } } } else if (code == BRANCHJ) /* single branch is optimized. */ diff --git a/t/op/re_tests b/t/op/re_tests index e957609..d506e6e 100644 --- a/t/op/re_tests +++ b/t/op/re_tests @@ -749,3 +749,4 @@ tt+$ xxxtt y - - '(\.c(pp|xx|c)?$)'i IO.c y $1 .c ^([a-z]:) C:/ n - - '^\S\s+aa$'m \nx aa y - - +(^|a)b ab y - -