diff options
-rw-r--r-- | op.h | 3 | ||||
-rw-r--r-- | op_reg_common.h | 42 | ||||
-rw-r--r-- | regexp.h | 18 |
3 files changed, 38 insertions, 25 deletions
@@ -396,9 +396,6 @@ struct pmop { # error Too many PMf_ bits used. See above and regnodes.h for any spare in middle #endif -/* mask of bits that need to be transfered to re->extflags */ -#define PMf_COMPILETIME (PMf_MULTILINE|PMf_SINGLELINE|PMf_LOCALE|PMf_FOLD|PMf_EXTENDED|PMf_KEEPCOPY) - #ifdef USE_ITHREADS # define PmopSTASHPV(o) \ diff --git a/op_reg_common.h b/op_reg_common.h index b6a4f75f5f..d4e39873e1 100644 --- a/op_reg_common.h +++ b/op_reg_common.h @@ -10,18 +10,33 @@ */ /* These defines are used in both op.h and regexp.h The definitions use the - * shift form so that ext/B/defsubs_h.PL will pick them up */ -#define RXf_PMf_MULTILINE (1 << 0) /* /m */ -#define RXf_PMf_SINGLELINE (1 << 1) /* /s */ -#define RXf_PMf_FOLD (1 << 2) /* /i */ -#define RXf_PMf_EXTENDED (1 << 3) /* /x */ -#define RXf_PMf_KEEPCOPY (1 << 4) /* /p */ -#define RXf_PMf_LOCALE (1 << 5) + * shift form so that ext/B/defsubs_h.PL will pick them up. + * + * Data structures used in the two headers have common fields, and in fact one + * is copied onto the other. This makes it easy to keep them in sync */ + +/* This tells where the first of these bits is. Setting it to 0 saved cycles + * and memory. I (khw) think the code will work if changed back, but haven't + * tested it */ +#define RXf_PMf_STD_PMMOD_SHIFT 0 + +/* The bits need to be ordered so that the msix are contiguous starting at bit + * RXf_PMf_STD_PMMOD_SHIFT, followed by the p. See STD_PAT_MODS and + * INT_PAT_MODS in regexp.h for the reason contiguity is needed */ +#define RXf_PMf_MULTILINE (1 << (RXf_PMf_STD_PMMOD_SHIFT+0)) /* /m */ +#define RXf_PMf_SINGLELINE (1 << (RXf_PMf_STD_PMMOD_SHIFT+1)) /* /s */ +#define RXf_PMf_FOLD (1 << (RXf_PMf_STD_PMMOD_SHIFT+2)) /* /i */ +#define RXf_PMf_EXTENDED (1 << (RXf_PMf_STD_PMMOD_SHIFT+3)) /* /x */ +#define RXf_PMf_KEEPCOPY (1 << (RXf_PMf_STD_PMMOD_SHIFT+4)) /* /p */ +#define RXf_PMf_LOCALE (1 << (RXf_PMf_STD_PMMOD_SHIFT+5)) /* Next available bit after the above. Name begins with '_' so won't be * exported by B */ -#define _RXf_PMf_SHIFT_NEXT 6 +#define _RXf_PMf_SHIFT_NEXT (RXf_PMf_STD_PMMOD_SHIFT+6) +/* Mask of the above bits. These need to be transferred from op_pmflags to + * re->extflags during compilation */ +#define RXf_PMf_COMPILETIME (RXf_PMf_MULTILINE|RXf_PMf_SINGLELINE|RXf_PMf_LOCALE|RXf_PMf_FOLD|RXf_PMf_EXTENDED|RXf_PMf_KEEPCOPY) /* These copies need to be numerical or defsubs_h.PL won't know about them. */ #define PMf_MULTILINE 1<<0 @@ -34,3 +49,14 @@ #if PMf_MULTILINE != RXf_PMf_MULTILINE || PMf_SINGLELINE != RXf_PMf_SINGLELINE || PMf_FOLD != RXf_PMf_FOLD || PMf_EXTENDED != RXf_PMf_EXTENDED || PMf_KEEPCOPY != RXf_PMf_KEEPCOPY || PMf_LOCALE != RXf_PMf_LOCALE # error RXf_PMf defines are wrong #endif + +#define PMf_COMPILETIME RXf_PMf_COMPILETIME + +/* Error check that haven't left something out of this. This isn't done + * directly in the #define because doing so confuses regcomp.pl. + * (2**n - 1) is n 1 bits, so the below gets the contiguous bits between the + * beginning and ending shifts */ +#if RXf_PMf_COMPILETIME != (((1 << (_RXf_PMf_SHIFT_NEXT))-1) \ + & (~((1 << RXf_PMf_STD_PMMOD_SHIFT)-1))) +# error RXf_PMf_COMPILETIME is invalid +#endif @@ -8,8 +8,6 @@ * */ -#include "op_reg_common.h" - /* * Definitions etc. for regexp(3) routines. * @@ -220,25 +218,17 @@ and check for NULL. /* Flags stored in regexp->extflags * These are used by code external to the regexp engine * - * Note that flags starting with RXf_PMf_ have exact equivalents - * stored in op_pmflags and which are defined in op.h, they are defined - * numerically here only for clarity. + * Note that the flags whose names start with RXf_PMf_ are defined in + * op_reg_common.h, being copied from the parallel flags of op_pmflags * * NOTE: if you modify any RXf flags you should run regen.pl or regcomp.pl * so that regnodes.h is updated with the changes. * */ -/* 0x3F of extflags is used by (RXf_)PMf_COMPILETIME - * If you change these you need to change the equivalent flags in op.h, and - * vice versa. These need to be ordered so that the msix are contiguous - * starting at bit 0, followed by the p; bit 0 is because of the shift below - * being 0; see STD_PAT_MODS and INT_PAT_MODS below for the contiguity cause */ -/* the flags above are transfered from the PMOP->op_pmflags member during - * compilation */ -#define RXf_PMf_STD_PMMOD_SHIFT 0 +#include "op_reg_common.h" + #define RXf_PMf_STD_PMMOD (RXf_PMf_MULTILINE|RXf_PMf_SINGLELINE|RXf_PMf_FOLD|RXf_PMf_EXTENDED) -#define RXf_PMf_COMPILETIME (RXf_PMf_MULTILINE|RXf_PMf_SINGLELINE|RXf_PMf_LOCALE|RXf_PMf_FOLD|RXf_PMf_EXTENDED|RXf_PMf_KEEPCOPY) #define CASE_STD_PMMOD_FLAGS_PARSE_SET(pmfl) \ case IGNORE_PAT_MOD: *(pmfl) |= RXf_PMf_FOLD; break; \ |