Deprecate some functions in utf8.c
authorKarl Williamson <public@khwilliamson.com>
Fri, 7 Dec 2012 04:41:23 +0000 (21:41 -0700)
committerKarl Williamson <public@khwilliamson.com>
Sun, 9 Dec 2012 17:30:02 +0000 (10:30 -0700)
These functions are not used by the Perl core.  Code should be using
the equivalent macros in handy.h that may avoid a function call.

embed.fnc
pod/perldelta.pod
proto.h
utf8.c

index c84b12a..b851e3c 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -602,24 +602,24 @@ pR        |OP*    |invert         |NULLOK OP* cmd
 ApR    |I32    |is_lvalue_sub
 : Used in cop.h
 XopR   |I32    |was_lvalue_sub
-AMpPR  |U32    |to_uni_upper_lc|U32 c
-AMpPR  |U32    |to_uni_title_lc|U32 c
-AMpPR  |U32    |to_uni_lower_lc|U32 c
+ADMpPR |U32    |to_uni_upper_lc|U32 c
+ADMpPR |U32    |to_uni_title_lc|U32 c
+ADMpPR |U32    |to_uni_lower_lc|U32 c
 AMpPR  |bool   |is_uni_alnum   |UV c
 AMpPR  |bool   |is_uni_alnumc  |UV c
 AMpPR  |bool   |is_uni_idfirst |UV c
 AMpPR  |bool   |is_uni_alpha   |UV c
-AMpPR  |bool   |is_uni_ascii   |UV c
-AMpPR  |bool   |is_uni_blank   |UV c
-AMpPR  |bool   |is_uni_space   |UV c
-AMpPR  |bool   |is_uni_cntrl   |UV c
+ADMpPR |bool   |is_uni_ascii   |UV c
+ADMpPR |bool   |is_uni_blank   |UV c
+ADMpPR |bool   |is_uni_space   |UV c
+ADMpPR |bool   |is_uni_cntrl   |UV c
 AMpPR  |bool   |is_uni_graph   |UV c
 AMpPR  |bool   |is_uni_digit   |UV c
 AMpPR  |bool   |is_uni_upper   |UV c
 AMpPR  |bool   |is_uni_lower   |UV c
 AMpPR  |bool   |is_uni_print   |UV c
 AMpPR  |bool   |is_uni_punct   |UV c
-AMpPR  |bool   |is_uni_xdigit  |UV c
+ADMpPR |bool   |is_uni_xdigit  |UV c
 AMp    |UV     |to_uni_upper   |UV c|NN U8 *p|NN STRLEN *lenp
 AMp    |UV     |to_uni_title   |UV c|NN U8 *p|NN STRLEN *lenp
 #ifdef PERL_IN_UTF8_C
@@ -638,20 +638,20 @@ AMmp      |UV     |to_uni_fold    |UV c|NN U8 *p|NN STRLEN *lenp
 AMp    |UV     |_to_uni_fold_flags|UV c|NN U8 *p|NN STRLEN *lenp|const U8 flags
 AMpPR  |bool   |is_uni_alnum_lc|UV c
 AMpPR  |bool   |is_uni_alnumc_lc|UV c
-AMpPR  |bool   |is_uni_idfirst_lc|UV c
+ADMpPR |bool   |is_uni_idfirst_lc|UV c
 AMpR   |bool   |_is_uni_perl_idstart|UV c
 AMpPR  |bool   |is_uni_alpha_lc|UV c
-AMpPR  |bool   |is_uni_ascii_lc|UV c
-AMpPR  |bool   |is_uni_space_lc|UV c
-AMpPR  |bool   |is_uni_blank_lc|UV c
-AMpPR  |bool   |is_uni_cntrl_lc|UV c
+ADMpPR |bool   |is_uni_ascii_lc|UV c
+ADMpPR |bool   |is_uni_space_lc|UV c
+ADMpPR |bool   |is_uni_blank_lc|UV c
+ADMpPR |bool   |is_uni_cntrl_lc|UV c
 AMpPR  |bool   |is_uni_graph_lc|UV c
 AMpPR  |bool   |is_uni_digit_lc|UV c
 AMpPR  |bool   |is_uni_upper_lc|UV c
 AMpPR  |bool   |is_uni_lower_lc|UV c
 AMpPR  |bool   |is_uni_print_lc|UV c
 AMpPR  |bool   |is_uni_punct_lc|UV c
-AMpPR  |bool   |is_uni_xdigit_lc|UV c
+ADMpPR |bool   |is_uni_xdigit_lc|UV c
 Anpd   |bool   |is_ascii_string|NN const U8 *s|STRLEN len
 AnpdD  |STRLEN |is_utf8_char   |NN const U8 *s
 Anpd   |STRLEN |is_utf8_char_buf|NN const U8 *buf|NN const U8 *buf_end
