X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=utf8.c;h=0153fd6cd86858228ce7269f52b10395560cc3ef;hb=1be79c1b33149964355b8298e509bb8974fe3030;hp=4bb2e9bd788fd4ef190295e545271f0eabbeeb2d;hpb=0453d815b8a74697ff1e5451c27aba2fe537b8e0;p=p5sagit%2Fp5-mst-13.2.git diff --git a/utf8.c b/utf8.c index 4bb2e9b..0153fd6 100644 --- a/utf8.c +++ b/utf8.c @@ -68,8 +68,8 @@ Perl_uv_to_utf8(pTHX_ U8 *d, UV uv) *d++ = (( uv & 0x3f) | 0x80); return d; } -#ifdef Quad_t - if (uv < 0x2000000000) +#ifdef HAS_QUAD + if (uv < 0x1000000000LL) #endif { *d++ = 0xfe; /* Can't match U+FEFF! */ @@ -81,7 +81,7 @@ Perl_uv_to_utf8(pTHX_ U8 *d, UV uv) *d++ = (( uv & 0x3f) | 0x80); return d; } -#ifdef Quad_t +#ifdef HAS_QUAD { *d++ = 0xff; /* Can't match U+FFFE! */ *d++ = (((uv >> 36) & 0x3f) | 0x80); @@ -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)