This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
INSTALL =~ s/5.006/5.6/; delay loading Errno until needed
[perl5.git] / utf8.c
diff --git a/utf8.c b/utf8.c
index 4bb2e9b..a470376 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -261,6 +261,14 @@ Perl_is_uni_alnum(pTHX_ U32 c)
 }
 
 bool
+Perl_is_uni_alnumc(pTHX_ U32 c)
+{
+    U8 tmpbuf[10];
+    uv_to_utf8(tmpbuf, (UV)c);
+    return is_utf8_alnumc(tmpbuf);
+}
+
+bool
 Perl_is_uni_idfirst(pTHX_ U32 c)
 {
     U8 tmpbuf[10];
@@ -277,6 +285,14 @@ Perl_is_uni_alpha(pTHX_ U32 c)
 }
 
 bool
+Perl_is_uni_ascii(pTHX_ U32 c)
+{
+    U8 tmpbuf[10];
+    uv_to_utf8(tmpbuf, (UV)c);
+    return is_utf8_ascii(tmpbuf);
+}
+
+bool
 Perl_is_uni_space(pTHX_ U32 c)
 {
     U8 tmpbuf[10];
@@ -309,6 +325,22 @@ Perl_is_uni_lower(pTHX_ U32 c)
 }
 
 bool
+Perl_is_uni_cntrl(pTHX_ U32 c)
+{
+    U8 tmpbuf[10];
+    uv_to_utf8(tmpbuf, (UV)c);
+    return is_utf8_cntrl(tmpbuf);
+}
+
+bool
+Perl_is_uni_graph(pTHX_ U32 c)
+{
+    U8 tmpbuf[10];
+    uv_to_utf8(tmpbuf, (UV)c);
+    return is_utf8_graph(tmpbuf);
+}
+
+bool
 Perl_is_uni_print(pTHX_ U32 c)
 {
     U8 tmpbuf[10];
@@ -316,6 +348,22 @@ Perl_is_uni_print(pTHX_ U32 c)
     return is_utf8_print(tmpbuf);
 }
 
+bool
+Perl_is_uni_punct(pTHX_ U32 c)
+{
+    U8 tmpbuf[10];
+    uv_to_utf8(tmpbuf, (UV)c);
+    return is_utf8_punct(tmpbuf);
+}
+
+bool
+Perl_is_uni_xdigit(pTHX_ U32 c)
+{
+    U8 tmpbuf[10];
+    uv_to_utf8(tmpbuf, (UV)c);
+    return is_utf8_xdigit(tmpbuf);
+}
+
 U32
 Perl_to_uni_upper(pTHX_ U32 c)
 {
@@ -349,6 +397,12 @@ Perl_is_uni_alnum_lc(pTHX_ U32 c)
 }
 
 bool
+Perl_is_uni_alnumc_lc(pTHX_ U32 c)
+{
+    return is_uni_alnumc(c);   /* XXX no locale support yet */
+}
+
+bool
 Perl_is_uni_idfirst_lc(pTHX_ U32 c)
 {
     return is_uni_idfirst(c);  /* XXX no locale support yet */
@@ -361,6 +415,12 @@ Perl_is_uni_alpha_lc(pTHX_ U32 c)
 }
 
 bool
+Perl_is_uni_ascii_lc(pTHX_ U32 c)
+{
+    return is_uni_ascii(c);    /* XXX no locale support yet */
+}
+
+bool
 Perl_is_uni_space_lc(pTHX_ U32 c)
 {
     return is_uni_space(c);    /* XXX no locale support yet */
@@ -385,11 +445,35 @@ Perl_is_uni_lower_lc(pTHX_ U32 c)
 }
 
 bool
+Perl_is_uni_cntrl_lc(pTHX_ U32 c)
+{
+    return is_uni_cntrl(c);    /* XXX no locale support yet */
+}
+
+bool
+Perl_is_uni_graph_lc(pTHX_ U32 c)
+{
+    return is_uni_graph(c);    /* XXX no locale support yet */
+}
+
+bool
 Perl_is_uni_print_lc(pTHX_ U32 c)
 {
     return is_uni_print(c);    /* XXX no locale support yet */
 }
 