@@ -660,26 +660,26 @@ Anpdmb    |bool   |is_utf8_string_loc|NN const U8 *s|STRLEN len|NULLOK const U8 **ep
 Anpd   |bool   |is_utf8_string_loclen|NN const U8 *s|STRLEN len|NULLOK const U8 **ep|NULLOK STRLEN *el
 AMpR   |bool   |is_utf8_alnum  |NN const U8 *p
 AMpR   |bool   |is_utf8_alnumc |NN const U8 *p
-AMpR   |bool   |is_utf8_idfirst|NN const U8 *p
-AMpR   |bool   |is_utf8_xidfirst|NN const U8 *p
+ADMpR  |bool   |is_utf8_idfirst|NN const U8 *p
+ADMpR  |bool   |is_utf8_xidfirst|NN const U8 *p
 AMpR   |bool   |_is_utf8_perl_idstart|NN const U8 *p
-AMpR   |bool   |is_utf8_idcont |NN const U8 *p
-AMpR   |bool   |is_utf8_xidcont        |NN const U8 *p
+ADMpR  |bool   |is_utf8_idcont |NN const U8 *p
+ADMpR  |bool   |is_utf8_xidcont        |NN const U8 *p
 AMpR   |bool   |is_utf8_alpha  |NN const U8 *p
-AMpR   |bool   |is_utf8_ascii  |NN const U8 *p
-AMpR   |bool   |is_utf8_blank  |NN const U8 *p
-AMpR   |bool   |is_utf8_space  |NN const U8 *p
-AMpR   |bool   |is_utf8_perl_space     |NN const U8 *p
-AMpR   |bool   |is_utf8_perl_word      |NN const U8 *p
-AMpR   |bool   |is_utf8_cntrl  |NN const U8 *p
+ADMpR  |bool   |is_utf8_ascii  |NN const U8 *p
+ADMpR  |bool   |is_utf8_blank  |NN const U8 *p
+ADMpR  |bool   |is_utf8_space  |NN const U8 *p
+ADMpR  |bool   |is_utf8_perl_space     |NN const U8 *p
+ADMpR  |bool   |is_utf8_perl_word      |NN const U8 *p
+ADMpR  |bool   |is_utf8_cntrl  |NN const U8 *p
 AMpR   |bool   |is_utf8_digit  |NN const U8 *p
-AMpR   |bool   |is_utf8_posix_digit    |NN const U8 *p
+ADMpR  |bool   |is_utf8_posix_digit    |NN const U8 *p
 AMpR   |bool   |is_utf8_graph  |NN const U8 *p
 AMpR   |bool   |is_utf8_upper  |NN const U8 *p
 AMpR   |bool   |is_utf8_lower  |NN const U8 *p
 AMpR   |bool   |is_utf8_print  |NN const U8 *p
 AMpR   |bool   |is_utf8_punct  |NN const U8 *p
-AMpR   |bool   |is_utf8_xdigit |NN const U8 *p
+ADMpR  |bool   |is_utf8_xdigit |NN const U8 *p
 AMpR   |bool   |is_utf8_mark   |NN const U8 *p
 : Used in perly.y
 p      |OP*    |jmaybe         |NN OP *o
index 0f1c89a..b3996e5 100644 (file)
@@ -53,6 +53,41 @@ an updated module in the L</Modules and Pragmata> section.
 
 [ List each deprecation as a =head2 entry ]
 
+=head2 Various XS-callable functions are now deprecated
+
+The following functions will be removed from a future version of Perl,
+and should not be used.  With participating C compilers (e.g., gcc),
+compiling any file that uses any of these will generate a warning.
+These were not intended for public use; there are equivalent, faster,
+macros for most of them.  See L<perlapi/Character classes>:
+C<is_uni_ascii>,
+C<is_uni_ascii_lc>,
+C<is_uni_blank>,
+C<is_uni_blank_lc>,
+C<is_uni_cntrl>,
+C<is_uni_cntrl_lc>,
+C<is_uni_idfirst_lc>,
+C<is_uni_space>,
+C<is_uni_space_lc>,
+C<is_uni_xdigit>,
+C<is_uni_xdigit_lc>,
+C<is_utf8_ascii>,
+C<is_utf8_blank>,
+C<is_utf8_cntrl>,
+C<is_utf8_idcont>,
+C<is_utf8_idfirst>,
+C<is_utf8_perl_space>,
+C<is_utf8_perl_word>,
+C<is_utf8_posix_digit>,
+C<is_utf8_space>,
+C<is_utf8_xdigit>.
+C<is_utf8_xidcont>,
+C<is_utf8_xidfirst>,
+C<to_uni_lower_lc>,
+C<to_uni_title_lc>,
+and
+C<to_uni_upper_lc>.
+
 =head1 Performance Enhancements
 
 XXX Changes which enhance performance without changing behaviour go here.
