This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c, regexec.c: Move common code to a function
authorKarl Williamson <khw@cpan.org>
Tue, 29 Apr 2014 01:48:40 +0000 (19:48 -0600)
committerKarl Williamson <khw@cpan.org>
Fri, 30 May 2014 16:24:27 +0000 (10:24 -0600)
There are other cases where this functionality will be needed as well.

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

index 478e748..3510fed 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -1529,6 +1529,7 @@ ApM       |SV*    |_get_regclass_nonbitmap_data                              \
                                |NN const struct regnode *node|bool doinit \
                                |NULLOK SV **listsvp                       \
                                |NULLOK SV **lonly_utf8_locale
+EXp    |void|_load_PL_utf8_foldclosures|
 #endif
 #if defined(PERL_IN_REGCOMP_C) || defined (PERL_IN_DUMP_C)
 EXMp   |void   |_invlist_dump  |NN PerlIO *file|I32 level   \
diff --git a/embed.h b/embed.h
index 6ef7266..481bdac 100644 (file)
--- a/embed.h
+++ b/embed.h
 #  if defined(PERL_IN_REGCOMP_C) || defined (PERL_IN_DUMP_C)
 #define _invlist_dump(a,b,c,d) Perl__invlist_dump(aTHX_ a,b,c,d)
 #  endif
+#  if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_REGEXEC_C)
+#define _load_PL_utf8_foldclosures()   Perl__load_PL_utf8_foldclosures(aTHX)
+#  endif
 #  if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_REGEXEC_C) || defined(PERL_IN_UTF8_C)
 #define _get_swash_invlist(a)  Perl__get_swash_invlist(aTHX_ a)
 #define _invlist_contains_cp(a,b)      S__invlist_contains_cp(aTHX_ a,b)
diff --git a/proto.h b/proto.h
index 7a71622..f5793cc 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -7025,6 +7025,7 @@ PERL_CALLCONV SV* Perl__get_regclass_nonbitmap_data(pTHX_ const regexp *prog, co
 #define PERL_ARGS_ASSERT__GET_REGCLASS_NONBITMAP_DATA  \
        assert(node)
 
+PERL_CALLCONV void     Perl__load_PL_utf8_foldclosures(pTHX);
 #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)
index 236cb24..df56350 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -9069,6 +9069,23 @@ Perl__invlist_dump(pTHX_ PerlIO *file, I32 level,
         count += 2;
     }
 }
+
+void
+Perl__load_PL_utf8_foldclosures (pTHX)
+{
+    assert(! PL_utf8_foldclosures);
+
+    /* If the folds haven't been read in, call a fold function
+     * to force that */
+    if (! PL_utf8_tofold) {
+        U8 dummy[UTF8_MAXBYTES_CASE+1];
+
+        /* This string is just a short named one above \xff */
+        to_utf8_fold((U8*) HYPHEN_UTF8, dummy, NULL);
+        assert(PL_utf8_tofold); /* Verify that worked */
+    }
+    PL_utf8_foldclosures = _swash_inversion_hash(PL_utf8_tofold);
+}
 #endif
 
 #ifdef PERL_ARGS_ASSERT__INVLISTEQ
@@ -14316,18 +14333,7 @@ parseit:
                 /* This is a hash that for a particular fold gives all
                  * characters that are involved in it */
                 if (! PL_utf8_foldclosures) {
-
-                    /* If the folds haven't been read in, call a fold function
-                     * to force that */
-                    if (! PL_utf8_tofold) {
-                        U8 dummy[UTF8_MAXBYTES_CASE+1];
-
-                        /* This string is just a short named one above \xff */
-                        to_utf8_fold((U8*) HYPHEN_UTF8, dummy, NULL);
-                        assert(PL_utf8_tofold); /* Verify that worked */
-                    }
-                    PL_utf8_foldclosures
-                                      = _swash_inversion_hash(PL_utf8_tofold);
+                    _load_PL_utf8_foldclosures();
                 }
             }
 
index d4a7fdd..32c446f 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -3698,14 +3698,7 @@ S_setup_EXACTISH_ST_c1_c2(pTHX_ const regnode * const text_node, int *c1p,
                 /* Load the folds hash, if not already done */
                 SV** listp;
                 if (! PL_utf8_foldclosures) {
-                    if (! PL_utf8_tofold) {
-                        U8 dummy[UTF8_MAXBYTES_CASE+1];
-
-                        /* Force loading this by folding an above-Latin1 char */
-                        to_utf8_fold((U8*) HYPHEN_UTF8, dummy, NULL);
-                        assert(PL_utf8_tofold); /* Verify that worked */
-                    }
-                    PL_utf8_foldclosures = _swash_inversion_hash(PL_utf8_tofold);
+                    _load_PL_utf8_foldclosures();
                 }
 
                 /* The fold closures data structure is a hash with the keys