From 6a6d2de02b1575437a42c1c60641009428f24411 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Tue, 16 Feb 2021 06:27:54 -0700 Subject: [PATCH] Make three locale PL_ strings const char* This adds some compile safety to these. --- embed.fnc | 2 +- intrpvar.h | 6 +++--- locale.c | 2 +- proto.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/embed.fnc b/embed.fnc index ff70cd4b7c21..dfdea38621af 100644 --- a/embed.fnc +++ b/embed.fnc @@ -3225,7 +3225,7 @@ ST |const char*|my_nl_langinfo|const nl_item item|bool toggle ST |const char*|my_nl_langinfo|const int item|bool toggle # endif iTR |const char *|save_to_buffer|NULLOK const char * string \ - |NULLOK char **buf \ + |NULLOK const char **buf \ |NN Size_t *buf_size \ |const Size_t offset # if defined(USE_LOCALE) diff --git a/intrpvar.h b/intrpvar.h index 390dd95a9883..35baf2c17639 100644 --- a/intrpvar.h +++ b/intrpvar.h @@ -741,9 +741,9 @@ PERLVARI(I, collation_standard, bool, TRUE) /* Assume simple collation */ #endif /* USE_LOCALE_COLLATE */ -PERLVARI(I, langinfo_buf, char *, NULL) +PERLVARI(I, langinfo_buf, const char *, NULL) PERLVARI(I, langinfo_bufsize, Size_t, 0) -PERLVARI(I, setlocale_buf, char *, NULL) +PERLVARI(I, setlocale_buf, const char *, NULL) PERLVARI(I, setlocale_bufsize, Size_t, 0) #ifdef PERL_SAWAMPERSAND @@ -802,7 +802,7 @@ PERLVARI(I, numeric_underlying_is_standard, bool, TRUE) PERLVARI(I, numeric_standard, int, TRUE) /* Assume C locale numerics */ -PERLVAR(I, numeric_name, char *) /* Name of current numeric locale */ +PERLVAR(I, numeric_name, const char *) /* Name of current numeric locale */ PERLVAR(I, numeric_radix_sv, SV *) /* The radix separator if not '.' */ # ifdef USE_POSIX_2008_LOCALE diff --git a/locale.c b/locale.c index 7c3c7cf803d8..d9f3e139fe0d 100644 --- a/locale.c +++ b/locale.c @@ -2336,7 +2336,7 @@ Perl_setlocale(const int category, const char * locale) } PERL_STATIC_INLINE const char * -S_save_to_buffer(const char * string, char **buf, Size_t *buf_size, +S_save_to_buffer(const char * string, const char **buf, Size_t *buf_size, const Size_t offset) { /* Copy the NUL-terminated 'string' to 'buf' + 'offset'. 'buf' has size diff --git a/proto.h b/proto.h index b500abe315c8..631b2e076744 100644 --- a/proto.h +++ b/proto.h @@ -5121,7 +5121,7 @@ PERL_CALLCONV SV* Perl_hfree_next_entry(pTHX_ HV *hv, STRLEN *indexp); #endif #if defined(PERL_IN_LOCALE_C) #ifndef PERL_NO_INLINE_FUNCTIONS -PERL_STATIC_INLINE const char * S_save_to_buffer(const char * string, char **buf, Size_t *buf_size, const Size_t offset) +PERL_STATIC_INLINE const char * S_save_to_buffer(const char * string, const char **buf, Size_t *buf_size, const Size_t offset) __attribute__warn_unused_result__; #define PERL_ARGS_ASSERT_SAVE_TO_BUFFER \ assert(buf_size)