diff --git a/proto.h b/proto.h
index ec49374..65049a1 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -1698,26 +1698,32 @@ PERL_CALLCONV bool      Perl_is_uni_alpha_lc(pTHX_ UV c)
                        __attribute__pure__;
 
 PERL_CALLCONV bool     Perl_is_uni_ascii(pTHX_ UV c)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__pure__;
 
 PERL_CALLCONV bool     Perl_is_uni_ascii_lc(pTHX_ UV c)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__pure__;
 
 PERL_CALLCONV bool     Perl_is_uni_blank(pTHX_ UV c)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__pure__;
 
 PERL_CALLCONV bool     Perl_is_uni_blank_lc(pTHX_ UV c)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__pure__;
 
 PERL_CALLCONV bool     Perl_is_uni_cntrl(pTHX_ UV c)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__pure__;
 
 PERL_CALLCONV bool     Perl_is_uni_cntrl_lc(pTHX_ UV c)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__pure__;
 
@@ -1742,6 +1748,7 @@ PERL_CALLCONV bool        Perl_is_uni_idfirst(pTHX_ UV c)
                        __attribute__pure__;
 
 PERL_CALLCONV bool     Perl_is_uni_idfirst_lc(pTHX_ UV c)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__pure__;
 
@@ -1770,10 +1777,12 @@ PERL_CALLCONV bool      Perl_is_uni_punct_lc(pTHX_ UV c)
                        __attribute__pure__;
 
 PERL_CALLCONV bool     Perl_is_uni_space(pTHX_ UV c)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__pure__;
 
 PERL_CALLCONV bool     Perl_is_uni_space_lc(pTHX_ UV c)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__pure__;
 
@@ -1786,10 +1795,12 @@ PERL_CALLCONV bool      Perl_is_uni_upper_lc(pTHX_ UV c)
                        __attribute__pure__;
 
 PERL_CALLCONV bool     Perl_is_uni_xdigit(pTHX_ UV c)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__pure__;
 
 PERL_CALLCONV bool     Perl_is_uni_xdigit_lc(pTHX_ UV c)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__pure__;
 
@@ -1812,12 +1823,14 @@ PERL_CALLCONV bool      Perl_is_utf8_alpha(pTHX_ const U8 *p)
        assert(p)
 
 PERL_CALLCONV bool     Perl_is_utf8_ascii(pTHX_ const U8 *p)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_IS_UTF8_ASCII \
        assert(p)
 
 PERL_CALLCONV bool     Perl_is_utf8_blank(pTHX_ const U8 *p)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_IS_UTF8_BLANK \
@@ -1836,6 +1849,7 @@ PERL_CALLCONV STRLEN      Perl_is_utf8_char_buf(const U8 *buf, const U8 *buf_end)
        assert(buf); assert(buf_end)
 
 PERL_CALLCONV bool     Perl_is_utf8_cntrl(pTHX_ const U8 *p)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_IS_UTF8_CNTRL \
@@ -1854,12 +1868,14 @@ PERL_CALLCONV bool      Perl_is_utf8_graph(pTHX_ const U8 *p)
        assert(p)
 
 PERL_CALLCONV bool     Perl_is_utf8_idcont(pTHX_ const U8 *p)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_IS_UTF8_IDCONT        \
        assert(p)
 
 PERL_CALLCONV bool     Perl_is_utf8_idfirst(pTHX_ const U8 *p)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_IS_UTF8_IDFIRST       \
@@ -1878,18 +1894,21 @@ PERL_CALLCONV bool      Perl_is_utf8_mark(pTHX_ const U8 *p)
        assert(p)
 
 PERL_CALLCONV bool     Perl_is_utf8_perl_space(pTHX_ const U8 *p)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_IS_UTF8_PERL_SPACE    \
        assert(p)
 
 PERL_CALLCONV bool     Perl_is_utf8_perl_word(pTHX_ const U8 *p)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_IS_UTF8_PERL_WORD     \
        assert(p)
 
 PERL_CALLCONV bool     Perl_is_utf8_posix_digit(pTHX_ const U8 *p)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_IS_UTF8_POSIX_DIGIT   \
@@ -1908,6 +1927,7 @@ PERL_CALLCONV bool        Perl_is_utf8_punct(pTHX_ const U8 *p)
        assert(p)
 
 PERL_CALLCONV bool     Perl_is_utf8_space(pTHX_ const U8 *p)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_IS_UTF8_SPACE \
