X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=utf8.c;h=5fa2aab6865221298af24f27ac71496de801cb66;hb=89ebb4a3f2a55825eeed13aaf58db5c73d2140ef;hp=5c6f2715f3427314e0746d4c033cabc21c8899ad;hpb=014ead4bccac5462b3a10654493980250e84b1d4;p=p5sagit%2Fp5-mst-13.2.git diff --git a/utf8.c b/utf8.c index 5c6f271..5fa2aab 100644 --- a/utf8.c +++ b/utf8.c @@ -38,7 +38,7 @@ within non-zero characters. =for apidoc A|U8 *|uvuni_to_utf8_flags|U8 *d|UV uv|UV flags Adds the UTF-8 representation of the Unicode codepoint C to the end -of the string C; C should be have at least C free +of the string C; C should be have at least C free bytes available. The return value is the pointer to the byte after the end of the new character. In other words, @@ -551,7 +551,7 @@ returned and retlen is set, if possible, to -1. UV Perl_utf8_to_uvchr(pTHX_ U8 *s, STRLEN *retlen) { - return Perl_utf8n_to_uvchr(aTHX_ s, UTF8_MAXLEN, retlen, + return Perl_utf8n_to_uvchr(aTHX_ s, UTF8_MAXBYTES, retlen, ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY); } @@ -575,7 +575,7 @@ UV Perl_utf8_to_uvuni(pTHX_ U8 *s, STRLEN *retlen) { /* Call the low level routine asking for checks */ - return Perl_utf8n_to_uvuni(aTHX_ s, UTF8_MAXLEN, retlen, + return Perl_utf8n_to_uvuni(aTHX_ s, UTF8_MAXBYTES, retlen, ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY); } @@ -937,7 +937,7 @@ Perl_utf16_to_utf8_reversed(pTHX_ U8* p, U8* d, I32 bytelen, I32 *newlen) bool Perl_is_uni_alnum(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN+1]; + U8 tmpbuf[UTF8_MAXBYTES+1]; uvchr_to_utf8(tmpbuf, c); return is_utf8_alnum(tmpbuf); } @@ -945,7 +945,7 @@ Perl_is_uni_alnum(pTHX_ UV c) bool Perl_is_uni_alnumc(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN+1]; + U8 tmpbuf[UTF8_MAXBYTES+1]; uvchr_to_utf8(tmpbuf, c); return is_utf8_alnumc(tmpbuf); } @@ -953,7 +953,7 @@ Perl_is_uni_alnumc(pTHX_ UV c) bool Perl_is_uni_idfirst(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN+1]; + U8 tmpbuf[UTF8_MAXBYTES+1]; uvchr_to_utf8(tmpbuf, c); return is_utf8_idfirst(tmpbuf); } @@ -961,7 +961,7 @@ Perl_is_uni_idfirst(pTHX_ UV c) bool Perl_is_uni_alpha(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN+1]; + U8 tmpbuf[UTF8_MAXBYTES+1]; uvchr_to_utf8(tmpbuf, c); return is_utf8_alpha(tmpbuf); } @@ -969,7 +969,7 @@ Perl_is_uni_alpha(pTHX_ UV c) bool Perl_is_uni_ascii(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN+1]; + U8 tmpbuf[UTF8_MAXBYTES+1]; uvchr_to_utf8(tmpbuf, c); return is_utf8_ascii(tmpbuf); } @@ -977,7 +977,7 @@ Perl_is_uni_ascii(pTHX_ UV c) bool Perl_is_uni_space(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN+1]; + U8 tmpbuf[UTF8_MAXBYTES+1]; uvchr_to_utf8(tmpbuf, c); return is_utf8_space(tmpbuf); } @@ -985,7 +985,7 @@ Perl_is_uni_space(pTHX_ UV c) bool Perl_is_uni_digit(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN+1]; + U8 tmpbuf[UTF8_MAXBYTES+1]; uvchr_to_utf8(tmpbuf, c); return is_utf8_digit(tmpbuf); } @@ -993,7 +993,7 @@ Perl_is_uni_digit(pTHX_ UV c) bool Perl_is_uni_upper(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN+1]; + U8 tmpbuf[UTF8_MAXBYTES+1]; uvchr_to_utf8(tmpbuf, c); return is_utf8_upper(tmpbuf); } @@ -1001,7 +1001,7 @@ Perl_is_uni_upper(pTHX_ UV c) bool Perl_is_uni_lower(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN+1]; + U8 tmpbuf[UTF8_MAXBYTES+1]; uvchr_to_utf8(tmpbuf, c); return is_utf8_lower(tmpbuf); } @@ -1009,7 +1009,7 @@ Perl_is_uni_lower(pTHX_ UV c) bool Perl_is_uni_cntrl(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN+1]; + U8 tmpbuf[UTF8_MAXBYTES+1]; uvchr_to_utf8(tmpbuf, c); return is_utf8_cntrl(tmpbuf); } @@ -1017,7 +1017,7 @@ Perl_is_uni_cntrl(pTHX_ UV c) bool Perl_is_uni_graph(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN+1]; + U8 tmpbuf[UTF8_MAXBYTES+1]; uvchr_to_utf8(tmpbuf, c); return is_utf8_graph(tmpbuf); } @@ -1025,7 +1025,7 @@ Perl_is_uni_graph(pTHX_ UV c) bool Perl_is_uni_print(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN+1]; + U8 tmpbuf[UTF8_MAXBYTES+1]; uvchr_to_utf8(tmpbuf, c); return is_utf8_print(tmpbuf); } @@ -1033,7 +1033,7 @@ Perl_is_uni_print(pTHX_ UV c) bool Perl_is_uni_punct(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN+1]; + U8 tmpbuf[UTF8_MAXBYTES+1]; uvchr_to_utf8(tmpbuf, c); return is_utf8_punct(tmpbuf); } @@ -1041,7 +1041,7 @@ Perl_is_uni_punct(pTHX_ UV c) bool Perl_is_uni_xdigit(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; + U8 tmpbuf[UTF8_MAXBYTES_CASE+1]; uvchr_to_utf8(tmpbuf, c); return is_utf8_xdigit(tmpbuf); } @@ -1166,7 +1166,7 @@ Perl_to_uni_upper_lc(pTHX_ U32 c) /* XXX returns only the first character -- do not use XXX */ /* XXX no locale support yet */ STRLEN len; - U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; + U8 tmpbuf[UTF8_MAXBYTES_CASE+1]; return (U32)to_uni_upper(c, tmpbuf, &len); } @@ -1176,7 +1176,7 @@ Perl_to_uni_title_lc(pTHX_ U32 c) /* XXX returns only the first character XXX -- do not use XXX */ /* XXX no locale support yet */ STRLEN len; - U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; + U8 tmpbuf[UTF8_MAXBYTES_CASE+1]; return (U32)to_uni_title(c, tmpbuf, &len); } @@ -1186,7 +1186,7 @@ Perl_to_uni_lower_lc(pTHX_ U32 c) /* XXX returns only the first character -- do not use XXX */ /* XXX no locale support yet */ STRLEN len; - U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; + U8 tmpbuf[UTF8_MAXBYTES_CASE+1]; return (U32)to_uni_lower(c, tmpbuf, &len); } @@ -1400,7 +1400,7 @@ UV Perl_to_utf8_case(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, char *normal, char *special) { UV uv0, uv1; - U8 tmpbuf[UTF8_MAXLEN_FOLD+1]; + U8 tmpbuf[UTF8_MAXBYTES_CASE+1]; STRLEN len = 0; uv0 = utf8_to_uvchr(p, 0); @@ -1489,9 +1489,8 @@ Perl_to_utf8_case(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, char *norma Convert the UTF-8 encoded character at p to its uppercase version and store that in UTF-8 in ustrp and its length in bytes in lenp. Note -that the ustrp needs to be at least UTF8_MAXLEN_UCLC+1 bytes since the -uppercase version may be longer than the original character (up to two -characters). +that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since +the uppercase version may be longer than the original character. The first character of the uppercased version is returned (but note, as explained above, that there may be more.) @@ -1510,9 +1509,8 @@ Perl_to_utf8_upper(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp) Convert the UTF-8 encoded character at p to its titlecase version and store that in UTF-8 in ustrp and its length in bytes in lenp. Note -that the ustrp needs to be at least UTF8_MAXLEN_UCLC+1 bytes since the -titlecase version may be longer than the original character (up to two -characters). +that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the +titlecase version may be longer than the original character. The first character of the titlecased version is returned (but note, as explained above, that there may be more.) @@ -1531,9 +1529,8 @@ Perl_to_utf8_title(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp) Convert the UTF-8 encoded character at p to its lowercase version and store that in UTF-8 in ustrp and its length in bytes in lenp. Note -that the ustrp needs to be at least UTF8_MAXLEN_UCLC+1 bytes since the -lowercase version may be longer than the original character (up to two -characters). +that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the +lowercase version may be longer than the original character. The first character of the lowercased version is returned (but note, as explained above, that there may be more.) @@ -1552,7 +1549,7 @@ Perl_to_utf8_lower(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp) Convert the UTF-8 encoded character at p to its foldcase version and store that in UTF-8 in ustrp and its length in bytes in lenp. Note -that the ustrp needs to be at least UTF8_MAXLEN_FOLD+1 bytes since the +that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the foldcase version may be longer than the original character (up to three characters). @@ -1711,7 +1708,7 @@ Perl_swash_fetch(pTHX_ SV *sv, U8 *ptr, bool do_utf8) /* We use utf8n_to_uvuni() as we want an index into Unicode tables, not a native character number. */ - UV code_point = utf8n_to_uvuni(ptr, UTF8_MAXLEN, 0, + UV code_point = utf8n_to_uvuni(ptr, UTF8_MAXBYTES, 0, ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY); SV *errsv_save; @@ -1778,7 +1775,7 @@ Perl_swash_fetch(pTHX_ SV *sv, U8 *ptr, bool do_utf8) =for apidoc A|U8 *|uvchr_to_utf8|U8 *d|UV uv Adds the UTF-8 representation of the Native codepoint C to the end -of the string C; C should be have at least C free +of the string C; C should be have at least C free bytes available. The return value is the pointer to the byte after the end of the new character. In other words, @@ -1954,8 +1951,8 @@ Perl_ibcmp_utf8(pTHX_ const char *s1, char **pe1, register UV l1, bool u1, const register U8 *e1 = 0, *f1 = 0, *q1 = 0; register U8 *e2 = 0, *f2 = 0, *q2 = 0; STRLEN n1 = 0, n2 = 0; - U8 foldbuf1[UTF8_MAXLEN_FOLD+1]; - U8 foldbuf2[UTF8_MAXLEN_FOLD+1]; + U8 foldbuf1[UTF8_MAXBYTES_CASE+1]; + U8 foldbuf2[UTF8_MAXBYTES_CASE+1]; U8 natbuf[1+1]; STRLEN foldlen1, foldlen2; bool match;