summaryrefslogtreecommitdiff
path: root/regcomp.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2022-07-05 07:33:59 -0600
committerKarl Williamson <khw@cpan.org>2022-07-12 05:14:35 -0600
commitff37df4b7ee5eb72f28efb62402ea69c571d43a0 (patch)
treee2e121a13a63481e17162286a201bf2de87984b2 /regcomp.h
parent73af6c070bf1fd12a5bd45bc3e2b9f086e2b05cf (diff)
downloadperl-ff37df4b7ee5eb72f28efb62402ea69c571d43a0.tar.gz
regcomp.h: Make bitmap lookups more general
This introduces a new macro and converts to use it so that bitmaps other than the traditional ones in ANYOF nodes may be defined in a common manner.
Diffstat (limited to 'regcomp.h')
-rw-r--r--regcomp.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/regcomp.h b/regcomp.h
index 7e2c03ce90..10bd9fc47f 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -696,9 +696,13 @@ struct regnode_ssc {
/* Utility macros for the bitmap and classes of ANYOF */
+#define BITMAP_BYTE(p, c) (( (U8*) (p)) [ ( ( (UV) (c)) >> 3) ] )
+#define BITMAP_BIT(c) (1U << ((c) & 7))
+#define BITMAP_TEST(p, c) (BITMAP_BYTE(p, c) & BITMAP_BIT((U8)(c)))
+
#define ANYOF_FLAGS(p) ((p)->flags)
-#define ANYOF_BIT(c) (1U << ((c) & 7))
+#define ANYOF_BIT(c) BITMAP_BIT(c)
#define ANYOF_POSIXL_BITMAP(p) (((regnode_charclass_posixl*) (p))->classflags)
@@ -750,7 +754,7 @@ struct regnode_ssc {
#define ANYOF_BITMAP_BYTE(p, c) BITMAP_BYTE(ANYOF_BITMAP(p), c)
#define ANYOF_BITMAP_SET(p, c) (ANYOF_BITMAP_BYTE(p, c) |= ANYOF_BIT(c))
#define ANYOF_BITMAP_CLEAR(p,c) (ANYOF_BITMAP_BYTE(p, c) &= ~ANYOF_BIT(c))
-#define ANYOF_BITMAP_TEST(p, c) cBOOL(ANYOF_BITMAP_BYTE(p, c) & ANYOF_BIT(c))
+#define ANYOF_BITMAP_TEST(p, c) cBOOL(ANYOF_BITMAP_BYTE(p, c) & ANYOF_BIT(c))
#define ANYOF_BITMAP_SETALL(p) \
memset (ANYOF_BITMAP(p), 255, ANYOF_BITMAP_SIZE)
@@ -982,10 +986,6 @@ typedef struct _reg_ac_data reg_ac_data;
#define IS_ANYOF_TRIE(op) ((op)==TRIEC || (op)==AHOCORASICKC)
#define IS_TRIE_AC(op) ((op)>=AHOCORASICK)
-
-#define BITMAP_BYTE(p, c) (( (U8*) p) [ ( ( (UV) (c)) >> 3) ] )
-#define BITMAP_TEST(p, c) (BITMAP_BYTE(p, c) & ANYOF_BIT((U8)c))
-
/* these defines assume uniquecharcount is the correct variable, and state may be evaluated twice */
#define TRIE_NODENUM(state) (((state)-1)/(trie->uniquecharcount)+1)
#define SAFE_TRIE_NODENUM(state) ((state) ? (((state)-1)/(trie->uniquecharcount)+1) : (state))