Skip to content

Commit

Permalink
no PL_CUR_LC_ALL
Browse files Browse the repository at this point in the history
  • Loading branch information
khwilliamson committed Jan 27, 2023
1 parent 2a9e021 commit ae3d5de
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
4 changes: 1 addition & 3 deletions intrpvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,7 @@ PERLVARI(I, cur_locale_obj, locale_t, NULL)
#endif
#ifdef USE_PL_CURLOCALES

/* This is the most number of categories we've encountered so far on any
* platform, doesn't include LC_ALL */
PERLVARA(I, curlocales, PERL_LOCALE_CATEGORIES_COUNT_, const char *)
PERLVARA(I, curlocales, PERL_LOCALE_CATEGORIES_ALL_COUNT_, const char *)

#endif
#ifdef USE_PL_CUR_LC_ALL
Expand Down
37 changes: 17 additions & 20 deletions locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,17 +877,14 @@ S_my_querylocale_i(pTHX_ const unsigned int index)
/* But we do have up-to-date values when we keep our own records
* (except some times in initialization, where we get the value from
* the system. */
const char ** which = (index == LC_ALL_INDEX_)
? &PL_cur_LC_ALL
: &PL_curlocales[index];
if (*which == NULL) {
if (PL_curlocales[index] == NULL) {
STDIZED_SETLOCALE_LOCK;
retval = stdized_setlocale(category, NULL);
*which = savepv(retval);
PL_curlocales[index] = savepv(retval);
STDIZED_SETLOCALE_UNLOCK;
}
else {
retval = *which;
retval = PL_curlocales[index];
}

# endif
Expand Down Expand Up @@ -926,10 +923,10 @@ S_update_PL_curlocales_i(pTHX_
PL_curlocales[i] = savepv(new_locale);
}

Safefree(PL_cur_LC_ALL);
PL_cur_LC_ALL = savepv(calculate_LC_ALL(PL_curlocales));
DEBUG_U(PerlIO_printf(Perl_debug_log, "%s\n", PL_cur_LC_ALL));
return PL_cur_LC_ALL;
Safefree(PL_curlocales[LC_ALL_INDEX_]);
PL_curlocales[LC_ALL_INDEX_] = savepv(calculate_LC_ALL(PL_curlocales));
DEBUG_U(PerlIO_printf(Perl_debug_log, "%s\n", PL_curlocales[LC_ALL_INDEX_]));
return PL_curlocales[LC_ALL_INDEX_];
}

/* Update the single category's record */
Expand All @@ -942,9 +939,9 @@ S_update_PL_curlocales_i(pTHX_
|| ( recalc_LC_ALL == RECALCULATE_LC_ALL_ON_FINAL_INTERATION
&& index == NOMINAL_LC_ALL_INDEX - 1))
{
Safefree(PL_cur_LC_ALL);
PL_cur_LC_ALL = savepv(calculate_LC_ALL(PL_curlocales));
DEBUG_U(PerlIO_printf(Perl_debug_log, "%s\n", PL_cur_LC_ALL));
Safefree(PL_curlocales[LC_ALL_INDEX_]);
PL_curlocales[LC_ALL_INDEX_] = savepv(calculate_LC_ALL(PL_curlocales));
DEBUG_U(PerlIO_printf(Perl_debug_log, "%s\n", PL_curlocales[LC_ALL_INDEX_]));
}

return PL_curlocales[index];
Expand Down Expand Up @@ -1078,9 +1075,9 @@ S_setlocale_from_aggregate_LC_ALL(pTHX_ const char * locale, const line_t line)
* categories whose locale is 'C'. khw thinks it's better to store a
* complete LC_ALL. So calculate it. */
const char * retval = savepv(calculate_LC_ALL(PL_curlocales));
Safefree(PL_cur_LC_ALL);
PL_cur_LC_ALL = retval;
DEBUG_U(PerlIO_printf(Perl_debug_log, "%s\n", PL_cur_LC_ALL));
Safefree(PL_curlocales[LC_ALL_INDEX_]);
PL_curlocales[LC_ALL_INDEX_] = retval;
DEBUG_U(PerlIO_printf(Perl_debug_log, "%s\n", PL_curlocales[LC_ALL_INDEX_]));

# else

Expand Down Expand Up @@ -1177,9 +1174,9 @@ S_emulate_setlocale_i(pTHX_
if (UNLIKELY( recalc_LC_ALL == RECALCULATE_LC_ALL_ON_FINAL_INTERATION
&& index == NOMINAL_LC_ALL_INDEX - 1))
{
Safefree(PL_cur_LC_ALL);
PL_cur_LC_ALL = savepv(calculate_LC_ALL(PL_curlocales));
DEBUG_U(PerlIO_printf(Perl_debug_log, "%s\n", PL_cur_LC_ALL));
Safefree(PL_curlocales[LC_ALL_INDEX_]);
PL_curlocales[LC_ALL_INDEX_] = savepv(calculate_LC_ALL(PL_curlocales));
DEBUG_U(PerlIO_printf(Perl_debug_log, "%s\n", PL_curlocales[LC_ALL_INDEX_]));
}

# endif
Expand Down Expand Up @@ -7353,7 +7350,7 @@ Perl_switch_locale_context()
# ifdef USE_POSIX_2008_LOCALE
# ifdef DEBUGGING
if (PL_phase != PERL_PHASE_CONSTRUCT) DEBUG_U(PerlIO_printf(Perl_debug_log, "switch_locale_context: aTHX=%p, phase=%s, obj=%p\n", aTHX, PL_phase_names[PL_phase], PL_cur_locale_obj));
# ifdef USE_PL_CURLOCALES
# ifdef USE_PL_CUR_LC_ALL
if (PL_phase != PERL_PHASE_CONSTRUCT) DEBUG_U(PerlIO_printf(Perl_debug_log, "locale=%s\n", PL_cur_LC_ALL));
# endif
# endif
Expand Down
1 change: 0 additions & 1 deletion makedef.pl
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ BEGIN
if ($define{USE_POSIX_2008_LOCALE} && ! $define{USE_QUERYLOCALE})
{
$define{USE_PL_CURLOCALES} = 1;
$define{USE_PL_CUR_LC_ALL} = 1;
}

if ($define{WIN32} && $define{USE_THREAD_SAFE_LOCALE})
Expand Down
1 change: 0 additions & 1 deletion perl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,6 @@ violations are fatal.
* querylocale; so must keep track of it ourselves */
# if (defined(USE_POSIX_2008_LOCALE) && ! defined(USE_QUERYLOCALE))
# define USE_PL_CURLOCALES
# define USE_PL_CUR_LC_ALL
# endif

# if defined(WIN32) && defined(USE_THREAD_SAFE_LOCALE)
Expand Down

0 comments on commit ae3d5de

Please sign in to comment.