summaryrefslogtreecommitdiff
path: root/regcomp.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-06-30 15:03:14 -0600
committerKarl Williamson <khw@cpan.org>2014-08-21 14:49:46 -0600
commitdcb20b364cef1eec53dfee5ed1078aa04ef59ed8 (patch)
tree249151f4f1bb1d26d614e81d71152b21b6c96d9a /regcomp.h
parentda0334e84bccb9964f9752cf3ad04aa2ccff66b3 (diff)
downloadperl-dcb20b364cef1eec53dfee5ed1078aa04ef59ed8.tar.gz
regex: Use #define for number of bits in ANYOF
ANYOF nodes (for bracketed character classes) currently are for code points 0-255. This is the first step in the eventual making that size configurable. This also renames a static function, as the domain may not necessarily be 'latin1'
Diffstat (limited to 'regcomp.h')
-rw-r--r--regcomp.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/regcomp.h b/regcomp.h
index 3bb1a533f6..68646f1a33 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -184,8 +184,9 @@ struct regnode_2 {
U16 arg2;
};
+#define NUM_ANYOF_CODE_POINTS 256
-#define ANYOF_BITMAP_SIZE (256 / 8) /* 8 bits/Byte */
+#define ANYOF_BITMAP_SIZE (NUM_ANYOF_CODE_POINTS / 8) /* 8 bits/Byte */
/* Note that these form structs which are supersets of the next smaller one, by
* appending fields. Alignment problems can occur if one of those optional
@@ -551,9 +552,13 @@ struct regnode_ssc {
memset (ANYOF_BITMAP(p), 255, ANYOF_BITMAP_SIZE)
#define ANYOF_BITMAP_CLEARALL(p) \
Zero (ANYOF_BITMAP(p), ANYOF_BITMAP_SIZE)
-/* Check that all 256 bits are all set. Used in S_cl_is_anything() */
-#define ANYOF_BITMAP_TESTALLSET(p) /* Assumes sizeof(p) == 32 */ \
+#if ANYOF_BITMAP_SIZE == 32
+/* Check that all 256 bits are all set. */
+# define ANYOF_BITMAP_TESTALLSET(p) /* Assumes sizeof(p) == 32 */ \
memEQ (ANYOF_BITMAP(p), "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377", ANYOF_BITMAP_SIZE)
+#else
+# error Need to fix this if raise bitmap size. (As of this writing this macro is unused in the core)
+#endif
#define ANYOF_SKIP ((ANYOF_SIZE - 1)/sizeof(regnode))
#define ANYOF_POSIXL_SKIP ((ANYOF_POSIXL_SIZE - 1)/sizeof(regnode))