This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Make invlist_search() usable from re_comp.c
authorKarl Williamson <public@khwilliamson.com>
Mon, 18 Jun 2012 17:51:43 +0000 (11:51 -0600)
committerKarl Williamson <public@khwilliamson.com>
Thu, 2 Aug 2012 15:24:52 +0000 (09:24 -0600)
This was a static function which I couldn't get to be callable from the
debugging version of regcomp.c.  This makes it public, but known only
in the regcomp.c source file.  It changes the name to begin with an
underscore so that if someone cheats by adding preprocessor #defines,
they still have to call it with the name that convention indicates is a
private function.

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

index 97b0a9f..627024a 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -1398,7 +1398,7 @@ EiMR      |UV*    |get_invlist_iter_addr  |NN SV* invlist
 EiMR   |UV*    |get_invlist_version_id_addr    |NN SV* invlist
 EiM    |void   |invlist_iterinit|NN SV* invlist
 EsMR   |bool   |invlist_iternext|NN SV* invlist|NN UV* start|NN UV* end
-EsMR   |IV     |invlist_search |NN SV* const invlist|const UV cp
+EXpMR  |IV     |_invlist_search        |NN SV* const invlist|const UV cp
 EiMR   |UV     |invlist_highest|NN SV* const invlist
 #endif
 #if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_UTF8_C)
diff --git a/embed.h b/embed.h
index bb96c46..027a5f3 100644 (file)
--- a/embed.h
+++ b/embed.h
 #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 _invlist_contains_cp(a,b)      S__invlist_contains_cp(aTHX_ a,b)
+#define _invlist_search(a,b)   Perl__invlist_search(aTHX_ a,b)
 #define _new_invlist_C_array(a)        S__new_invlist_C_array(aTHX_ a)
 #define add_alternate(a,b,c)   S_add_alternate(aTHX_ a,b,c)
 #define add_cp_to_invlist(a,b) S_add_cp_to_invlist(aTHX_ a,b)
 #define invlist_iternext(a,b,c)        S_invlist_iternext(aTHX_ a,b,c)
 #define invlist_len(a)         S_invlist_len(aTHX_ a)
 #define invlist_max(a)         S_invlist_max(aTHX_ a)
-#define invlist_search(a,b)    S_invlist_search(aTHX_ a,b)
 #define invlist_set_len(a,b)   S_invlist_set_len(aTHX_ a,b)
 #define invlist_trim(a)                S_invlist_trim(aTHX_ a)
 #define join_exact(a,b,c,d,e,f,g)      S_join_exact(aTHX_ a,b,c,d,e,f,g)
diff --git a/proto.h b/proto.h
index 433d32a..dbdf7ea 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -6365,6 +6365,12 @@ STATIC bool      S__invlist_contains_cp(pTHX_ SV* const invlist, const UV cp)
 #define PERL_ARGS_ASSERT__INVLIST_CONTAINS_CP  \
        assert(invlist)
 
+PERL_CALLCONV IV       Perl__invlist_search(pTHX_ SV* const invlist, const UV cp)
+                       __attribute__warn_unused_result__
+                       __attribute__nonnull__(pTHX_1);
+#define PERL_ARGS_ASSERT__INVLIST_SEARCH       \
+       assert(invlist)
+
 STATIC SV*     S__new_invlist_C_array(pTHX_ UV* list)
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
@@ -6511,12 +6517,6 @@ PERL_STATIC_INLINE UV    S_invlist_max(pTHX_ SV* const invlist)
 #define PERL_ARGS_ASSERT_INVLIST_MAX   \
        assert(invlist)
 
-STATIC IV      S_invlist_search(pTHX_ SV* const invlist, const UV cp)
-                       __attribute__warn_unused_result__
-                       __attribute__nonnull__(pTHX_1);
-#define PERL_ARGS_ASSERT_INVLIST_SEARCH        \
-       assert(invlist)
-
 PERL_STATIC_INLINE void        S_invlist_set_len(pTHX_ SV* const invlist, const UV len)
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_INVLIST_SET_LEN       \
index 16c5cf2..488ebeb 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -7316,8 +7316,10 @@ S__append_range_to_invlist(pTHX_ SV* const invlist, const UV start, const UV end
     }
 }
 
-STATIC IV
-S_invlist_search(pTHX_ SV* const invlist, const UV cp)
+#ifndef PERL_IN_XSUB_RE
+
+IV
+Perl__invlist_search(pTHX_ SV* const invlist, const UV cp)
 {
     /* Searches the inversion list for the entry that contains the input code
      * point <cp>.  If <cp> is not in the list, -1 is returned.  Otherwise, the
@@ -7328,7 +7330,7 @@ S_invlist_search(pTHX_ SV* const invlist, const UV cp)
     IV high = invlist_len(invlist);
     const UV * const array = invlist_array(invlist);
 
-    PERL_ARGS_ASSERT_INVLIST_SEARCH;
+    PERL_ARGS_ASSERT__INVLIST_SEARCH;
 
     /* If list is empty or the code point is before the first element, return
      * failure. */
@@ -7358,8 +7360,6 @@ S_invlist_search(pTHX_ SV* const invlist, const UV cp)
     return high - 1;
 }
 
-#ifndef PERL_IN_XSUB_RE
-
 void
 Perl__invlist_populate_swatch(pTHX_ SV* const invlist, const UV start, const UV end, U8* swatch)
 {
@@ -7384,7 +7384,7 @@ Perl__invlist_populate_swatch(pTHX_ SV* const invlist, const UV start, const UV
     array = invlist_array(invlist);
 
     /* Find which element it is */
-    i = invlist_search(invlist, start);
+    i = _invlist_search(invlist, start);
 
     /* We populate from <start> to <end> */
     while (current < end) {
@@ -7952,7 +7952,7 @@ S__invlist_contains_cp(pTHX_ SV* const invlist, const UV cp)
 {
     /* Does <invlist> contain code point <cp> as part of the set? */
 
-    IV index = invlist_search(invlist, cp);
+    IV index = _invlist_search(invlist, cp);
 
     PERL_ARGS_ASSERT__INVLIST_CONTAINS_CP;