summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2006-04-18 17:03:15 +0000
committerDave Mitchell <davem@fdisolutions.com>2006-04-18 17:03:15 +0000
commit7409bbd3a4107bc6a3bbf2564b61619917eefa19 (patch)
tree968f3321ac9c2745b83800842d2cf5e0e8f1ab43 /regexec.c
parent55585837ec93736f56724c4bcdd0cdd335912e71 (diff)
downloadperl-7409bbd3a4107bc6a3bbf2564b61619917eefa19.tar.gz
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
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/regexec.c b/regexec.c
index 50f164ff89..53ec117bd0 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<<POSCACHE_SEEN))) \
- PL_reg_poscache[0] |= (1<<POSCACHE_SUCCESS) || (1<<POSCACHE_SEEN); \
- else if (!(PL_reg_poscache[0] & (1<<POSCACHE_SUCCESS))) { \
+ if (!(PL_reg_poscache[0] & (1<<POSCACHE_SEEN))) { \
+ PL_reg_poscache[0] |= (1<<POSCACHE_SUCCESS) | (1<<POSCACHE_SEEN); \
+ PL_reg_poscache[st->u.whilem.cache_offset] |= (1<<st->u.whilem.cache_bit); \
+ } \
+ else if (PL_reg_poscache[0] & (1<<POSCACHE_SUCCESS)) { \
+ PL_reg_poscache[st->u.whilem.cache_offset] |= (1<<st->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<<POSCACHE_SEEN))) \
+ if (!(PL_reg_poscache[0] & (1<<POSCACHE_SEEN))) { \
PL_reg_poscache[0] |= (1<<POSCACHE_SEEN); \
- else if ((PL_reg_poscache[0] & (1<<POSCACHE_SUCCESS))) { \
+ PL_reg_poscache[st->u.whilem.cache_offset] |= (1<<st->u.whilem.cache_bit); \
+ } \
+ else if (!(PL_reg_poscache[0] & (1<<POSCACHE_SUCCESS))) { \
+ PL_reg_poscache[st->u.whilem.cache_offset] |= (1<<st->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<<st->u.whilem.cache_bit);
}
}