diff options
author | Nicholas Clark <nick@ccl4.org> | 2008-01-02 12:06:05 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-01-02 12:06:05 +0000 |
commit | 07bc277f32c1d7aff237dd3f55d558b5d4b93314 (patch) | |
tree | 86a4a36156c095e618d07cc5cb6d35875496d75f /regexp.h | |
parent | 3d66076ad00dfe06380fb774b92fb59dc07fe4ec (diff) | |
download | perl-07bc277f32c1d7aff237dd3f55d558b5d4b93314.tar.gz |
Wrap all deferences of struct regexp* in macros RX_*() [and for
regcomp.c and regexec.c RXp_* where necessary] so that in future we
can maintain source compatibility when we add an extra level of
dereferencing.
p4raw-id: //depot/perl@32802
Diffstat (limited to 'regexp.h')
-rw-r--r-- | regexp.h | 57 |
1 files changed, 41 insertions, 16 deletions
@@ -341,29 +341,53 @@ and check for NULL. */ #define RX_HAS_CUTGROUP(prog) ((prog)->intflags & PREGf_CUTGROUP_SEEN) -#define RX_MATCH_TAINTED(prog) ((prog)->extflags & RXf_TAINTED_SEEN) -#define RX_MATCH_TAINTED_on(prog) ((prog)->extflags |= RXf_TAINTED_SEEN) -#define RX_MATCH_TAINTED_off(prog) ((prog)->extflags &= ~RXf_TAINTED_SEEN) +#define RXp_MATCH_TAINTED(prog) (RXp_EXTFLAGS(prog) & RXf_TAINTED_SEEN) +#define RX_MATCH_TAINTED(prog) (RX_EXTFLAGS(prog) & RXf_TAINTED_SEEN) +#define RX_MATCH_TAINTED_on(prog) (RX_EXTFLAGS(prog) |= RXf_TAINTED_SEEN) +#define RX_MATCH_TAINTED_off(prog) (RX_EXTFLAGS(prog) &= ~RXf_TAINTED_SEEN) #define RX_MATCH_TAINTED_set(prog, t) ((t) \ ? RX_MATCH_TAINTED_on(prog) \ : RX_MATCH_TAINTED_off(prog)) -#define RX_MATCH_COPIED(prog) ((prog)->extflags & RXf_COPY_DONE) -#define RX_MATCH_COPIED_on(prog) ((prog)->extflags |= RXf_COPY_DONE) -#define RX_MATCH_COPIED_off(prog) ((prog)->extflags &= ~RXf_COPY_DONE) +#define RXp_MATCH_COPIED(prog) (RXp_EXTFLAGS(prog) & RXf_COPY_DONE) +#define RX_MATCH_COPIED(prog) (RX_EXTFLAGS(prog) & RXf_COPY_DONE) +#define RXp_MATCH_COPIED_on(prog) (RXp_EXTFLAGS(prog) |= RXf_COPY_DONE) +#define RX_MATCH_COPIED_on(prog) (RX_EXTFLAGS(prog) |= RXf_COPY_DONE) +#define RXp_MATCH_COPIED_off(prog) (RXp_EXTFLAGS(prog) &= ~RXf_COPY_DONE) +#define RX_MATCH_COPIED_off(prog) (RX_EXTFLAGS(prog) &= ~RXf_COPY_DONE) #define RX_MATCH_COPIED_set(prog,t) ((t) \ ? RX_MATCH_COPIED_on(prog) \ : RX_MATCH_COPIED_off(prog)) -/* For source compatibility. We used to store these explicitly. */ -#define RX_PRECOMP(prog) ((prog)->wrapped + (prog)->pre_prefix) +#define RXp_PRECOMP(rx) ((rx)->wrapped + (rx)->pre_prefix) /* 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) ((prog)->wraplen - (prog)->pre_prefix - 1) -#define RX_WRAPPED(prog) ((prog)->wrapped) -#define RX_WRAPLEN(prog) ((prog)->wraplen) +#define RXp_PRELEN(rx) ((rx)->wraplen - (rx)->pre_prefix - 1) +#define RXp_WRAPPED(rx) ((rx)->wrapped) +#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) ((prog)->wrapped + (prog)->pre_prefix) +#define RX_PRELEN(prog) ((prog)->wraplen - (prog)->pre_prefix - 1) +#define RX_WRAPPED(prog) ((prog)->wrapped) +#define RX_WRAPLEN(prog) ((prog)->wraplen) +#define RX_CHECK_SUBSTR(prog) ((prog)->check_substr) +#define RX_EXTFLAGS(prog) ((prog)->extflags) +#define RX_REFCNT(prog) ((prog)->refcnt) +#define RX_ENGINE(prog) ((prog)->engine) +#define RX_SUBBEG(prog) ((prog)->subbeg) +#define RX_OFFS(prog) ((prog)->offs) +#define RX_NPARENS(prog) ((prog)->nparens) +#define RX_SUBLEN(prog) ((prog)->sublen) +#define RX_SUBBEG(prog) ((prog)->subbeg) +#define RX_MINLEN(prog) ((prog)->minlen) +#define RX_MINLENRET(prog) ((prog)->minlenret) +#define RX_GOFS(prog) ((prog)->gofs) +#define RX_LASTPAREN(prog) ((prog)->lastparen) +#define RX_LASTCLOSEPAREN(prog) ((prog)->lastcloseparen) +#define RX_SEEN_EVALS(prog) ((prog)->seen_evals) #endif /* PLUGGABLE_RE_EXTENSION */ @@ -375,20 +399,21 @@ and check for NULL. SV_CHECK_THINKFIRST_COW_DROP(rx->saved_copy); \ } \ if (RX_MATCH_COPIED(rx)) { \ - Safefree(rx->subbeg); \ + Safefree(RX_SUBBEG(rx)); \ RX_MATCH_COPIED_off(rx); \ }} STMT_END #else #define RX_MATCH_COPY_FREE(rx) \ STMT_START {if (RX_MATCH_COPIED(rx)) { \ - Safefree(rx->subbeg); \ + Safefree(RX_SUBBEG(rx)); \ RX_MATCH_COPIED_off(rx); \ }} STMT_END #endif -#define RX_MATCH_UTF8(prog) ((prog)->extflags & RXf_MATCH_UTF8) -#define RX_MATCH_UTF8_on(prog) ((prog)->extflags |= RXf_MATCH_UTF8) -#define RX_MATCH_UTF8_off(prog) ((prog)->extflags &= ~RXf_MATCH_UTF8) +#define RXp_MATCH_UTF8(prog) (RXp_EXTFLAGS(prog) & RXf_MATCH_UTF8) +#define RX_MATCH_UTF8(prog) (RX_EXTFLAGS(prog) & RXf_MATCH_UTF8) +#define RX_MATCH_UTF8_on(prog) (RX_EXTFLAGS(prog) |= RXf_MATCH_UTF8) +#define RX_MATCH_UTF8_off(prog) (RX_EXTFLAGS(prog) &= ~RXf_MATCH_UTF8) #define RX_MATCH_UTF8_set(prog, t) ((t) \ ? (RX_MATCH_UTF8_on(prog), (PL_reg_match_utf8 = 1)) \ : (RX_MATCH_UTF8_off(prog), (PL_reg_match_utf8 = 0))) |