summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2018-09-20 22:23:00 -0600
committerKarl Williamson <khw@cpan.org>2018-10-20 00:09:54 -0600
commit14ed74f6dd2e0e693ae27a31f52b809b3258942d (patch)
tree372a7d4bb53e93cb6bb6daf0b0dfbf33e7cdffa3
parent791aaf541f8a702d973890e80d703c32899f0651 (diff)
downloadperl-14ed74f6dd2e0e693ae27a31f52b809b3258942d.tar.gz
regcomp.h: Add some macros
These are use to allow the bit map of run-time /[[:posix:]]/l classes to be stored in a variable, and not just in the argument of an ANYOF node. This will enable the next commit to use such a variable. The current macros are rewritten to just call the new ones with the proper arguments. A macro of a different sort is also created to allow one to set the entire bit field in the node at once.
-rw-r--r--regcomp.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/regcomp.h b/regcomp.h
index b0b02ae619..6fcdc22079 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -651,13 +651,22 @@ struct regnode_ssc {
#define ANYOF_BIT(c) (1U << ((c) & 7))
-#define ANYOF_POSIXL_SET(p, c) (((regnode_charclass_posixl*) (p))->classflags |= (1U << (c)))
+#define POSIXL_SET(field, c) ((field) |= (1U << (c)))
+#define ANYOF_POSIXL_SET(p, c) POSIXL_SET(((regnode_charclass_posixl*) (p))->classflags, (c))
-#define ANYOF_POSIXL_CLEAR(p, c) (((regnode_charclass_posixl*) (p))->classflags &= ~ (1U <<(c)))
+#define POSIXL_CLEAR(field, c) ((field) &= ~ (1U <<(c)))
+#define ANYOF_POSIXL_CLEAR(p, c) POSIXL_CLEAR(((regnode_charclass_posixl*) (p))->classflags, (c))
-#define ANYOF_POSIXL_TEST(p, c) (((regnode_charclass_posixl*) (p))->classflags & (1U << (c)))
+#define POSIXL_TEST(field, c) ((field) & (1U << (c)))
+#define ANYOF_POSIXL_TEST(p, c) POSIXL_TEST(((regnode_charclass_posixl*) (p))->classflags, (c))
-#define ANYOF_POSIXL_ZERO(ret) STMT_START { ((regnode_charclass_posixl*) (ret))->classflags = 0; } STMT_END
+#define POSIXL_ZERO(field) STMT_START { (field) = 0; } STMT_END
+#define ANYOF_POSIXL_ZERO(ret) POSIXL_ZERO(((regnode_charclass_posixl*) (ret))->classflags)
+
+#define ANYOF_POSIXL_SET_TO_BITMAP(p, bits) \
+ STMT_START { \
+ ((regnode_charclass_posixl*) (p))->classflags = (bits); \
+ } STMT_END
/* Shifts a bit to get, eg. 0x4000_0000, then subtracts 1 to get 0x3FFF_FFFF */
#define ANYOF_POSIXL_SETALL(ret) STMT_START { ((regnode_charclass_posixl*) (ret))->classflags = ((1U << ((ANYOF_POSIXL_MAX) - 1))) - 1; } STMT_END