Commit 10db3a6156 for perl
commit 10db3a61565536c176f3f5df88fb182f758c4349
Author: Yves Orton <demerphq@gmail.com>
Date: Tue Oct 27 21:37:57 2026 +0100
regcomp: name BOUND/NBOUND field
Use BOUNDARY_TYPE for the boundary kind stored in boundary nodes.
Compilation, debugging, and execution now name this field directly while
retaining the existing node representation and behavior.
diff --git a/regcomp.c b/regcomp.c
index e677d0802b..90efbddd08 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -6140,7 +6140,7 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
}
ret = reg_node(pRExC_state, op);
- FLAGS(REGNODE_p(ret)) = flags;
+ BOUNDARY_TYPE_SET(REGNODE_p(ret), flags);
goto finish_meta_pat;
}
diff --git a/regcomp.h b/regcomp.h
index 841b927261..3d070a0d92 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -706,6 +706,14 @@ struct regnode_ssc {
FLAGS(p) = (val); \
} STMT_END
+#define BOUNDARY_TYPE(p) \
+ (assert(REGNODE_TYPE(OP(p)) == BOUND || REGNODE_TYPE(OP(p)) == NBOUND), \
+ PREVENT_LVALUE(FLAGS(p)))
+#define BOUNDARY_TYPE_SET(p, val) STMT_START { \
+ assert(REGNODE_TYPE(OP(p)) == BOUND || REGNODE_TYPE(OP(p)) == NBOUND); \
+ 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 { \
diff --git a/regcomp_debug.c b/regcomp_debug.c
index 02a16b6562..bd85eb8952 100644
--- a/regcomp_debug.c
+++ b/regcomp_debug.c
@@ -1049,8 +1049,8 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o, const regmatch_
"{sb}",
"{wb}"
};
- assert(FLAGS(o) < C_ARRAY_LENGTH(bounds));
- sv_catpv(sv, bounds[FLAGS(o)]);
+ assert(BOUNDARY_TYPE(o) < C_ARRAY_LENGTH(bounds));
+ sv_catpv(sv, bounds[BOUNDARY_TYPE(o)]);
}
else if (k == BRANCHJ && (op == UNLESSM || op == IFMATCH)) {
sv_catpvf(sv, "[%d", -(LOOKBEHIND_MAX_CHARS(o)));
diff --git a/regexec.c b/regexec.c
index fece09296e..172a4971ae 100644
--- a/regexec.c
+++ b/regexec.c
@@ -3024,7 +3024,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
case BOUND_tb_p8:
/* regcomp.c makes sure that these only have the traditional \b
* meaning. */
- assert(FLAGS(c) == TRADITIONAL_BOUND);
+ assert(BOUNDARY_TYPE(c) == TRADITIONAL_BOUND);
FBC_BOUND_A_NON_UTF8(isWORDCHAR_A);
break;
@@ -3033,7 +3033,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
case BOUNDA_t8_p8:
/* regcomp.c makes sure that these only have the traditional \b
* meaning. */
- assert(FLAGS(c) == TRADITIONAL_BOUND);
+ assert(BOUNDARY_TYPE(c) == TRADITIONAL_BOUND);
FBC_BOUND_A_UTF8(isWORDCHAR_A);
break;
@@ -3044,7 +3044,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
case NBOUND_tb_p8:
/* regcomp.c makes sure that these only have the traditional \b
* meaning. */
- assert(FLAGS(c) == TRADITIONAL_BOUND);
+ assert(BOUNDARY_TYPE(c) == TRADITIONAL_BOUND);
FBC_NBOUND_A_NON_UTF8(isWORDCHAR_A);
break;
@@ -3053,14 +3053,14 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
case NBOUNDA_t8_p8:
/* regcomp.c makes sure that these only have the traditional \b
* meaning. */
- assert(FLAGS(c) == TRADITIONAL_BOUND);
+ assert(BOUNDARY_TYPE(c) == TRADITIONAL_BOUND);
FBC_NBOUND_A_UTF8(isWORDCHAR_A);
break;
case NBOUNDU_tb_pb:
case NBOUNDU_tb_p8:
- if ((bound_type) FLAGS(c) == TRADITIONAL_BOUND) {
+ if ((bound_type) BOUNDARY_TYPE(c) == TRADITIONAL_BOUND) {
FBC_NBOUND_NON_UTF8(isWORDCHAR_L1);
break;
}
@@ -3071,7 +3071,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
case NBOUNDL_tb_pb:
case NBOUNDL_tb_p8:
CHECK_AND_WARN_PROBLEMATIC_LOCALE_;
- if (FLAGS(c) == TRADITIONAL_BOUND) {
+ if (BOUNDARY_TYPE(c) == TRADITIONAL_BOUND) {
FBC_NBOUND_NON_UTF8(isWORDCHAR_LC);
break;
}
@@ -3084,7 +3084,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
case BOUNDL_tb_pb:
case BOUNDL_tb_p8:
CHECK_AND_WARN_PROBLEMATIC_LOCALE_;
- if (FLAGS(c) == TRADITIONAL_BOUND) {
+ if (BOUNDARY_TYPE(c) == TRADITIONAL_BOUND) {
FBC_BOUND_NON_UTF8(isWORDCHAR_LC);
break;
}
@@ -3095,7 +3095,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
case BOUNDU_tb_pb:
case BOUNDU_tb_p8:
- if ((bound_type) FLAGS(c) == TRADITIONAL_BOUND) {
+ if ((bound_type) BOUNDARY_TYPE(c) == TRADITIONAL_BOUND) {
FBC_BOUND_NON_UTF8(isWORDCHAR_L1);
break;
}
@@ -3114,7 +3114,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
}
}
- switch((bound_type) FLAGS(c)) {
+ switch((bound_type) BOUNDARY_TYPE(c)) {
case TRADITIONAL_BOUND: /* Should have already been handled */
assert(0);
break;
@@ -3215,7 +3215,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
case BOUNDL_t8_pb:
case BOUNDL_t8_p8:
CHECK_AND_WARN_PROBLEMATIC_LOCALE_;
- if (FLAGS(c) == TRADITIONAL_BOUND) {
+ if (BOUNDARY_TYPE(c) == TRADITIONAL_BOUND) {
FBC_BOUND_UTF8(isWORDCHAR_LC, isWORDCHAR_LC_uvchr,
isWORDCHAR_LC_utf8_safe);
break;
@@ -3229,7 +3229,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
case NBOUNDL_t8_pb:
case NBOUNDL_t8_p8:
CHECK_AND_WARN_PROBLEMATIC_LOCALE_;
- if (FLAGS(c) == TRADITIONAL_BOUND) {
+ if (BOUNDARY_TYPE(c) == TRADITIONAL_BOUND) {
FBC_NBOUND_UTF8(isWORDCHAR_LC, isWORDCHAR_LC_uvchr,
isWORDCHAR_LC_utf8_safe);
break;
@@ -3244,13 +3244,13 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
case NBOUND_t8_p8:
/* regcomp.c makes sure that these only have the traditional \b
* meaning. */
- assert(FLAGS(c) == TRADITIONAL_BOUND);
+ assert(BOUNDARY_TYPE(c) == TRADITIONAL_BOUND);
/* FALLTHROUGH */
case NBOUNDU_t8_pb:
case NBOUNDU_t8_p8:
- if ((bound_type) FLAGS(c) == TRADITIONAL_BOUND) {
+ if ((bound_type) BOUNDARY_TYPE(c) == TRADITIONAL_BOUND) {
FBC_NBOUND_UTF8(isWORDCHAR_L1, isWORDCHAR_uni,
isWORDCHAR_utf8_safe);
break;
@@ -3263,13 +3263,13 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
case BOUND_t8_p8:
/* regcomp.c makes sure that these only have the traditional \b
* meaning. */
- assert(FLAGS(c) == TRADITIONAL_BOUND);
+ assert(BOUNDARY_TYPE(c) == TRADITIONAL_BOUND);
/* FALLTHROUGH */
case BOUNDU_t8_pb:
case BOUNDU_t8_p8:
- if ((bound_type) FLAGS(c) == TRADITIONAL_BOUND) {
+ if ((bound_type) BOUNDARY_TYPE(c) == TRADITIONAL_BOUND) {
FBC_BOUND_UTF8(isWORDCHAR_L1, isWORDCHAR_uni, isWORDCHAR_utf8_safe);
break;
}
@@ -3288,7 +3288,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
}
}
- switch((bound_type) FLAGS(c)) {
+ switch((bound_type) BOUNDARY_TYPE(c)) {
case TRADITIONAL_BOUND: /* Should have already been handled */
assert(0);
break;
@@ -8051,7 +8051,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
bool b1, b2;
CHECK_AND_WARN_PROBLEMATIC_LOCALE_;
- if (FLAGS(scan) != TRADITIONAL_BOUND) {
+ if (BOUNDARY_TYPE(scan) != TRADITIONAL_BOUND) {
CHECK_AND_WARN_NON_UTF8_CTYPE_LOCALE_IN_BOUND;
goto boundu;
}
@@ -8135,7 +8135,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
}
else if (utf8_target) {
bound_utf8:
- switch((bound_type) FLAGS(scan)) {
+ switch((bound_type) BOUNDARY_TYPE(scan)) {
case TRADITIONAL_BOUND:
{
bool b1, b2;
@@ -8239,7 +8239,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
}
}
else { /* Not utf8 target */
- switch((bound_type) FLAGS(scan)) {
+ switch((bound_type) BOUNDARY_TYPE(scan)) {
case TRADITIONAL_BOUND:
{
bool b1, b2;