This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Extract some code into an inline function
authorKarl Williamson <public@khwilliamson.com>
Mon, 9 Jul 2012 19:10:00 +0000 (13:10 -0600)
committerKarl Williamson <public@khwilliamson.com>
Wed, 25 Jul 2012 03:13:46 +0000 (21:13 -0600)
This code will be used in future commits in multiple places

embed.fnc
embed.h
proto.h
regcomp.c

index 3b7fd77..33f77c9 100644 (file)
--- 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 (file)
--- a/embed.h
+++ b/embed.h
 #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 (file)
--- 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);
index fa407c4..6e296eb 100644 (file)
--- 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);