@@ -1935,18 +1955,21 @@ PERL_CALLCONV bool      Perl_is_utf8_upper(pTHX_ const U8 *p)
        assert(p)
 
 PERL_CALLCONV bool     Perl_is_utf8_xdigit(pTHX_ const U8 *p)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_IS_UTF8_XDIGIT        \
        assert(p)
 
 PERL_CALLCONV bool     Perl_is_utf8_xidcont(pTHX_ const U8 *p)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_IS_UTF8_XIDCONT       \
        assert(p)
 
 PERL_CALLCONV bool     Perl_is_utf8_xidfirst(pTHX_ const U8 *p)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_IS_UTF8_XIDFIRST      \
@@ -4463,6 +4486,7 @@ PERL_CALLCONV UV  Perl_to_uni_lower(pTHX_ UV c, U8 *p, STRLEN *lenp)
        assert(p); assert(lenp)
 
 PERL_CALLCONV U32      Perl_to_uni_lower_lc(pTHX_ U32 c)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__pure__;
 
@@ -4473,6 +4497,7 @@ PERL_CALLCONV UV  Perl_to_uni_title(pTHX_ UV c, U8 *p, STRLEN *lenp)
        assert(p); assert(lenp)
 
 PERL_CALLCONV U32      Perl_to_uni_title_lc(pTHX_ U32 c)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__pure__;
 
@@ -4483,6 +4508,7 @@ PERL_CALLCONV UV  Perl_to_uni_upper(pTHX_ UV c, U8 *p, STRLEN *lenp)
        assert(p); assert(lenp)
 
 PERL_CALLCONV U32      Perl_to_uni_upper_lc(pTHX_ U32 c)
+                       __attribute__deprecated__
                        __attribute__warn_unused_result__
                        __attribute__pure__;
 
diff --git a/utf8.c b/utf8.c
index 215ff7a..e1597bc 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -1498,12 +1498,24 @@ Perl_is_uni_alnumc(pTHX_ UV c)
     return is_utf8_alnumc(tmpbuf);
 }
 
+bool    /* Internal function so we can deprecate the external one, and call
+           this one from other deprecated functions in this file */
+S_is_utf8_idfirst(pTHX_ const U8 *p)
+{
+    dVAR;
+
+    if (*p == '_')
+       return TRUE;
+    /* is_utf8_idstart would be more logical. */
+    return is_utf8_common(p, &PL_utf8_idstart, "IdStart");
+}
+
 bool
 Perl_is_uni_idfirst(pTHX_ UV c)
 {
     U8 tmpbuf[UTF8_MAXBYTES+1];
     uvchr_to_utf8(tmpbuf, c);
-    return is_utf8_idfirst(tmpbuf);
+    return S_is_utf8_idfirst(aTHX_ tmpbuf);
 }
 
 bool
@@ -1873,7 +1885,7 @@ Perl_is_uni_blank_lc(pTHX_ UV c)
     if (c < 256) {
         return isBLANK_LC(UNI_TO_NATIVE(c));
     }
-    return is_uni_blank(c);
+    return isBLANK_uni(c);
 }
 
 bool
@@ -1882,7 +1894,7 @@ Perl_is_uni_space_lc(pTHX_ UV c)
     if (c < 256) {
         return isSPACE_LC(UNI_TO_NATIVE(c));
     }
-    return is_uni_space(c);
+    return isSPACE_uni(c);
 }
 
 bool
@@ -1918,7 +1930,7 @@ Perl_is_uni_cntrl_lc(pTHX_ UV c)
     if (c < 256) {
         return isCNTRL_LC(UNI_TO_NATIVE(c));
     }
-    return is_uni_cntrl(c);
+    return 0;
 }
 
 bool
@@ -1954,7 +1966,7 @@ Perl_is_uni_xdigit_lc(pTHX_ UV c)
     if (c < 256) {
        return isXDIGIT_LC(UNI_TO_NATIVE(c));
     }
-    return is_uni_xdigit(c);
+    return isXDIGIT_uni(c);
 }
 
 U32
@@ -2050,10 +2062,7 @@ Perl_is_utf8_idfirst(pTHX_ const U8 *p) /* The naming is historical. */
 
     PERL_ARGS_ASSERT_IS_UTF8_IDFIRST;
 
-    if (*p == '_')
-       return TRUE;
-    /* is_utf8_idstart would be more logical. */
-    return is_utf8_common(p, &PL_utf8_idstart, "IdStart");
+    return S_is_utf8_idfirst(aTHX_ p);
 }
 
 bool