Commit f039c202fd for perl
commit f039c202fd7d10cbf646942029d78b14c05fc1c6
Author: Yves Orton <demerphq@gmail.com>
Date: Tue Oct 27 21:37:27 2026 +0100
regcomp: name ANYOFM mask and value
Give the mask and masked match value in ANYOFM and NANYOFM separate
property names. This makes the two fields clear in class optimization,
debug output, and execution while preserving their existing encoding.
diff --git a/regcomp.c b/regcomp.c
index 28c4471675..95b708c4bf 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -12256,7 +12256,7 @@ S_optimize_regclass(pTHX_
/* The argument is the lowest code point */
*ret = reg1node(pRExC_state, op, lowest_cp);
- FLAGS(REGNODE_p(*ret)) = ANYOFM_mask;
+ ANYOFM_MASK_SET(REGNODE_p(*ret), ANYOFM_mask);
}
}
@@ -13612,15 +13612,15 @@ Perl_get_ANYOFM_contents(pTHX_ const regnode * n)
* ANYOFM/NANYOFM node 'n' */
SV * cp_list = new_invlist_(-1);
- const U8 lowest = (U8) ARG1u(n);
+ const U8 lowest = (U8) ANYOFM_MATCH_VALUE(n);
unsigned int i;
U8 count = 0;
- U8 needed = 1U << PL_bitcount[ (U8) ~ FLAGS(n)];
+ U8 needed = 1U << PL_bitcount[ (U8) ~ ANYOFM_MASK(n)];
/* Starting with the lowest code point, any code point that ANDed with the
* mask yields the lowest code point is in the set */
for (i = lowest; i <= 0xFF; i++) {
- if ((i & FLAGS(n)) == ARG1u(n)) {
+ if ((i & ANYOFM_MASK(n)) == ANYOFM_MATCH_VALUE(n)) {
cp_list = add_cp_to_invlist(cp_list, i);
count++;
diff --git a/regcomp.h b/regcomp.h
index acdb828550..3358f293ac 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -620,6 +620,13 @@ struct regnode_ssc {
ARG1u_SET((p), (val)); \
} STMT_END
+#define ANYOFM_MATCH_VALUE(p) \
+ (assert(OP(p) == ANYOFM || OP(p) == NANYOFM), PREVENT_LVALUE(ARG1u(p)))
+#define ANYOFM_MATCH_VALUE_SET(p, val) STMT_START { \
+ assert(OP(p) == ANYOFM || OP(p) == NANYOFM); \
+ ARG1u_SET((p), (val)); \
+} STMT_END
+
#define NEXACTb_BYTE(p) \
(assert(OP(p) == NEXACTb), PREVENT_LVALUE(ARG1u(p)))
#define NEXACTb_BYTE_SET(p, val) STMT_START { \
@@ -691,6 +698,13 @@ struct regnode_ssc {
FLAGS(p) = (val); \
} STMT_END
+#define ANYOFM_MASK(p) \
+ (assert(OP(p) == ANYOFM || OP(p) == NANYOFM), PREVENT_LVALUE(FLAGS(p)))
+#define ANYOFM_MASK_SET(p, val) STMT_START { \
+ assert(OP(p) == ANYOFM || OP(p) == NANYOFM); \
+ FLAGS(p) = (val); \
+} STMT_END
+
#define REF_IS_VOLATILE(p) \
(assert(REGNODE_TYPE(OP(p)) == REF), PREVENT_LVALUE((FLAGS(p) & \
VOLATILE_REF) != 0))
diff --git a/regcomp_study.c b/regcomp_study.c
index 6706d67547..5a2906ac80 100644
--- a/regcomp_study.c
+++ b/regcomp_study.c
@@ -2401,8 +2401,8 @@ Perl_study_chunk(pTHX_
U8 mask = ~ ('A' ^ 'a'); /* These differ in just one bit */
OP(scan) = ANYOFM;
- ARG1u_SET(scan, *s & mask);
- FLAGS(scan) = mask;
+ ANYOFM_MATCH_VALUE_SET(scan, *s & mask);
+ ANYOFM_MASK_SET(scan, mask);
/* We're not EXACTFish any more, so restudy.
* Search for "restudy" in this file to find
* a comment with details. */
@@ -2528,8 +2528,8 @@ Perl_study_chunk(pTHX_
* case, and the lowest code point of the
* pair (which the '&' forces) */
OP(next) = ANYOFM;
- ARG1u_SET(next, *STRING(next) & mask);
- FLAGS(next) = mask;
+ ANYOFM_MATCH_VALUE_SET(next, *STRING(next) & mask);
+ ANYOFM_MASK_SET(next, mask);
}
if (flags & SCF_DO_STCLASS) {
diff --git a/regexec.c b/regexec.c
index 116021a9be..811efeadbf 100644
--- a/regexec.c
+++ b/regexec.c
@@ -2637,10 +2637,10 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
}
break;
- case ANYOFM_tb_pb: /* ARG1u() is the base byte; FLAGS() the mask byte */
+ case ANYOFM_tb_pb: /* ANYOFM_MATCH_VALUE() is the base byte; ANYOFM_MASK() the mask byte */
case ANYOFM_tb_p8:
REXEC_FBC_NON_UTF8_FIND_NEXT_SCAN(
- find_next_masked((U8 *) s, (U8 *) strend, (U8) ARG1u(c), FLAGS(c)));
+ find_next_masked((U8 *) s, (U8 *) strend, (U8) ANYOFM_MATCH_VALUE(c), ANYOFM_MASK(c)));
break;
case ANYOFM_t8_pb:
@@ -2649,13 +2649,13 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
* we do anyway for performance reasons, as otherwise we would have to
* examine all the continuation characters */
REXEC_FBC_UTF8_FIND_NEXT_SCAN(
- find_next_masked((U8 *) s, (U8 *) strend, (U8) ARG1u(c), FLAGS(c)));
+ find_next_masked((U8 *) s, (U8 *) strend, (U8) ANYOFM_MATCH_VALUE(c), ANYOFM_MASK(c)));
break;
case NANYOFM_tb_pb:
case NANYOFM_tb_p8:
REXEC_FBC_NON_UTF8_FIND_NEXT_SCAN(
- find_span_end_mask((U8 *) s, (U8 *) strend, (U8) ARG1u(c), FLAGS(c)));
+ find_span_end_mask((U8 *) s, (U8 *) strend, (U8) ANYOFM_MATCH_VALUE(c), ANYOFM_MASK(c)));
break;
case NANYOFM_t8_pb:
@@ -2663,7 +2663,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
variants. */
REXEC_FBC_UTF8_FIND_NEXT_SCAN(
(char *) find_span_end_mask((U8 *) s, (U8 *) strend,
- (U8) ARG1u(c), FLAGS(c)));
+ (U8) ANYOFM_MATCH_VALUE(c), ANYOFM_MASK(c)));
break;
case NEXACTb_tb_pb:
@@ -8349,7 +8349,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
case ANYOFM:
if ( NEXTCHR_IS_EOS
- || (UCHARAT(locinput) & FLAGS(scan)) != ARG1u(scan)
+ || (UCHARAT(locinput) & ANYOFM_MASK(scan)) != ANYOFM_MATCH_VALUE(scan)
|| locinput >= loceol)
{
sayNO;
@@ -8359,7 +8359,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
case NANYOFM:
if ( NEXTCHR_IS_EOS
- || (UCHARAT(locinput) & FLAGS(scan)) == ARG1u(scan)
+ || (UCHARAT(locinput) & ANYOFM_MASK(scan)) == ANYOFM_MATCH_VALUE(scan)
|| locinput >= loceol)
{
sayNO;
@@ -11399,13 +11399,13 @@ S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p,
case ANYOFM_tb:
scan = (char *) find_span_end_mask((U8 *) scan, (U8 *) this_eol,
- (U8) ARG1u(p), FLAGS(p));
+ (U8) ANYOFM_MATCH_VALUE(p), ANYOFM_MASK(p));
break;
case NANYOFM_t8:
while ( hardcount < max
&& scan < this_eol
- && (*scan & FLAGS(p)) != ARG1u(p))
+ && (*scan & ANYOFM_MASK(p)) != ANYOFM_MATCH_VALUE(p))
{
scan += UTF8SKIP(scan);
hardcount++;
@@ -11414,7 +11414,7 @@ S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p,
case NANYOFM_tb:
scan = (char *) find_next_masked((U8 *) scan, (U8 *) this_eol,
- (U8) ARG1u(p), FLAGS(p));
+ (U8) ANYOFM_MATCH_VALUE(p), ANYOFM_MASK(p));
break;
case NEXACTb_t8: