From: Nicholas Clark Date: Sat, 5 Jan 2008 14:43:55 +0000 (+0000) Subject: Abolish RXp_PRELEN(rx) and RXp_WRAPLEN() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5509d87acdf3aa5ea39fe6c8e59a42b46a5141cd;p=p5sagit%2Fp5-mst-13.2.git Abolish RXp_PRELEN(rx) and RXp_WRAPLEN() Fix up some uses of RX_* macros in the block conditionally compiled with STUPID_PATTERN_CHECKS. p4raw-id: //depot/perl@32843 --- diff --git a/regcomp.c b/regcomp.c index b1a8cb0..3c9915f 100644 --- a/regcomp.c +++ b/regcomp.c @@ -4290,12 +4290,12 @@ redo_first_pass: >> RXf_PMf_STD_PMMOD_SHIFT); const char *fptr = STD_PAT_MODS; /*"msix"*/ char *p; - RXp_WRAPLEN(r) = plen + has_minus + has_p + has_runon + RX_WRAPLEN(rx) = plen + has_minus + has_p + has_runon + (sizeof(STD_PAT_MODS) - 1) + (sizeof("(?:)") - 1); - p = sv_grow(rx, RXp_WRAPLEN(r) + 1); - SvCUR_set(rx, RXp_WRAPLEN(r)); + p = sv_grow(rx, RX_WRAPLEN(rx) + 1); + SvCUR_set(rx, RX_WRAPLEN(rx)); SvPOK_on(rx); *p++='('; *p++='?'; if (has_p) @@ -4797,17 +4797,17 @@ reStudy: r->paren_names = NULL; #ifdef STUPID_PATTERN_CHECKS - if (RX_PRELEN(r) == 0) + if (RX_PRELEN(rx) == 0) r->extflags |= RXf_NULL; - if (r->extflags & RXf_SPLIT && RX_PRELEN(r) == 1 && RX_PRECOMP(rx)[0] == ' ') + if (r->extflags & RXf_SPLIT && RX_PRELEN(rx) == 1 && RX_PRECOMP(rx)[0] == ' ') /* XXX: this should happen BEFORE we compile */ r->extflags |= (RXf_SKIPWHITE|RXf_WHITE); - else if (RX_PRELEN(r) == 3 && memEQ("\\s+", RXp_PRECOMP(r), 3)) + else if (RX_PRELEN(rx) == 3 && memEQ("\\s+", RX_PRECOMP(rx), 3)) r->extflags |= RXf_WHITE; - else if (RX_PRELEN(r) == 1 && RXp_PRECOMP(r)[0] == '^') + else if (RX_PRELEN(rx) == 1 && RXp_PRECOMP(rx)[0] == '^') r->extflags |= RXf_START_ONLY; #else - if (r->extflags & RXf_SPLIT && RXp_PRELEN(r) == 1 && RX_PRECOMP(rx)[0] == ' ') + if (r->extflags & RXf_SPLIT && RX_PRELEN(rx) == 1 && RX_PRECOMP(rx)[0] == ' ') /* XXX: this should happen BEFORE we compile */ r->extflags |= (RXf_SKIPWHITE|RXf_WHITE); else { @@ -9264,7 +9264,7 @@ Perl_regfree_internal(pTHX_ REGEXP * const rx) { SV *dsv= sv_newmortal(); RE_PV_QUOTED_DECL(s, (r->extflags & RXf_UTF8), - dsv, RX_PRECOMP(rx), RXp_PRELEN(r), 60); + dsv, RX_PRECOMP(rx), RX_PRELEN(rx), 60); PerlIO_printf(Perl_debug_log,"%sFreeing REx:%s %s\n", PL_colors[4],PL_colors[5],s); } diff --git a/regexp.h b/regexp.h index fd2431a..bae20d5 100644 --- a/regexp.h +++ b/regexp.h @@ -356,18 +356,16 @@ and check for NULL. ? RX_MATCH_COPIED_on(prog) \ : RX_MATCH_COPIED_off(prog)) -/* FIXME? Are we hardcoding too much here and constraining plugin extension - writers? Specifically, the value 1 assumes that the wrapped version always - has exactly one character at the end, a ')'. Will that always be true? */ -#define RXp_PRELEN(rx) ((rx)->wraplen - (rx)->pre_prefix - 1) -#define RXp_WRAPLEN(rx) ((rx)->wraplen) #define RXp_EXTFLAGS(rx) ((rx)->extflags) /* For source compatibility. We used to store these explicitly. */ #define RX_PRECOMP(prog) (RX_WRAPPED(prog) + ((struct regexp *)SvANY(prog))->pre_prefix) -#define RX_PRELEN(prog) RXp_PRELEN((struct regexp *)SvANY(prog)) +/* FIXME? Are we hardcoding too much here and constraining plugin extension + writers? Specifically, the value 1 assumes that the wrapped version always + has exactly one character at the end, a ')'. Will that always be true? */ +#define RX_PRELEN(prog) (RX_WRAPLEN(prog) - ((struct regexp *)SvANY(prog))->pre_prefix - 1) #define RX_WRAPPED(prog) SvPVX(prog) -#define RX_WRAPLEN(prog) RXp_WRAPLEN((struct regexp *)SvANY(prog)) +#define RX_WRAPLEN(prog) (((struct regexp *)SvANY(prog))->wraplen) #define RX_CHECK_SUBSTR(prog) (((struct regexp *)SvANY(prog))->check_substr) #define RX_EXTFLAGS(prog) RXp_EXTFLAGS((struct regexp *)SvANY(prog)) #define RX_REFCNT(prog) SvREFCNT(prog)