Skip to content

Commit

Permalink
locale.c: Split up S_setlocale_from_aggregate_LC_ALL
Browse files Browse the repository at this point in the history
This splits out the parsing of the LC_ALL string from the locale
setting.  Future commits will use the parse portion in more places.

The new code doesn't panic on syntax errors, unlike the old.  This is
because we should never panic on user input, but return failure instead.
  • Loading branch information
khwilliamson committed Jul 31, 2023
1 parent cfc6472 commit 796f4ab
Show file tree
Hide file tree
Showing 5 changed files with 257 additions and 104 deletions.
12 changes: 10 additions & 2 deletions embed.fnc
Original file line number Diff line number Diff line change
Expand Up @@ -4424,13 +4424,21 @@ S |const char *|setlocale_from_aggregate_LC_ALL \
|NN const char *locale \
|const line_t line
S |locale_t|use_curlocale_scratch
# if defined(LC_ALL)
S |parse_LC_ALL_string_return|parse_LC_ALL_string \
|NN const char *string \
|NN const char **output \
|const line_t caller_line
# endif
# if !defined(USE_QUERYLOCALE)
S |void |update_PL_curlocales_i \
|const unsigned int index \
|NN const char *new_locale
# endif
# elif defined(USE_LOCALE_THREADS) && !defined(USE_THREAD_SAFE_LOCALE) && \
!defined(USE_THREAD_SAFE_LOCALE_EMULATION)
# elif defined(USE_LOCALE_THREADS) && \
!defined(USE_THREAD_SAFE_LOCALE) && \
!defined(USE_THREAD_SAFE_LOCALE_EMULATION) /* &&
!defined(USE_POSIX_2008_LOCALE) */
S |bool |less_dicey_bool_setlocale_r \
|const int cat \
|NN const char *locale
Expand Down
10 changes: 7 additions & 3 deletions embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -1304,12 +1304,16 @@
# define querylocale_2008_i(a) S_querylocale_2008_i(aTHX_ a)
# define setlocale_from_aggregate_LC_ALL(a,b) S_setlocale_from_aggregate_LC_ALL(aTHX_ a,b)
# define use_curlocale_scratch() S_use_curlocale_scratch(aTHX)
# if defined(LC_ALL)
# define parse_LC_ALL_string(a,b,c) S_parse_LC_ALL_string(aTHX_ a,b,c)
# endif
# if !defined(USE_QUERYLOCALE)
# define update_PL_curlocales_i(a,b) S_update_PL_curlocales_i(aTHX_ a,b)
# endif
# elif defined(USE_LOCALE_THREADS) && \
!defined(USE_THREAD_SAFE_LOCALE) && \
!defined(USE_THREAD_SAFE_LOCALE_EMULATION)
# elif defined(USE_LOCALE_THREADS) && \
!defined(USE_THREAD_SAFE_LOCALE) && \
!defined(USE_THREAD_SAFE_LOCALE_EMULATION) /* &&
!defined(USE_POSIX_2008_LOCALE) */
# define less_dicey_bool_setlocale_r(a,b) S_less_dicey_bool_setlocale_r(aTHX_ a,b)
# define less_dicey_setlocale_r(a,b) S_less_dicey_setlocale_r(aTHX_ a,b)
# endif
Expand Down
Loading

0 comments on commit 796f4ab

Please sign in to comment.