ns |bool |need_utf8 |NN const char *pat|NN const char *patend
ns |char |first_symbol |NN const char *pat|NN const char *patend
sR |char * |sv_exp_grow |NN SV *sv|STRLEN needed
+sR |char * |bytes_to_uni |NN const U8 *start|STRLEN len|NN char *dest
#endif
#if defined(PERL_IN_PP_CTL_C) || defined(PERL_DECL_PROT)
#define need_utf8 S_need_utf8
#define first_symbol S_first_symbol
#define sv_exp_grow S_sv_exp_grow
+#define bytes_to_uni S_bytes_to_uni
#endif
#endif
#if defined(PERL_IN_PP_CTL_C) || defined(PERL_DECL_PROT)
#define need_utf8 S_need_utf8
#define first_symbol S_first_symbol
#define sv_exp_grow(a,b) S_sv_exp_grow(aTHX_ a,b)
+#define bytes_to_uni(a,b,c) S_bytes_to_uni(aTHX_ a,b,c)
#endif
#endif
#if defined(PERL_IN_PP_CTL_C) || defined(PERL_DECL_PROT)
return TRUE;
}
-STATIC void
-bytes_to_uni(pTHX_ const U8 *start, STRLEN len, char **dest) {
- U8 buffer[UTF8_MAXLEN];
+STATIC char *
+S_bytes_to_uni(pTHX_ const U8 *start, STRLEN len, char *dest) {
const U8 * const end = start + len;
- char *d = *dest;
+
while (start < end) {
+ U8 buffer[UTF8_MAXLEN];
const int length =
uvuni_to_utf8_flags(buffer, NATIVE_TO_UNI(*start), 0) - buffer;
switch(length) {
case 1:
- *d++ = buffer[0];
+ *dest++ = buffer[0];
break;
case 2:
- *d++ = buffer[0];
- *d++ = buffer[1];
+ *dest++ = buffer[0];
+ *dest++ = buffer[1];
break;
default:
Perl_croak(aTHX_ "Perl bug: value %d UTF-8 expands to %d bytes",
}
start++;
}
- *dest = d;
+ return dest;
}
#define PUSH_BYTES(utf8, cur, buf, len) \
STMT_START { \
- if (utf8) bytes_to_uni(aTHX_ (U8 *) buf, len, &(cur)); \
+ if (utf8) \
+ (cur) = bytes_to_uni((U8 *) buf, len, (cur)); \
else { \
Copy(buf, cur, len, char); \
(cur) += (len); \
STMT_START { \
if (utf8) { \
const U8 au8 = (byte); \
- bytes_to_uni(aTHX_ &au8, 1, &(s)); \
+ (s) = bytes_to_uni(&au8, 1, (s)); \
} else *(U8 *)(s)++ = (byte); \
} STMT_END
len+(endb-buffer)*UTF8_EXPAND);
end = start+SvLEN(cat);
}
- bytes_to_uni(aTHX_ buffer, endb-buffer, &cur);
+ cur = bytes_to_uni(buffer, endb-buffer, cur);
} else {
if (cur >= end) {
*cur = '\0';
__attribute__warn_unused_result__
__attribute__nonnull__(pTHX_1);
+STATIC char * S_bytes_to_uni(pTHX_ const U8 *start, STRLEN len, char *dest)
+ __attribute__warn_unused_result__
+ __attribute__nonnull__(pTHX_1)
+ __attribute__nonnull__(pTHX_3);
+
#endif
#if defined(PERL_IN_PP_CTL_C) || defined(PERL_DECL_PROT)