Skip to content

Commit 96ac690

Browse files
committed
utf8_to_bytes_: Add argument, macro
The argument is currently unused. The macro is a public facing API that calls this function with the correct argument
1 parent a284efe commit 96ac690

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

embed.fnc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,6 +3699,10 @@ CDbdp |UV |utf8n_to_uvuni |NN const U8 *s \
36993699
Adpx |U8 * |utf8_to_bytes |NN U8 *s \
37003700
|NN STRLEN *lenp
37013701
Cp |bool |utf8_to_bytes_ |NN U8 **s_ptr \
3702+
|NN STRLEN *lenp \
3703+
|Perl_utf8_to_bytes_arg result_as
3704+
Admp |bool |utf8_to_bytes_overwrite \
3705+
|NN U8 **s_ptr \
37023706
|NN STRLEN *lenp
37033707
EMXp |U8 * |utf16_to_utf8 |NN U8 *p \
37043708
|NN U8 *d \

embed.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,8 @@
859859
# define utf8_hop_safe Perl_utf8_hop_safe
860860
# define utf8_length(a,b) Perl_utf8_length(aTHX_ a,b)
861861
# define utf8_to_bytes(a,b) Perl_utf8_to_bytes(aTHX_ a,b)
862-
# define utf8_to_bytes_(a,b) Perl_utf8_to_bytes_(aTHX_ a,b)
862+
# define utf8_to_bytes_(a,b,c) Perl_utf8_to_bytes_(aTHX_ a,b,c)
863+
# define utf8_to_bytes_overwrite(a,b) Perl_utf8_to_bytes_overwrite(aTHX,a,b)
863864
# define utf8_to_uvchr_buf_helper(a,b,c) Perl_utf8_to_uvchr_buf_helper(aTHX_ a,b,c)
864865
# define utf8n_to_uvchr_msgs Perl_utf8n_to_uvchr_msgs
865866
# define uvchr_to_utf8(a,b) Perl_uvchr_to_utf8(aTHX,a,b)

proto.h

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

utf8.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,7 +2378,8 @@ If you need a copy of the string, see L</bytes_from_utf8>.
23782378
*/
23792379

23802380
bool
2381-
Perl_utf8_to_bytes_(pTHX_ U8 **s_ptr, STRLEN *lenp)
2381+
Perl_utf8_to_bytes_(pTHX_ U8 **s_ptr, STRLEN *lenp,
2382+
Perl_utf8_to_bytes_arg result_as)
23822383
{
23832384
PERL_ARGS_ASSERT_UTF8_TO_BYTES_;
23842385
PERL_UNUSED_CONTEXT;
@@ -2597,7 +2598,7 @@ Perl_utf8_to_bytes(pTHX_ U8 *s, STRLEN *lenp)
25972598
{
25982599
PERL_ARGS_ASSERT_UTF8_TO_BYTES;
25992600

2600-
if (utf8_to_bytes_(&s, lenp)) {
2601+
if (utf8_to_bytes_overwrite(&s, lenp)) {
26012602
return s;
26022603
}
26032604

utf8.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,15 @@ point's representation.
13061306

13071307
#define Perl_is_utf8_char_buf(buf, buf_end) isUTF8_CHAR(buf, buf_end)
13081308

1309+
typedef enum {
1310+
PL_utf8_to_bytes_overwrite = 0,
1311+
PL_utf8_to_bytes_new_memory,
1312+
PL_utf8_to_bytes_use_temporary,
1313+
} Perl_utf8_to_bytes_arg;
1314+
1315+
#define Perl_utf8_to_bytes_overwrite(mTHX, s, l) \
1316+
Perl_utf8_to_bytes_(aTHX_ s, l, PL_utf8_to_bytes_overwrite)
1317+
13091318
/* Do not use; should be deprecated. Use isUTF8_CHAR() instead; this is
13101319
* retained solely for backwards compatibility */
13111320
#define IS_UTF8_CHAR(p, n) (isUTF8_CHAR(p, (p) + (n)) == n)

0 commit comments

Comments
 (0)