Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
khwilliamson committed May 7, 2023
1 parent 255b8d2 commit dffc180
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
2 changes: 2 additions & 0 deletions dist/threads/threads.xs
Expand Up @@ -220,7 +220,9 @@ S_ithread_set(pTHX_ ithread *thread)
dMY_CXT;
DEBUG_U(PerlIO_printf(Perl_debug_log, "ithread_set about to set MY_CXT context to thread %p; tid=%ld\n", thread, thread->tid));
MY_CXT.context = thread;
#ifdef PERL_SET_NON_tTHX_CONTEXT
PERL_SET_NON_tTHX_CONTEXT(thread->interp);
#endif
}

STATIC ithread *
Expand Down
2 changes: 1 addition & 1 deletion intrpvar.h
Expand Up @@ -763,7 +763,7 @@ PERLVARA(I, restore_locale, LOCALE_CATEGORIES_COUNT_, const char *)
PERLVARA(I, restore_locale_depth, LOCALE_CATEGORIES_COUNT_, Size_t)
#endif

#if defined(USE_LOCALE) && ! defined(USE_THREAD_SAFE_LOCALE)
#if defined(USE_LOCALE) && (defined(WIN32) || ! defined(USE_THREAD_SAFE_LOCALE))
PERLVARI(I, perl_controls_locale, bool, true)
#endif
#ifdef USE_PL_CUR_LC_ALL
Expand Down
21 changes: 13 additions & 8 deletions locale.c
Expand Up @@ -1529,7 +1529,7 @@ S_parse_LC_ALL_string(pTHX_ const char * string,

/* Find our internal index of the category name; uses a linear
* search */
const unsigned name_len = category_end - s;
const unsigned int name_len = (unsigned int) (category_end - s);
for (index = 0; index < C_ARRAY_LENGTH(category_names); index++) {
if ( name_len == category_name_lengths[index]
&& memEQ(s, category_names[index], name_len))
Expand Down Expand Up @@ -3333,12 +3333,6 @@ S_calculate_LC_ALL_string(pTHX_ const char ** category_locales_list,
}
else

# endif
# ifdef USE_PL_CUR_LC_ALL

Safefree(PL_cur_LC_ALL);
PL_cur_LC_ALL = savepv(aggregate_locale);

# endif

{
Expand Down Expand Up @@ -3462,6 +3456,14 @@ S_calculate_LC_ALL_string(pTHX_ const char ** category_locales_list,
PL_curlocales[LC_ALL_INDEX_] = savepv(retval);
}

# endif
# ifdef USE_PL_CUR_LC_ALL

if (format == INTERNAL_FORMAT) {
Safefree(PL_cur_LC_ALL);
PL_cur_LC_ALL = savepv(retval);
}

# endif

DEBUG_L(PerlIO_printf(Perl_debug_log,
Expand Down Expand Up @@ -3606,7 +3608,8 @@ S_find_locale_from_environment(pTHX_ const locale_category_index index)
/* For each desired category, use any corresponding environment variable;
* or the default if none such exists. */
bool is_disparate = false; /* Assume is uniform until proven otherwise */
for (unsigned i = lower; i <= upper; i++) {
// XXX i should be locale_category_index
for (unsigned int i = lower; i <= upper; i++) {
const char * const env_override = PerlEnv_getenv(category_names[i]);
unsigned int j = i - offset;

Expand Down Expand Up @@ -9946,6 +9949,8 @@ Perl_thread_locale_init(pTHX)
locale_panic_("_configthreadlocale returned an error");
}

PL_perl_controls_locale = true;

# endif

void_setlocale_c(LC_ALL, "C");
Expand Down
3 changes: 2 additions & 1 deletion makedef.pl
Expand Up @@ -482,7 +482,8 @@ sub readvar {
);
}

unless ($define{USE_LOCALE})
unless ($define{USE_LOCALE} && ( $define{WIN32}
|| ! $define{USE_THREAD_SAFE_LOCALE}))
{
++$skip{$_} foreach qw(
PL_perl_controls_locale
Expand Down
6 changes: 3 additions & 3 deletions sv.c
Expand Up @@ -16035,9 +16035,9 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
PL_subname = sv_dup_inc(proto_perl->Isubname, param);

/* We copy the locale state of the current thread to the new one. The new one
* is supposed to start in the C locale (XXX is this inconsistency correct?) but on dangerous systems it is just copied, so as to avoid affecting the parent global state. This gets much better if emulation is in effect */
#if defined(USE_LOCALE) && ! defined(USE_THREAD_SAFE_LOCALE)
PL_perl_controls_locale = TRUE;
* XXX is supposed to start in the C locale (XXX is this inconsistency correct?) but on dangerous systems it is just copied, so as to avoid affecting the parent global state. This gets much better if emulation is in effect */
#if defined(USE_LOCALE) && (defined(WIN32) || ! defined(USE_THREAD_SAFE_LOCALE))
PL_perl_controls_locale = false;
#endif
#ifdef USE_PL_CURLOCALES
for (i = 0; i < (int) C_ARRAY_LENGTH(PL_curlocales); i++) {
Expand Down

0 comments on commit dffc180

Please sign in to comment.