This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Extract code into a function
authorKarl Williamson <khw@cpan.org>
Tue, 16 Oct 2018 03:31:13 +0000 (21:31 -0600)
committerKarl Williamson <khw@cpan.org>
Sat, 20 Oct 2018 06:09:56 +0000 (00:09 -0600)
This is in preparation for a later commit where the code will become
more complex and be called from more than one place.

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

index eadc706..e635918 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -2368,6 +2368,7 @@ Es        |regnode_offset|regnode_guts|NN RExC_state_t *pRExC_state          \
                                |const U8 op                               \
                                |const STRLEN extra_len                    \
                                |NN const char* const name
+Es     |void   |change_engine_size|NN RExC_state_t *pRExC_state|const Ptrdiff_t size
 Es     |regnode_offset|reganode|NN RExC_state_t *pRExC_state|U8 op \
                                |U32 arg
 Es     |regnode_offset|reg2Lanode|NN RExC_state_t *pRExC_state            \
diff --git a/embed.h b/embed.h
index 8e762bc..ea7c0d9 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define add_data               S_add_data
 #define add_multi_match(a,b,c) S_add_multi_match(aTHX_ a,b,c)
 #define alloc_maybe_populate_EXACT(a,b,c,d,e,f)        S_alloc_maybe_populate_EXACT(aTHX_ a,b,c,d,e,f)
+#define change_engine_size(a,b)        S_change_engine_size(aTHX_ a,b)
 #define cntrl_to_mnemonic      S_cntrl_to_mnemonic
 #define compute_EXACTish       S_compute_EXACTish
 #define construct_ahocorasick_from_trie(a,b,c) S_construct_ahocorasick_from_trie(aTHX_ a,b,c)
diff --git a/proto.h b/proto.h
index b72bd2a..f977d95 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -5394,6 +5394,9 @@ PERL_STATIC_INLINE void   S_alloc_maybe_populate_EXACT(pTHX_ RExC_state_t *pRExC_s
 #define PERL_ARGS_ASSERT_ALLOC_MAYBE_POPULATE_EXACT    \
        assert(pRExC_state); assert(node); assert(flagp)
 #endif
+STATIC void    S_change_engine_size(pTHX_ RExC_state_t *pRExC_state, const Ptrdiff_t size);
+#define PERL_ARGS_ASSERT_CHANGE_ENGINE_SIZE    \
+       assert(pRExC_state)
 STATIC const char *    S_cntrl_to_mnemonic(const U8 c)
                        __attribute__warn_unused_result__;
 
index a3f7194..8197ca6 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -19216,6 +19216,14 @@ S_nextchar(pTHX_ RExC_state_t *pRExC_state)
     }
 }
 
+STATIC void
+S_change_engine_size(pTHX_ RExC_state_t *pRExC_state, const Ptrdiff_t size)
+{
+    PERL_ARGS_ASSERT_CHANGE_ENGINE_SIZE;
+
+    RExC_size += size;
+}
+
 STATIC regnode_offset
 S_regnode_guts(pTHX_ RExC_state_t *pRExC_state, const U8 op, const STRLEN extra_size, const char* const name)
 {
@@ -19235,7 +19243,7 @@ S_regnode_guts(pTHX_ RExC_state_t *pRExC_state, const U8 op, const STRLEN extra_
 
     if (SIZE_ONLY) {
        SIZE_ALIGN(RExC_size);
-       RExC_size += 1 + extra_size;
+    change_engine_size(pRExC_state, (Ptrdiff_t) 1 + extra_size);
        return(ret);
     }
     if (REGNODE_p(RExC_emit) >= RExC_emit_bound)