From 1489b465ff4e90485a0fae9370f20fc560a1dba8 Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Wed, 3 Aug 2022 15:18:52 +0200 Subject: [PATCH] regex engine - wrap PL_regnode_off_by_arg with macro REGNODE_OFF_BY_ARG() --- regcomp.c | 14 +++++++------- regcomp.h | 1 + reginline.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/regcomp.c b/regcomp.c index 0b8973ce26..a8bf8d5a91 100644 --- a/regcomp.c +++ b/regcomp.c @@ -4396,7 +4396,7 @@ S_join_exact(pTHX_ RExC_state_t *pRExC_state, regnode *scan, #ifdef EXPERIMENTAL_INPLACESCAN if (flags && !NEXT_OFF(n)) { DEBUG_PEEP("atch", val, depth, 0); - if (PL_regnode_off_by_arg[OP(n)]) { + if (REGNODE_OFF_BY_ARG(OP(n))) { ARG_SET(n, val - n); } else { @@ -4656,11 +4656,11 @@ S_rck_elide_nothing(pTHX_ regnode *node) PERL_ARGS_ASSERT_RCK_ELIDE_NOTHING; if (OP(node) != CURLYX) { - const int max = (PL_regnode_off_by_arg[OP(node)] + const int max = (REGNODE_OFF_BY_ARG(OP(node)) ? I32_MAX /* I32 may be smaller than U16 on CRAYs! */ : (I32_MAX < U16_MAX ? I32_MAX : U16_MAX)); - int off = (PL_regnode_off_by_arg[OP(node)] ? ARG(node) : NEXT_OFF(node)); + int off = (REGNODE_OFF_BY_ARG(OP(node)) ? ARG(node) : NEXT_OFF(node)); int noff; regnode *n = node; @@ -4675,7 +4675,7 @@ S_rck_elide_nothing(pTHX_ regnode *node) ) { off += noff; } - if (PL_regnode_off_by_arg[OP(node)]) + if (REGNODE_OFF_BY_ARG(OP(node))) ARG(node) = off; else NEXT_OFF(node) = off; @@ -5908,7 +5908,7 @@ S_study_chunk(pTHX_ while ( nxt1 && (OP(nxt1) != WHILEM)) { regnode *nnxt = regnext(nxt1); if (nnxt == nxt) { - if (PL_regnode_off_by_arg[OP(nxt1)]) + if (REGNODE_OFF_BY_ARG(OP(nxt1))) ARG_SET(nxt1, nxt2 - nxt1); else if (nxt2 - nxt1 < U16_MAX) NEXT_OFF(nxt1) = nxt2 - nxt1; @@ -21484,7 +21484,7 @@ S_regtail(pTHX_ RExC_state_t * pRExC_state, /* Populate this node's next pointer */ assert(val >= scan); - if (PL_regnode_off_by_arg[OP(REGNODE_p(scan))]) { + if (REGNODE_OFF_BY_ARG(OP(REGNODE_p(scan)))) { assert((UV) (val - scan) <= U32_MAX); ARG_SET(REGNODE_p(scan), val - scan); } @@ -21583,7 +21583,7 @@ S_regtail_study(pTHX_ RExC_state_t *pRExC_state, regnode_offset p, (IV)(val - scan) ); }); - if (PL_regnode_off_by_arg[OP(REGNODE_p(scan))]) { + if (REGNODE_OFF_BY_ARG(OP(REGNODE_p(scan)))) { assert((UV) (val - scan) <= U32_MAX); ARG_SET(REGNODE_p(scan), val - scan); } diff --git a/regcomp.h b/regcomp.h index c4b5f551bc..f41d40f112 100644 --- a/regcomp.h +++ b/regcomp.h @@ -1410,6 +1410,7 @@ typedef enum { #endif #define REGNODE_TYPE(arg) PL_regnode_kind[(arg)] +#define REGNODE_OFF_BY_ARG(node) PL_regnode_of_by_arg[(node)] #if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_REGEXEC_C) #include "reginline.h" diff --git a/reginline.h b/reginline.h index 1d1d4ef80d..589e341e50 100644 --- a/reginline.h +++ b/reginline.h @@ -18,7 +18,7 @@ Perl_regnext(pTHX_ const regnode *p) (int)OP(p), (int)REGNODE_MAX); } - offset = (PL_regnode_off_by_arg[OP(p)] ? ARG(p) : NEXT_OFF(p)); + offset = (REGNODE_OFF_BY_ARG(OP(p)) ? ARG(p) : NEXT_OFF(p)); if (offset == 0) return(NULL);