Move initialization of PL_XPosix_ptrs[] to perl.c
authorKarl Williamson <public@khwilliamson.com>
Mon, 6 Jan 2014 19:14:31 +0000 (12:14 -0700)
committerKarl Williamson <public@khwilliamson.com>
Thu, 9 Jan 2014 21:05:44 +0000 (14:05 -0700)
This was performed unconditionally in regcomp.c.  However, future
commits will use this from other code.  Almost all (but not completely
all) Perl code uses regular expressions, so only rarely will this small
amount of initialization be performed when it currently isn't.

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

index d0d980c..c3ace70 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -1098,8 +1098,8 @@ Ap        |void   |regdump        |NN const regexp* r
 Ap     |SV*    |regclass_swash |NULLOK const regexp *prog \
                                |NN const struct regnode *node|bool doinit \
                                |NULLOK SV **listsvp|NULLOK SV **altsvp
-#ifdef PERL_IN_REGCOMP_C
-EMsR   |SV*    |_new_invlist_C_array|NN const UV* const list
+#if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_PERL_C)
+AMpR   |SV*    |_new_invlist_C_array|NN const UV* const list
 : Not used currently: EXMs     |bool   |_invlistEQ     |NN SV* const a|NN SV* const b|const bool complement_b
 #endif
 Ap     |I32    |pregexec       |NN REGEXP * const prog|NN char* stringarg \
diff --git a/embed.h b/embed.h
index e918bcb..d5b85db 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define warn_nocontext         Perl_warn_nocontext
 #define warner_nocontext       Perl_warner_nocontext
 #endif
+#if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_PERL_C)
+#define _new_invlist_C_array(a)        Perl__new_invlist_C_array(aTHX_ a)
+#endif
 #if defined(PERL_MAD)
 #define newFORM(a,b,c)         Perl_newFORM(aTHX_ a,b,c)
 #endif
 #  if defined(PERL_IN_REGCOMP_C)
 #define _append_range_to_invlist(a,b,c)        S__append_range_to_invlist(aTHX_ a,b,c)
 #define _invlist_array_init(a,b)       S__invlist_array_init(aTHX_ a,b)
-#define _new_invlist_C_array(a)        S__new_invlist_C_array(aTHX_ a)
 #define add_cp_to_invlist(a,b) S_add_cp_to_invlist(aTHX_ a,b)
 #define add_data               S_add_data
 #define alloc_maybe_populate_EXACT(a,b,c,d,e)  S_alloc_maybe_populate_EXACT(aTHX_ a,b,c,d,e)
diff --git a/perl.c b/perl.c
index e5611aa..a11be8b 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -33,6 +33,7 @@
 #include "perl.h"
 #include "patchlevel.h"                        /* for local_patches */
 #include "XSUB.h"
+#include "charclass_invlists.h"
 
 #ifdef NETWARE
 #include "nwutil.h"    
@@ -379,6 +380,24 @@ perl_construct(pTHXx)
     /* Start with 1 bucket, for DFS.  It's unlikely we'll need more.  */
     HvMAX(PL_registered_mros) = 0;
 
+    PL_XPosix_ptrs[_CC_ASCII] = _new_invlist_C_array(ASCII_invlist);
+    PL_XPosix_ptrs[_CC_ALPHANUMERIC] = _new_invlist_C_array(XPosixAlnum_invlist);
+    PL_XPosix_ptrs[_CC_ALPHA] = _new_invlist_C_array(XPosixAlpha_invlist);
+    PL_XPosix_ptrs[_CC_BLANK] = _new_invlist_C_array(XPosixBlank_invlist);
+    PL_XPosix_ptrs[_CC_CASED] =  _new_invlist_C_array(Cased_invlist);
+    PL_XPosix_ptrs[_CC_CNTRL] = _new_invlist_C_array(XPosixCntrl_invlist);
+    PL_XPosix_ptrs[_CC_DIGIT] = _new_invlist_C_array(XPosixDigit_invlist);
+    PL_XPosix_ptrs[_CC_GRAPH] = _new_invlist_C_array(XPosixGraph_invlist);
+    PL_XPosix_ptrs[_CC_LOWER] = _new_invlist_C_array(XPosixLower_invlist);
+    PL_XPosix_ptrs[_CC_PRINT] = _new_invlist_C_array(XPosixPrint_invlist);
+    PL_XPosix_ptrs[_CC_PUNCT] = _new_invlist_C_array(XPosixPunct_invlist);
+    PL_XPosix_ptrs[_CC_SPACE] = _new_invlist_C_array(XPerlSpace_invlist);
+    PL_XPosix_ptrs[_CC_PSXSPC] = _new_invlist_C_array(XPosixSpace_invlist);
+    PL_XPosix_ptrs[_CC_UPPER] = _new_invlist_C_array(XPosixUpper_invlist);
+    PL_XPosix_ptrs[_CC_VERTSPACE] = _new_invlist_C_array(VertSpace_invlist);
+    PL_XPosix_ptrs[_CC_WORDCHAR] = _new_invlist_C_array(XPosixWord_invlist);
+    PL_XPosix_ptrs[_CC_XDIGIT] = _new_invlist_C_array(XPosixXDigit_invlist);
+
     ENTER;
 }
 