+bool
+Perl_is_uni_punct_lc(pTHX_ U32 c)
+{
+    return is_uni_punct(c);    /* XXX no locale support yet */
+}
+
+bool
+Perl_is_uni_xdigit_lc(pTHX_ U32 c)
+{
+    return is_uni_xdigit(c);   /* XXX no locale support yet */
+}
+
 U32
 Perl_to_uni_upper_lc(pTHX_ U32 c)
 {
@@ -408,7 +492,6 @@ Perl_to_uni_lower_lc(pTHX_ U32 c)
     return to_uni_lower(c);    /* XXX no locale support yet */
 }
 
-
 bool
 Perl_is_utf8_alnum(pTHX_ U8 *p)
 {
@@ -425,6 +508,21 @@ Perl_is_utf8_alnum(pTHX_ U8 *p)
 }
 
 bool
+Perl_is_utf8_alnumc(pTHX_ U8 *p)
+{
+    if (!PL_utf8_alnum)
+       PL_utf8_alnum = swash_init("utf8", "IsAlnumC", &PL_sv_undef, 0, 0);
+    return swash_fetch(PL_utf8_alnum, p);
+/*    return is_utf8_alpha(p) || is_utf8_digit(p); */
+#ifdef SURPRISINGLY_SLOWER  /* probably because alpha is usually true */
+    if (!PL_utf8_alnum)
+       PL_utf8_alnum = swash_init("utf8", "",
+           sv_2mortal(newSVpv("+utf8::IsAlpha\n+utf8::IsDigit\n005F\n",0)), 0, 0);
+    return swash_fetch(PL_utf8_alnum, p);
+#endif
+}
+
+bool
 Perl_is_utf8_idfirst(pTHX_ U8 *p)
 {
     return *p == '_' || is_utf8_alpha(p);
@@ -439,6 +537,14 @@ Perl_is_utf8_alpha(pTHX_ U8 *p)
 }
 
 bool
+Perl_is_utf8_ascii(pTHX_ U8 *p)
+{
+    if (!PL_utf8_ascii)
+       PL_utf8_ascii = swash_init("utf8", "IsAscii", &PL_sv_undef, 0, 0);
+    return swash_fetch(PL_utf8_ascii, p);
+}
+
+bool
 Perl_is_utf8_space(pTHX_ U8 *p)
 {
     if (!PL_utf8_space)
@@ -471,6 +577,22 @@ Perl_is_utf8_lower(pTHX_ U8 *p)
 }
 
 bool
+Perl_is_utf8_cntrl(pTHX_ U8 *p)
+{
+    if (!PL_utf8_cntrl)
+       PL_utf8_cntrl = swash_init("utf8", "IsCntrl", &PL_sv_undef, 0, 0);
+    return swash_fetch(PL_utf8_cntrl, p);
+}
+
+bool
+Perl_is_utf8_graph(pTHX_ U8 *p)
+{
+    if (!PL_utf8_graph)
+       PL_utf8_graph = swash_init("utf8", "IsGraph", &PL_sv_undef, 0, 0);
+    return swash_fetch(PL_utf8_graph, p);
+}
+
+bool
 Perl_is_utf8_print(pTHX_ U8 *p)
 {
     if (!PL_utf8_print)
@@ -479,6 +601,22 @@ Perl_is_utf8_print(pTHX_ U8 *p)
 }
 
 bool
+Perl_is_utf8_punct(pTHX_ U8 *p)
+{
+    if (!PL_utf8_punct)
+       PL_utf8_punct = swash_init("utf8", "IsPunct", &PL_sv_undef, 0, 0);
+    return swash_fetch(PL_utf8_punct, p);
+}
+
+bool
+Perl_is_utf8_xdigit(pTHX_ U8 *p)
+{
+    if (!PL_utf8_xdigit)
+       PL_utf8_xdigit = swash_init("utf8", "IsXDigit", &PL_sv_undef, 0, 0);
+    return swash_fetch(PL_utf8_xdigit, p);
+}
+
+bool
 Perl_is_utf8_mark(pTHX_ U8 *p)
 {
     if (!PL_utf8_mark)