From 86dc2bf573b880d9a9cb80e85148cf3540e08da0 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Mon, 9 Jul 2012 13:10:00 -0600 Subject: [PATCH] regcomp.c: Extract some code into an inline function This code will be used in future commits in multiple places --- embed.fnc | 1 + embed.h | 1 + proto.h | 5 +++++ regcomp.c | 33 +++++++++++++++++++++------------ 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/embed.fnc b/embed.fnc index 3b7fd77..33f77c9 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1949,6 +1949,7 @@ EsRn |char * |regwhite |NN struct RExC_state_t *pRExC_state \ |NN char *p Ei |void |alloc_maybe_populate_EXACT|NN struct RExC_state_t *pRExC_state \ |NN regnode *node|STRLEN len|UV code_point +Ei |U8 |compute_EXACTish|NN struct RExC_state_t *pRExC_state Es |char * |nextchar |NN struct RExC_state_t *pRExC_state Es |bool |reg_skipcomment|NN struct RExC_state_t *pRExC_state Es |void |scan_commit |NN const struct RExC_state_t *pRExC_state \ diff --git a/embed.h b/embed.h index 6a10e72..3af88ca 100644 --- a/embed.h +++ b/embed.h @@ -913,6 +913,7 @@ #define cl_init S_cl_init #define cl_is_anything S_cl_is_anything #define cl_or S_cl_or +#define compute_EXACTish(a) S_compute_EXACTish(aTHX_ a) #define get_invlist_iter_addr(a) S_get_invlist_iter_addr(aTHX_ a) #define get_invlist_len_addr(a) S_get_invlist_len_addr(aTHX_ a) #define get_invlist_version_id_addr(a) S_get_invlist_version_id_addr(aTHX_ a) diff --git a/proto.h b/proto.h index 91db7c0..e6d0dbe 100644 --- a/proto.h +++ b/proto.h @@ -6440,6 +6440,11 @@ STATIC void S_cl_or(const struct RExC_state_t *pRExC_state, struct regnode_charc #define PERL_ARGS_ASSERT_CL_OR \ assert(pRExC_state); assert(cl); assert(or_with) +PERL_STATIC_INLINE U8 S_compute_EXACTish(pTHX_ struct RExC_state_t *pRExC_state) + __attribute__nonnull__(pTHX_1); +#define PERL_ARGS_ASSERT_COMPUTE_EXACTISH \ + assert(pRExC_state) + PERL_STATIC_INLINE UV* S_get_invlist_iter_addr(pTHX_ SV* invlist) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); diff --git a/regcomp.c b/regcomp.c index fa407c4..6e296eb 100644 --- a/regcomp.c +++ b/regcomp.c @@ -9735,6 +9735,26 @@ S_reg_recode(pTHX_ const char value, SV **encp) return uv; } +PERL_STATIC_INLINE U8 +S_compute_EXACTish(pTHX_ RExC_state_t *pRExC_state) +{ + U8 op; + + PERL_ARGS_ASSERT_COMPUTE_EXACTISH; + + if (! FOLD) { + return EXACT; + } + + op = get_regex_charset(RExC_flags); + if (op >= REGEX_ASCII_RESTRICTED_CHARSET) { + op--; /* /a is same as /u, and map /aa's offset to what /a's would have + been, so there is no hole */ + } + + return op + EXACTF; +} + PERL_STATIC_INLINE void S_alloc_maybe_populate_EXACT(pTHX_ RExC_state_t *pRExC_state, regnode *node, STRLEN len, UV code_point) { @@ -10295,18 +10315,7 @@ tryagain: bool is_exactfu_sharp_s; ender = 0; - if (! FOLD) { - node_type = EXACT; - } - else { - node_type = get_regex_charset(RExC_flags); - if (node_type >= REGEX_ASCII_RESTRICTED_CHARSET) { - node_type--; /* /a is same as /u, and map /aa's offset to - what /a's would have been, so there is no - hole */ - } - node_type += EXACTF; - } + node_type = compute_EXACTish(pRExC_state); ret = reg_node(pRExC_state, node_type); s = STRING(ret); -- 2.7.4