From a27992ccf5d1a0c50667fb21ba8ca973f50a7508 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Tue, 26 Feb 2013 11:26:09 -0700 Subject: [PATCH] Convert uvuni_to_utf8() to function Code should almost never be dealing with non-native code points This is in preparation for later deprecation when our CPAN modules have been converted away from using it. --- embed.fnc | 2 +- embed.h | 1 + proto.h | 4 ++-- utf8.c | 10 ++++------ utf8.h | 3 +-- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/embed.fnc b/embed.fnc index 75fb103..23c4311 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1562,7 +1562,7 @@ Apd |U8* |uvchr_to_utf8 |NN U8 *d|UV uv Apdbm |U8* |uvchr_to_utf8 |NN U8 *d|UV uv #endif -Apbm |U8* |uvuni_to_utf8 |NN U8 *d|UV uv +Ap |U8* |uvuni_to_utf8 |NN U8 *d|UV uv Ap |U8* |uvchr_to_utf8_flags |NN U8 *d|UV uv|UV flags Apd |U8* |uvuni_to_utf8_flags |NN U8 *d|UV uv|UV flags Apd |char* |pv_uni_display |NN SV *dsv|NN const U8 *spv|STRLEN len|STRLEN pvlim|UV flags diff --git a/embed.h b/embed.h index d150991..b4a56d6 100644 --- a/embed.h +++ b/embed.h @@ -698,6 +698,7 @@ #define utf8_to_uvuni_buf(a,b,c) Perl_utf8_to_uvuni_buf(aTHX_ a,b,c) #define utf8n_to_uvuni(a,b,c,d) Perl_utf8n_to_uvuni(aTHX_ a,b,c,d) #define uvchr_to_utf8_flags(a,b,c) Perl_uvchr_to_utf8_flags(aTHX_ a,b,c) +#define uvuni_to_utf8(a,b) Perl_uvuni_to_utf8(aTHX_ a,b) #define uvuni_to_utf8_flags(a,b,c) Perl_uvuni_to_utf8_flags(aTHX_ a,b,c) #define valid_utf8_to_uvchr(a,b) Perl_valid_utf8_to_uvchr(aTHX_ a,b) #define valid_utf8_to_uvuni(a,b) Perl_valid_utf8_to_uvuni(aTHX_ a,b) diff --git a/proto.h b/proto.h index 40a4cc0..5356ddb 100644 --- a/proto.h +++ b/proto.h @@ -4777,8 +4777,8 @@ PERL_CALLCONV U8* Perl_uvchr_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags) #define PERL_ARGS_ASSERT_UVCHR_TO_UTF8_FLAGS \ assert(d) -/* PERL_CALLCONV U8* Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv) - __attribute__nonnull__(pTHX_1); */ +PERL_CALLCONV U8* Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv) + __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_UVUNI_TO_UTF8 \ assert(d) diff --git a/utf8.c b/utf8.c index b1dc30b..22f5331 100644 --- a/utf8.c +++ b/utf8.c @@ -89,7 +89,9 @@ Perl_is_ascii_string(const U8 *s, STRLEN len) /* =for apidoc uvuni_to_utf8_flags -Adds the UTF-8 representation of the Unicode code point C to the end +THIS FUNCTION SHOULD BE USED IN ONLY VERY SPECIALIZED CIRCUMSTANCES. + +It adds the UTF-8 representation of the Unicode code point C to the end of the string C; C should 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, @@ -98,13 +100,9 @@ end of the new character. In other words, or, in most cases, - d = uvuni_to_utf8(d, uv); - -(which is equivalent to) - d = uvuni_to_utf8_flags(d, uv, 0); -This is the recommended Unicode-aware way of saying +This is the Unicode-aware way of saying *(d++) = uv; diff --git a/utf8.h b/utf8.h index d8ca84e..251e32d 100644 --- a/utf8.h +++ b/utf8.h @@ -44,7 +44,6 @@ #define to_utf8_title(a,b,c) _to_utf8_title_flags(a,b,c,0, NULL) /* Source backward compatibility. */ -#define uvuni_to_utf8(d, uv) uvuni_to_utf8_flags(d, uv, 0) #define is_utf8_string_loc(s, len, ep) is_utf8_string_loclen(s, len, ep, 0) #define foldEQ_utf8(s1, pe1, l1, u1, s2, pe2, l2, u2) \ @@ -125,7 +124,7 @@ END_EXTERN_C /* As there are no translations, avoid the function wrapper */ #define utf8n_to_uvchr utf8n_to_uvuni -#define uvchr_to_utf8 uvuni_to_utf8 +#define uvchr_to_utf8(a,b) uvuni_to_utf8_flags(a,b,0) /* -- 2.7.4