Skip to content

Commit

Permalink
Fix compiling without LC_ALL defined
Browse files Browse the repository at this point in the history
It is legal to have a platform without the aggregate LC_ALL locale
category defined, though I don't know of any such.  Recent changes broke
compilation for that case.  This commit restores it.

(To check this, one has to munge perl.h slightly to force it to
be #undef, and I hadn't tried that recently)
  • Loading branch information
khwilliamson committed Nov 2, 2023
1 parent e2934ff commit 5314ff9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 58 deletions.
20 changes: 9 additions & 11 deletions embed.fnc
Expand Up @@ -4416,10 +4416,19 @@ Ri |const char *|mortalized_pv_copy \
|NULLOK const char * const pv
S |const char *|native_querylocale_i \
|const locale_category_index cat_index
S |void |new_LC_ALL |NN const char *lc_all \
|bool force
S |void |output_check_environment_warning \
|NULLOK const char * const language \
|NULLOK const char * const lc_all \
|NULLOK const char * const lang
S |parse_LC_ALL_string_return|parse_LC_ALL_string \
|NN const char *string \
|NN const char **output \
|const parse_LC_ALL_STRING_action \
|bool always_use_full_array \
|const bool panic_on_error \
|const line_t caller_line
So |void |restore_toggled_locale_i \
|const locale_category_index cat_index \
|NULLOK const char *original_locale \
Expand Down Expand Up @@ -4472,21 +4481,10 @@ S |const char *|my_langinfo_i \
S |void |give_perl_locale_control \
|NN const char *lc_all_string \
|const line_t caller_line
S |void |new_LC_ALL |NN const char *lc_all \
|bool force
S |parse_LC_ALL_string_return|parse_LC_ALL_string \
|NN const char *string \
|NN const char **output \
|const parse_LC_ALL_STRING_action \
|bool always_use_full_array \
|const bool panic_on_error \
|const line_t caller_line
# else
S |void |give_perl_locale_control \
|NN const char **curlocales \
|const line_t caller_line
S |void |new_LC_ALL |NN const char **individ_locales \
|bool force
# endif
# if defined(USE_LOCALE_COLLATE)
S |void |new_collate |NN const char *newcoll \
Expand Down
5 changes: 2 additions & 3 deletions embed.h
Expand Up @@ -1304,7 +1304,9 @@
# 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 native_querylocale_i(a) S_native_querylocale_i(aTHX_ a)
# define new_LC_ALL(a,b) S_new_LC_ALL(aTHX_ a,b)
# define output_check_environment_warning(a,b,c) S_output_check_environment_warning(aTHX_ a,b,c)
# define parse_LC_ALL_string(a,b,c,d,e,f) S_parse_LC_ALL_string(aTHX_ a,b,c,d,e,f)
# define save_to_buffer(a,b,c) S_save_to_buffer(aTHX_ a,b,c)
# define set_save_buffer_min_size(a,b,c) S_set_save_buffer_min_size(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)
Expand All @@ -1318,11 +1320,8 @@
# endif
# if defined(LC_ALL)
# define give_perl_locale_control(a,b) S_give_perl_locale_control(aTHX_ a,b)
# define new_LC_ALL(a,b) S_new_LC_ALL(aTHX_ a,b)
# define parse_LC_ALL_string(a,b,c,d,e,f) S_parse_LC_ALL_string(aTHX_ a,b,c,d,e,f)
# else
# define give_perl_locale_control(a,b) S_give_perl_locale_control(aTHX_ a,b)
# define new_LC_ALL(a,b) S_new_LC_ALL(aTHX_ a,b)
# endif
# if defined(USE_LOCALE_COLLATE)
# define new_collate(a,b) S_new_collate(aTHX_ a,b)
Expand Down
39 changes: 12 additions & 27 deletions locale.c
Expand Up @@ -823,7 +823,7 @@ STATIC const bool category_available[] = {
# ifdef LC_ALL
true,
# else
false
false,
# endif

false /* LC_UNKNOWN_AVAIL_ */
Expand Down Expand Up @@ -1074,7 +1074,7 @@ Perl_locale_panic(const char * msg,
#define setlocale_failure_panic_c(cat, cur, fail, line, higher_line) \
setlocale_failure_panic_i(cat##_INDEX_, cur, fail, line, higher_line)

#if defined(LC_ALL) && defined(USE_LOCALE)
#if defined(USE_LOCALE)

/* Expands to the code to
* result = savepvn(s, len)
Expand Down Expand Up @@ -3958,17 +3958,7 @@ Perl_warn_problematic_locale()
# endif /* USE_LOCALE_CTYPE */

STATIC void

# ifdef LC_ALL

S_new_LC_ALL(pTHX_ const char *lc_all, bool force)

# else

S_new_LC_ALL(pTHX_ const char ** individ_locales, bool force)

# endif

{
PERL_ARGS_ASSERT_NEW_LC_ALL;

Expand All @@ -3977,8 +3967,6 @@ S_new_LC_ALL(pTHX_ const char ** individ_locales, bool force)
* set, and not the nominal one (should they differ, as they may in
* LC_NUMERIC). */

# ifdef LC_ALL

const char * individ_locales[LC_ALL_INDEX_] = { NULL };

switch (parse_LC_ALL_string(lc_all,
Expand All @@ -3990,29 +3978,22 @@ S_new_LC_ALL(pTHX_ const char ** individ_locales, bool force)
earlier had to have succeeded */
__LINE__))
{
case invalid:
case no_array:
case only_element_0:
case invalid:
case no_array:
case only_element_0:
locale_panic_("Unexpected return from parse_LC_ALL_string");

case full_array:
case full_array:
break;
}

# endif

for_all_individual_category_indexes(i) {
if (update_functions[i]) {
const char * this_locale = individ_locales[i];
update_functions[i](aTHX_ this_locale, force);
}

# ifdef LC_ALL

Safefree(individ_locales[i]);

# endif

}
}

Expand Down Expand Up @@ -6876,9 +6857,13 @@ S_give_perl_locale_control(pTHX_

# else

new_LC_ALL(locales, true);

new_LC_ALL(calculate_LC_ALL_string(locales,
INTERNAL_FORMAT,
WANT_TEMP_PV,
caller_line),
true);
# endif

}

STATIC void
Expand Down
29 changes: 12 additions & 17 deletions proto.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5314ff9

Please sign in to comment.