From f61748ac869b88af2e2557f16421f2d4a8fd09f5 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Mon, 11 Sep 2017 19:12:56 -0600 Subject: [PATCH] locale.c: Create extended internal Perl_langinfo() This extended version allows it to be called so that it uses the current locale for the LC_NUMERIC, instead of toggling to the underlying one. (This can be useful when in the middle of things.) This ability won't be used until the next commit --- embed.fnc | 5 +++++ embed.h | 10 ++++++++++ locale.c | 11 ++++++++++- proto.h | 10 ++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/embed.fnc b/embed.fnc index d87e109..bdde5ea 100644 --- a/embed.fnc +++ b/embed.fnc @@ -2723,6 +2723,11 @@ s |bool |isa_lookup |NN HV *stash|NN const char * const name \ #endif #if defined(PERL_IN_LOCALE_C) +# ifdef HAS_NL_LANGINFO +sn |const char*|my_nl_langinfo|const nl_item item|bool toggle +# else +sn |const char*|my_nl_langinfo|const int item|bool toggle +# endif in |const char *|save_to_buffer|NN const char * string \ |NULLOK char **buf \ |NN Size_t *buf_size \ diff --git a/embed.h b/embed.h index 89e329a..ed7d5af 100644 --- a/embed.h +++ b/embed.h @@ -1413,6 +1413,11 @@ # endif # endif # endif +# if !(defined(HAS_NL_LANGINFO)) +# if defined(PERL_IN_LOCALE_C) +#define my_nl_langinfo S_my_nl_langinfo +# endif +# endif # if !(defined(HAS_SIGACTION) && defined(SA_SIGINFO)) #define sighandler Perl_sighandler # endif @@ -1501,6 +1506,11 @@ #define do_semop(a,b) Perl_do_semop(aTHX_ a,b) #define do_shmio(a,b,c) Perl_do_shmio(aTHX_ a,b,c) # endif +# if defined(HAS_NL_LANGINFO) +# if defined(PERL_IN_LOCALE_C) +#define my_nl_langinfo S_my_nl_langinfo +# endif +# endif # if defined(HAS_SIGACTION) && defined(SA_SIGINFO) #define sighandler Perl_sighandler # endif diff --git a/locale.c b/locale.c index 316cd5d..2e0fdc2 100644 --- a/locale.c +++ b/locale.c @@ -1254,7 +1254,16 @@ Perl_langinfo(const nl_item item) Perl_langinfo(const int item) #endif { - bool toggle = TRUE; + return my_nl_langinfo(item, TRUE); +} + +const char * +#ifdef HAS_NL_LANGINFO +S_my_nl_langinfo(const nl_item item, bool toggle) +#else +S_my_nl_langinfo(const int item, bool toggle) +#endif +{ dTHX; #if defined(HAS_NL_LANGINFO) /* nl_langinfo() is available. */ diff --git a/proto.h b/proto.h index fe3d94b..939ba28 100644 --- a/proto.h +++ b/proto.h @@ -3812,6 +3812,11 @@ PERL_CALLCONV char* Perl_ninstr(const char* big, const char* bigend, const char* #if !(defined(HAS_NL_LANGINFO) && defined(PERL_LANGINFO_H)) PERL_CALLCONV const char* Perl_langinfo(const int item); #endif +#if !(defined(HAS_NL_LANGINFO)) +# if defined(PERL_IN_LOCALE_C) +STATIC const char* S_my_nl_langinfo(const int item, bool toggle); +# endif +#endif #if !(defined(HAS_SIGACTION) && defined(SA_SIGINFO)) PERL_CALLCONV Signal_t Perl_csighandler(int sig); PERL_CALLCONV Signal_t Perl_sighandler(int sig); @@ -4234,6 +4239,11 @@ PERL_CALLCONV I32 Perl_do_shmio(pTHX_ I32 optype, SV** mark, SV** sp); #define PERL_ARGS_ASSERT_DO_SHMIO \ assert(mark); assert(sp) #endif +#if defined(HAS_NL_LANGINFO) +# if defined(PERL_IN_LOCALE_C) +STATIC const char* S_my_nl_langinfo(const nl_item item, bool toggle); +# endif +#endif #if defined(HAS_NL_LANGINFO) && defined(PERL_LANGINFO_H) PERL_CALLCONV const char* Perl_langinfo(const nl_item item); #endif -- 1.8.3.1