diff --git a/proto.h b/proto.h
index 647d357..a0a1a23 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -6570,12 +6570,6 @@ PERL_STATIC_INLINE UV*   S__invlist_array_init(pTHX_ SV* const invlist, const bool
 #define PERL_ARGS_ASSERT__INVLIST_ARRAY_INIT   \
        assert(invlist)
 
-STATIC SV*     S__new_invlist_C_array(pTHX_ const UV* const list)
-                       __attribute__warn_unused_result__
-                       __attribute__nonnull__(pTHX_1);
-#define PERL_ARGS_ASSERT__NEW_INVLIST_C_ARRAY  \
-       assert(list)
-
 PERL_STATIC_INLINE SV* S_add_cp_to_invlist(pTHX_ SV* invlist, const UV cp)
                        __attribute__warn_unused_result__;
 
@@ -6956,6 +6950,14 @@ PERL_CALLCONV void       Perl__invlist_dump(pTHX_ PerlIO *file, I32 level, const char*
        assert(file); assert(indent); assert(invlist)
 
 #endif
+#if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_PERL_C)
+PERL_CALLCONV SV*      Perl__new_invlist_C_array(pTHX_ const UV* const list)
+                       __attribute__warn_unused_result__
+                       __attribute__nonnull__(pTHX_1);
+#define PERL_ARGS_ASSERT__NEW_INVLIST_C_ARRAY  \
+       assert(list)
+
+#endif
 #if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_REGEXEC_C) || defined(PERL_IN_UTF8_C)
 PERL_CALLCONV SV*      Perl__get_swash_invlist(pTHX_ SV* const swash)
                        __attribute__warn_unused_result__
index 11b07ae..6c22ca5 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -5981,25 +5981,6 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
        PL_UpperLatin1 = _new_invlist_C_array(UpperLatin1_invlist);
         PL_utf8_foldable = _new_invlist_C_array(_Perl_Any_Folds_invlist);
 
-        PL_XPosix_ptrs[_CC_ASCII] = _new_invlist_C_array(ASCII_invlist);
-       PL_XPosix_ptrs[_CC_ALPHANUMERIC]
-                                = _new_invlist_C_array(XPosixAlnum_invlist);
-       PL_XPosix_ptrs[_CC_ALPHA] = _new_invlist_C_array(XPosixAlpha_invlist);
-       PL_XPosix_ptrs[_CC_BLANK] = _new_invlist_C_array(XPosixBlank_invlist);
-       PL_XPosix_ptrs[_CC_CASED] =  _new_invlist_C_array(Cased_invlist);
-       PL_XPosix_ptrs[_CC_CNTRL] = _new_invlist_C_array(XPosixCntrl_invlist);
-       PL_XPosix_ptrs[_CC_DIGIT] = _new_invlist_C_array(XPosixDigit_invlist);
-       PL_XPosix_ptrs[_CC_GRAPH] = _new_invlist_C_array(XPosixGraph_invlist);
-       PL_XPosix_ptrs[_CC_LOWER] = _new_invlist_C_array(XPosixLower_invlist);
-       PL_XPosix_ptrs[_CC_PRINT] = _new_invlist_C_array(XPosixPrint_invlist);
-       PL_XPosix_ptrs[_CC_PUNCT] = _new_invlist_C_array(XPosixPunct_invlist);
-       PL_XPosix_ptrs[_CC_SPACE] = _new_invlist_C_array(XPerlSpace_invlist);
-       PL_XPosix_ptrs[_CC_PSXSPC] = _new_invlist_C_array(XPosixSpace_invlist);
-       PL_XPosix_ptrs[_CC_UPPER] = _new_invlist_C_array(XPosixUpper_invlist);
-        PL_XPosix_ptrs[_CC_VERTSPACE] = _new_invlist_C_array(VertSpace_invlist);
-       PL_XPosix_ptrs[_CC_WORDCHAR] = _new_invlist_C_array(XPosixWord_invlist);
-       PL_XPosix_ptrs[_CC_XDIGIT] = _new_invlist_C_array(XPosixXDigit_invlist);
-
         PL_HasMultiCharFold = _new_invlist_C_array(_Perl_Multi_Char_Folds_invlist);
     }
 #endif
@@ -7655,8 +7636,8 @@ Perl__new_invlist(pTHX_ IV initial_size)
 }
 #endif
 
-STATIC SV*
-S__new_invlist_C_array(pTHX_ const UV* const list)
+SV*
+Perl__new_invlist_C_array(pTHX_ const UV* const list)
 {
     /* Return a pointer to a newly constructed inversion list, initialized to
      * point to <list>, which has to be in the exact correct inversion list