From 917a1abfd110a35e0ab8d270dbdc2e7cb69cd711 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Mon, 12 Jun 2023 14:30:16 -0600 Subject: [PATCH] locale.c: S_save_to_buffer: Add pTHX parameter This saves doing dTHX inside the function --- embed.fnc | 2 +- embed.h | 2 +- locale.c | 13 ++++--------- proto.h | 2 +- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/embed.fnc b/embed.fnc index 91eca8fc3098..e71418d44112 100644 --- a/embed.fnc +++ b/embed.fnc @@ -4348,7 +4348,7 @@ So |void |restore_toggled_locale_i \ |const unsigned cat_index \ |NULLOK const char *original_locale \ |const line_t caller_line -ST |const char *|save_to_buffer \ +S |const char *|save_to_buffer \ |NULLOK const char *string \ |NULLOK const char **buf \ |NULLOK Size_t *buf_size diff --git a/embed.h b/embed.h index 3698c20830c2..c5d88f454136 100644 --- a/embed.h +++ b/embed.h @@ -1273,7 +1273,7 @@ # define get_category_index_helper(a,b,c) S_get_category_index_helper(aTHX_ a,b,c) # define mortalized_pv_copy(a) S_mortalized_pv_copy(aTHX_ a) # define new_LC_ALL(a,b) S_new_LC_ALL(aTHX_ a,b) -# define save_to_buffer S_save_to_buffer +# define save_to_buffer(a,b,c) S_save_to_buffer(aTHX_ a,b,c) # define setlocale_failure_panic_via_i(a,b,c,d,e,f,g) S_setlocale_failure_panic_via_i(aTHX_ a,b,c,d,e,f,g) # if defined(DEBUGGING) # define my_setlocale_debug_string_i(a,b,c,d) S_my_setlocale_debug_string_i(aTHX_ a,b,c,d) diff --git a/locale.c b/locale.c index df1165536401..bd8834a3b487 100644 --- a/locale.c +++ b/locale.c @@ -4063,7 +4063,7 @@ S_is_locale_utf8(pTHX_ const char * locale) #ifdef USE_LOCALE STATIC const char * -S_save_to_buffer(const char * string, const char **buf, Size_t *buf_size) +S_save_to_buffer(pTHX_ const char * string, const char **buf, Size_t *buf_size) { /* Copy the NUL-terminated 'string' to a buffer whose address before this * call began at *buf, and whose available length before this call was @@ -4113,23 +4113,18 @@ S_save_to_buffer(const char * string, const char **buf, Size_t *buf_size) *buf_size = string_size; } - { - dTHX_DEBUGGING; - DEBUG_Lv(PerlIO_printf(Perl_debug_log, +# ifdef DEBUGGING + + DEBUG_Lv(PerlIO_printf(Perl_debug_log, "Copying '%s' to %p\n", ((is_utf8_string((U8 *) string, 0)) ? string :_byte_dump_string((U8 *) string, strlen(string), 0)), *buf)); - } - -# ifdef DEBUGGING /* Catch glitches. Usually this is because LC_CTYPE needs to be the same * locale as whatever is being worked on */ if (UNLIKELY(instr(string, REPLACEMENT_CHARACTER_UTF8))) { - dTHX_DEBUGGING; - locale_panic_(Perl_form(aTHX_ "Unexpected REPLACEMENT_CHARACTER in '%s'\n%s", string, get_LC_ALL_display())); diff --git a/proto.h b/proto.h index d71f6203ec0c..2740be194ff8 100644 --- a/proto.h +++ b/proto.h @@ -6990,7 +6990,7 @@ S_restore_toggled_locale_i(pTHX_ const unsigned cat_index, const char *original_ # define PERL_ARGS_ASSERT_RESTORE_TOGGLED_LOCALE_I STATIC const char * -S_save_to_buffer(const char *string, const char **buf, Size_t *buf_size); +S_save_to_buffer(pTHX_ const char *string, const char **buf, Size_t *buf_size); # define PERL_ARGS_ASSERT_SAVE_TO_BUFFER PERL_STATIC_NO_RET void