From afdc2649e99c79f6902f5ada3bc13dddf3333d8b Mon Sep 17 00:00:00 2001 From: Richard Leach Date: Tue, 4 Feb 2025 22:06:47 +0000 Subject: [PATCH] Change uiv_2buf() from a static to public API function --- embed.fnc | 10 +++++----- embed.h | 2 +- proto.h | 14 +++++++------- sv.c | 21 ++++++++++++++++----- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/embed.fnc b/embed.fnc index bbe8dfe26d..4d2a459d67 100644 --- a/embed.fnc +++ b/embed.fnc @@ -3654,6 +3654,11 @@ EXop |bool |try_amagic_bin |int method \ |int flags EXop |bool |try_amagic_un |int method \ |int flags +ARTp |char * |uiv_2buf |NN char * const buf \ + |const IV iv \ + |UV uv \ + |const int is_uv \ + |NN char ** const peob Adp |SSize_t|unpackstring |NN const char *pat \ |NN const char *patend \ |NN const char *s \ @@ -5896,11 +5901,6 @@ ST |STRLEN |sv_pos_u2b_midway \ |const STRLEN uend i |void |sv_unglob |NN SV * const sv \ |U32 flags -RTi |char * |uiv_2buf |NN char * const buf \ - |const IV iv \ - |UV uv \ - |const int is_uv \ - |NN char ** const peob S |void |utf8_mg_len_cache_update \ |NN SV * const sv \ |NN MAGIC ** const mgp \ diff --git a/embed.h b/embed.h index 9ee86850c2..68e5673273 100644 --- a/embed.h +++ b/embed.h @@ -851,6 +851,7 @@ # define to_uni_lower(a,b,c) Perl_to_uni_lower(aTHX_ a,b,c) # define to_uni_title(a,b,c) Perl_to_uni_title(aTHX_ a,b,c) # define to_uni_upper(a,b,c) Perl_to_uni_upper(aTHX_ a,b,c) +# define uiv_2buf Perl_uiv_2buf # define unpackstring(a,b,c,d,e) Perl_unpackstring(aTHX_ a,b,c,d,e) # define unshare_hek(a) Perl_unshare_hek(aTHX_ a) # define unsharepvn(a,b,c) Perl_unsharepvn(aTHX_ a,b,c) @@ -2185,7 +2186,6 @@ # define sv_pos_u2b_forwards S_sv_pos_u2b_forwards # define sv_pos_u2b_midway S_sv_pos_u2b_midway # define sv_unglob(a,b) S_sv_unglob(aTHX_ a,b) -# define uiv_2buf S_uiv_2buf # define utf8_mg_len_cache_update(a,b,c) S_utf8_mg_len_cache_update(aTHX_ a,b,c) # define utf8_mg_pos_cache_update(a,b,c,d,e) S_utf8_mg_pos_cache_update(aTHX_ a,b,c,d,e) # define visit(a,b,c) S_visit(aTHX_ a,b,c) diff --git a/proto.h b/proto.h index 2a0b0ff01b..3c4249bd54 100644 --- a/proto.h +++ b/proto.h @@ -5313,6 +5313,12 @@ PERL_CALLCONV bool Perl_try_amagic_un(pTHX_ int method, int flags); #define PERL_ARGS_ASSERT_TRY_AMAGIC_UN +PERL_CALLCONV char * +Perl_uiv_2buf(char * const buf, const IV iv, UV uv, const int is_uv, char ** const peob) + __attribute__warn_unused_result__; +#define PERL_ARGS_ASSERT_UIV_2BUF \ + assert(buf); assert(peob) + PERL_CALLCONV SSize_t Perl_unpackstring(pTHX_ const char *pat, const char *patend, const char *s, const char *strend, U32 flags); #define PERL_ARGS_ASSERT_UNPACKSTRING \ @@ -9091,13 +9097,7 @@ S_sv_unglob(pTHX_ SV * const sv, U32 flags); # define PERL_ARGS_ASSERT_SV_UNGLOB \ assert(sv) -PERL_STATIC_INLINE char * -S_uiv_2buf(char * const buf, const IV iv, UV uv, const int is_uv, char ** const peob) - __attribute__warn_unused_result__; -# define PERL_ARGS_ASSERT_UIV_2BUF \ - assert(buf); assert(peob) - -# endif /* !defined(PERL_NO_INLINE_FUNCTIONS) */ +# endif # if defined(USE_ITHREADS) STATIC SV * S_sv_dup_common(pTHX_ const SV * const ssv, CLONE_PARAMS * const param) diff --git a/sv.c b/sv.c index f6215c9f34..6c61f9a88a 100644 --- a/sv.c +++ b/sv.c @@ -2794,15 +2794,26 @@ static const union { '9', '8', '9', '9' }}; -/* uiv_2buf(): private routine for use by sv_2pv_flags(): print an IV or - * UV as a string towards the end of buf, and return pointers to start and - * end of it. +/* uiv_2buf(): originally a private routine for use by sv_2pv_flags(), + * now in use by do_print() and part of the public API. It prints an + * IV or UV as a string towards the end of buf, and return pointers + * to the start and end of it. * * We assume that buf is at least TYPE_CHARS(UV) long. */ -PERL_STATIC_INLINE char * -S_uiv_2buf(char *const buf, const IV iv, UV uv, const int is_uv, char **const peob) +/* +=for apidoc uiv_2buf + +This function converts an IV or UV to its string representation. + +It is used internally by sv_2pv_flags() and do_print(). + +=cut +*/ + +char * +Perl_uiv_2buf(char *const buf, const IV iv, UV uv, const int is_uv, char **const peob) { char *ptr = buf + TYPE_CHARS(UV); char * const ebuf = ptr;