Skip to content

Commit

Permalink
regex engine - wrap PL_regnode_name with macro REGNODE_NAME()
Browse files Browse the repository at this point in the history
  • Loading branch information
demerphq committed Aug 6, 2022
1 parent 79a585d commit cbf5c5b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
18 changes: 9 additions & 9 deletions regcomp.c
Expand Up @@ -2950,7 +2950,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch,
case EXACTFU:
case EXACTFLU8: folder = PL_fold_latin1; break;
case EXACTF: folder = PL_fold; break;
default: Perl_croak( aTHX_ "panic! In trie construction, unknown node type %u %s", (unsigned) flags, PL_regnode_name[flags] );
default: Perl_croak( aTHX_ "panic! In trie construction, unknown node type %u %s", (unsigned) flags, REGNODE_NAME(flags) );
}

trie = (reg_trie_data *) PerlMemShared_calloc( 1, sizeof(reg_trie_data) );
Expand Down Expand Up @@ -5168,7 +5168,7 @@ S_study_chunk(pTHX_
}
Perl_re_printf( aTHX_ "(First==%d,Last==%d,Cur==%d,tt==%s,ntt==%s,nntt==%s)\n",
REG_NODE_NUM(first), REG_NODE_NUM(prev), REG_NODE_NUM(cur),
PL_regnode_name[trietype], PL_regnode_name[noper_trietype], PL_regnode_name[noper_next_trietype]
REGNODE_NAME(trietype), REGNODE_NAME(noper_trietype), REGNODE_NAME(noper_next_trietype)
);
});

Expand Down Expand Up @@ -5266,7 +5266,7 @@ S_study_chunk(pTHX_
depth+1, SvPV_nolen_const( RExC_mysv ), REG_NODE_NUM(cur));
Perl_re_printf( aTHX_ "(First==%d, Last==%d, Cur==%d, tt==%s)\n",
REG_NODE_NUM(first), REG_NODE_NUM(prev), REG_NODE_NUM(cur),
PL_regnode_name[trietype]
REGNODE_NAME(trietype)
);

});
Expand Down Expand Up @@ -6788,7 +6788,7 @@ S_study_chunk(pTHX_

else if (OP(scan) == REGEX_SET) {
Perl_croak(aTHX_ "panic: %s regnode should be resolved"
" before optimization", PL_regnode_name[REGEX_SET]);
" before optimization", REGNODE_NAME(REGEX_SET));
}

/* Else: zero-length, ignore. */
Expand Down Expand Up @@ -21390,7 +21390,7 @@ S_reginsert(pTHX_ RExC_state_t *pRExC_state, const U8 op,
PERL_UNUSED_CONTEXT;
PERL_UNUSED_ARG(depth);
/* (REGNODE_TYPE((U8)op) == CURLY ? EXTRA_STEP_2ARGS : 0); */
DEBUG_PARSE_FMT("inst"," - %s", PL_regnode_name[op]);
DEBUG_PARSE_FMT("inst"," - %s", REGNODE_NAME(op));
assert(!RExC_study_started); /* I believe we should never use reginsert once we have started
studying. If this is wrong then we need to adjust RExC_recurse
below like we do with RExC_open_parens/RExC_close_parens. */
Expand Down Expand Up @@ -21474,7 +21474,7 @@ S_regtail(pTHX_ RExC_state_t * pRExC_state,
Perl_re_printf( aTHX_ "~ %s (%zu) %s %s\n",
SvPV_nolen_const(RExC_mysv), scan,
(temp == NULL ? "->" : ""),
(temp == NULL ? PL_regnode_name[OP(REGNODE_p(val))] : "")
(temp == NULL ? REGNODE_NAME(OP(REGNODE_p(val))) : "")
);
});
if (temp == NULL)
Expand Down Expand Up @@ -21567,7 +21567,7 @@ S_regtail_study(pTHX_ RExC_state_t *pRExC_state, regnode_offset p,
Perl_re_printf( aTHX_ "~ %s (%zu) -> %s\n",
SvPV_nolen_const(RExC_mysv),
scan,
PL_regnode_name[exact]);
REGNODE_NAME(exact));
});
if (temp == NULL)
break;
Expand Down Expand Up @@ -21895,7 +21895,7 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o, const regmatch_
(int)op, (int)REGNODE_MAX);
}
}
sv_catpv(sv, PL_regnode_name[op]); /* Take off const! */
sv_catpv(sv, REGNODE_NAME(op)); /* Take off const! */

k = REGNODE_TYPE(op);

Expand Down Expand Up @@ -21923,7 +21923,7 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o, const regmatch_
const reg_trie_data * const trie
= (reg_trie_data*)progi->data->data[!IS_TRIE_AC(op) ? n : ac->trie];

Perl_sv_catpvf(aTHX_ sv, "-%s", PL_regnode_name[o->flags]);
Perl_sv_catpvf(aTHX_ sv, "-%s", REGNODE_NAME(o->flags));
DEBUG_TRIE_COMPILE_r({
if (trie->jump)
sv_catpvs(sv, "(JUMP)");
Expand Down
1 change: 1 addition & 0 deletions regcomp.h
Expand Up @@ -1413,6 +1413,7 @@ typedef enum {
#define REGNODE_OFF_BY_ARG(node) PL_regnode_of_by_arg[(node)]
#define REGNODE_ARG_LEN(node) PL_regnode_arg_len[(node)]
#define REGNODE_ARG_LEN_VARIES(node) PL_regnode_arg_len_varies[(node)]
#define REGNODE_NAME(node) PL_regnode_name[(node)]

#if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_REGEXEC_C)
#include "reginline.h"
Expand Down
6 changes: 3 additions & 3 deletions regexec.c
Expand Up @@ -6183,7 +6183,7 @@ S_backup_one_WB(pTHX_ WB_enum * previous, const U8 * const strbeg, U8 ** curpos,
Perl_re_printf( aTHX_ \
"%*s" pp " %s%s%s%s%s\n", \
INDENT_CHARS(depth), "", \
PL_regnode_name[st->resume_state], \
REGNODE_NAME(st->resume_state), \
((st==yes_state||st==mark_state) ? "[" : ""), \
((st==yes_state) ? "Y" : ""), \
((st==mark_state) ? "M" : ""), \
Expand Down Expand Up @@ -9816,7 +9816,7 @@ NULL
Perl_re_exec_indentf( aTHX_ "%4s #%-3d %-10s %s\n",
depth,
i ? " " : "push",
depth - i, PL_regnode_name[cur->resume_state],
depth - i, REGNODE_NAME(cur->resume_state),
(curyes == cur) ? "yes" : ""
);
if (curyes == cur)
Expand Down Expand Up @@ -10643,7 +10643,7 @@ S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p,

default:
Perl_croak(aTHX_ "panic: regrepeat() called with unrecognized"
" node type %d='%s'", OP(p), PL_regnode_name[OP(p)]);
" node type %d='%s'", OP(p), REGNODE_NAME(OP(p)));
NOT_REACHED; /* NOTREACHED */

}
Expand Down

0 comments on commit cbf5c5b

Please sign in to comment.