Skip to content

Commit 9de1a49

Browse files
committed
Fixes to bytes_to_utf8-type functions
This commit turns bytes_to_utf8() back into an (inline) function, and changes the type of a parameter in bytes_to_utf8_free_me() to void*, which is a more accurate type for it. Fixes #22902
1 parent 50d6669 commit 9de1a49

File tree

6 files changed

+17
-11
lines changed

6 files changed

+17
-11
lines changed

embed.fnc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,12 +794,12 @@ Adp |int |bytes_cmp_utf8 |NN const U8 *b \
794794
Adp |U8 * |bytes_from_utf8|NN const U8 *s \
795795
|NN STRLEN *lenp \
796796
|NN bool *is_utf8p
797-
Admp |U8 * |bytes_to_utf8 |NN const U8 *s \
797+
Adip |U8 * |bytes_to_utf8 |NN const U8 *s \
798798
|NN STRLEN *lenp
799799
Adp |U8 * |bytes_to_utf8_free_me \
800800
|NN const U8 *s \
801801
|NN STRLEN *lenp \
802-
|NULLOK const U8 **free_me
802+
|NULLOK void **free_me
803803
AOdp |SSize_t|call_argv |NN const char *sub_name \
804804
|I32 flags \
805805
|NN char **argv

embed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
# define block_start(a) Perl_block_start(aTHX_ a)
156156
# define bytes_cmp_utf8(a,b,c,d) Perl_bytes_cmp_utf8(aTHX_ a,b,c,d)
157157
# define bytes_from_utf8(a,b,c) Perl_bytes_from_utf8(aTHX_ a,b,c)
158-
# define bytes_to_utf8(a,b) Perl_bytes_to_utf8(aTHX,a,b)
158+
# define bytes_to_utf8(a,b) Perl_bytes_to_utf8(aTHX_ a,b)
159159
# define bytes_to_utf8_free_me(a,b,c) Perl_bytes_to_utf8_free_me(aTHX_ a,b,c)
160160
# define c9strict_utf8_to_uv Perl_c9strict_utf8_to_uv
161161
# define call_argv(a,b,c) Perl_call_argv(aTHX_ a,b,c)

inline.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,6 @@ in lvalue context.
11321132
=cut
11331133
*/
11341134

1135-
11361135
PERL_STATIC_INLINE bool
11371136
Perl_rpp_is_lone(pTHX_ SV *sv)
11381137
{
@@ -1231,6 +1230,12 @@ Perl_append_utf8_from_native_byte(const U8 byte, U8** dest)
12311230
}
12321231
}
12331232

1233+
PERL_STATIC_INLINE U8 *
1234+
Perl_bytes_to_utf8(pTHX_ const U8 *s, STRLEN *lenp)
1235+
{
1236+
return bytes_to_utf8_free_me(s, lenp, NULL);
1237+
}
1238+
12341239
/*
12351240
=for apidoc valid_utf8_to_uvchr
12361241
Like C<L<perlapi/utf8_to_uvchr_buf>>, but should only be called when it is

proto.h

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

utf8.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,7 +3269,7 @@ But when it is a non-NULL pointer, C<bytes_to_utf8_free_me> stores into it
32693269
either NULL if no memory was allocated; or a pointer to that new memory. This
32703270
allows the following convenient paradigm:
32713271
3272-
U8 * free_me;
3272+
void * free_me;
32733273
U8 converted = bytes_to_utf8_free_me(string, &len, &free_me);
32743274
32753275
...
@@ -3292,7 +3292,7 @@ EBCDIC), see L</sv_recode_to_utf8>().
32923292

32933293
U8*
32943294
Perl_bytes_to_utf8_free_me(pTHX_ const U8 *s, Size_t *lenp,
3295-
const U8 ** free_me_ptr)
3295+
void ** free_me_ptr)
32963296
{
32973297
PERL_ARGS_ASSERT_BYTES_TO_UTF8_FREE_ME;
32983298
PERL_UNUSED_CONTEXT;

utf8.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,6 @@ point's representation.
13301330

13311331
#define Perl_is_utf8_char_buf(buf, buf_end) isUTF8_CHAR(buf, buf_end)
13321332

1333-
#define Perl_bytes_to_utf8(mTHX, s, lenp) Perl_bytes_to_utf8_free_me(aTHX_ s, lenp, NULL)
13341333
typedef enum {
13351334
PL_utf8_to_bytes_overwrite = 0,
13361335
PL_utf8_to_bytes_new_memory,

0 commit comments

Comments
 (0)