Skip to content

Commit

Permalink
New signature for static fcn my_langinfo()
Browse files Browse the repository at this point in the history
This commit changes the calling sequence for my_langinfo to add the
desired locale (or a sentinel to indicate to use the current locale),
and the locale category of the desired item.

This allows the function to be able to return the desired value for any
locale, avoiding some locale changes that would happen until this
commit, and hiding the need for locale changes from outside functions,
though a couple continue to do so to avoid potential multiple changes.
  • Loading branch information
khwilliamson committed Apr 9, 2021
1 parent 7148f92 commit ea8ab0e
Show file tree
Hide file tree
Showing 4 changed files with 310 additions and 145 deletions.
14 changes: 10 additions & 4 deletions embed.fnc
Original file line number Diff line number Diff line change
Expand Up @@ -3220,13 +3220,15 @@ ST |unsigned int|get_category_index|const int category|NULLOK const char * local
S |const char*|switch_category_locale_to_template|const int switch_category|const int template_category|NULLOK const char * template_locale
S |void |restore_switched_locale|const int category|NULLOK const char * const original_locale
# if defined(HAS_NL_LANGINFO) || defined(HAS_NL_LANGINFO_L)
S |const char*|my_langinfo|const nl_item item \
|bool toggle \
S |const char*|my_langinfo_i|const nl_item item \
|const unsigned int cat_index \
|NULLOK const char * locale \
|NN const char ** retbufp \
|NULLOK Size_t * retbuf_sizep
# else
S |const char*|my_langinfo|const int item \
|bool toggle \
S |const char*|my_langinfo_i|const int item \
|const unsigned int cat_index \
|NULLOK const char * locale \
|NN const char ** retbufp \
|NULLOK Size_t * retbuf_sizep
# endif
Expand Down Expand Up @@ -3254,6 +3256,10 @@ Sr |void |setlocale_failure_panic_i|const unsigned int cat_index \
S |void |set_numeric_radix|const bool use_locale
S |void |new_numeric |NULLOK const char* newnum
S |void |new_LC_ALL |NULLOK const char* unused
S |const char *|toggle_locale_i|const unsigned switch_cat_index \
|NN const char * new_locale
S |void |restore_toggled_locale_i|const unsigned cat_index \
|NULLOK const char * original_locale
ST |bool |is_codeset_name_UTF8|NN const char * name
# ifdef USE_POSIX_2008_LOCALE
S |const char*|emulate_setlocale_i|const unsigned int index \
Expand Down
6 changes: 4 additions & 2 deletions embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@
# if !(defined(HAS_NL_LANGINFO) || defined(HAS_NL_LANGINFO_L))
# if defined(PERL_IN_LOCALE_C)
# if defined(USE_LOCALE)
#define my_langinfo(a,b,c,d) S_my_langinfo(aTHX_ a,b,c,d)
#define my_langinfo_i(a,b,c,d,e) S_my_langinfo_i(aTHX_ a,b,c,d,e)
# endif
# endif
# endif
Expand Down Expand Up @@ -1607,7 +1607,7 @@
# if defined(HAS_NL_LANGINFO) || defined(HAS_NL_LANGINFO_L)
# if defined(PERL_IN_LOCALE_C)
# if defined(USE_LOCALE)
#define my_langinfo(a,b,c,d) S_my_langinfo(aTHX_ a,b,c,d)
#define my_langinfo_i(a,b,c,d,e) S_my_langinfo_i(aTHX_ a,b,c,d,e)
# endif
# endif
# endif
Expand Down Expand Up @@ -1710,11 +1710,13 @@
#define new_ctype(a) S_new_ctype(aTHX_ a)
#define new_numeric(a) S_new_numeric(aTHX_ a)
#define restore_switched_locale(a,b) S_restore_switched_locale(aTHX_ a,b)
#define restore_toggled_locale_i(a,b) S_restore_toggled_locale_i(aTHX_ a,b)
#define save_to_buffer S_save_to_buffer
#define set_numeric_radix(a) S_set_numeric_radix(aTHX_ a)
#define setlocale_failure_panic_i(a,b,c,d,e) S_setlocale_failure_panic_i(aTHX_ a,b,c,d,e)
#define stdize_locale(a,b,c,d) S_stdize_locale(aTHX_ a,b,c,d)
#define switch_category_locale_to_template(a,b,c) S_switch_category_locale_to_template(aTHX_ a,b,c)
#define toggle_locale_i(a,b) S_toggle_locale_i(aTHX_ a,b)
# if defined(USE_POSIX_2008_LOCALE)
#define emulate_setlocale_i(a,b,c,d) S_emulate_setlocale_i(aTHX_ a,b,c,d)
#define find_locale_from_environment(a) S_find_locale_from_environment(aTHX_ a)
Expand Down
Loading

0 comments on commit ea8ab0e

Please sign in to comment.