Skip to content

Commit

Permalink
PLcurlocales
Browse files Browse the repository at this point in the history
  • Loading branch information
khwilliamson committed May 6, 2021
1 parent 72fafcf commit 5178e05
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
1 change: 1 addition & 0 deletions embedvar.h
Expand Up @@ -111,6 +111,7 @@
#define PL_curcop (vTHX->Icurcop)
#define PL_curcopdb (vTHX->Icurcopdb)
#define PL_curlocales (vTHX->Icurlocales)
#define PL_curlocales_sizes (vTHX->Icurlocales_sizes)
#define PL_curpad (vTHX->Icurpad)
#define PL_curpm (vTHX->Icurpm)
#define PL_curpm_under (vTHX->Icurpm_under)
Expand Down
15 changes: 8 additions & 7 deletions intrpvar.h
Expand Up @@ -367,6 +367,14 @@ PERLVAR(I, utf8locale, bool) /* utf8 locale detected */
PERLVAR(I, in_utf8_CTYPE_locale, bool)
PERLVAR(I, in_utf8_COLLATE_locale, bool)
PERLVAR(I, in_utf8_turkic_locale, bool)

#ifdef USE_PL_CURLOCALES
/* This is the most number of categories we've encountered so far on any
* platform */
PERLVARA(I, curlocales, 12, const char *)
PERLVARA(I, curlocales_sizes, 12, Size_t)
#endif

#if defined(USE_LOCALE) && defined(USE_LOCALE_THREADS)
PERLVARI(I, locale_mutex_depth, int, 0) /* Emulate general semaphore */
#endif
Expand Down Expand Up @@ -717,13 +725,6 @@ PERLVAR(I, constpadix, PADOFFSET) /* lowest unused for constants */

PERLVAR(I, padix_floor, PADOFFSET) /* how low may inner block reset padix */

#ifdef USE_PL_CURLOCALES

/* This is the most number of categories we've encountered so far on any
* platform */
PERLVARA(I, curlocales, 12, const char *)

#endif
#ifdef USE_LOCALE_COLLATE

PERLVAR(I, collation_name, char *) /* Name of current collation */
Expand Down
15 changes: 5 additions & 10 deletions locale.c
Expand Up @@ -854,27 +854,23 @@ S_update_PL_curlocales_i(pTHX_
/* PL_curlocales is a parallel array, so has same
* length as 'categories' */
for (i = 0; i < LC_ALL_INDEX_; i++) {
Safefree(PL_curlocales[i]);
PL_curlocales[i] = savepv(new_locale);
save_to_buffer(new_locale, &PL_curlocales[i], &PL_curlocales_sizes[i]);
}

recalc_LC_ALL = TRUE;
}
else {

/* Update the single category's record */
Safefree(PL_curlocales[index]);
PL_curlocales[index] = savepv(new_locale);
save_to_buffer(new_locale, &PL_curlocales[index], &PL_curlocales_sizes[index]);

if (recalc_LC_ALL == LOOPING) {
recalc_LC_ALL = (index == NOMINAL_LC_ALL_INDEX - 1);
}
}

if (recalc_LC_ALL) { /* And recalculate LC_ALL */
Safefree(PL_curlocales[LC_ALL_INDEX_]);
PL_curlocales[LC_ALL_INDEX_] =
savepv(calculate_LC_ALL(PL_curlocales));
save_to_buffer(calculate_LC_ALL(PL_curlocales), &PL_curlocales[LC_ALL_INDEX_], &PL_curlocales_sizes[LC_ALL_INDEX_]);
}

return PL_curlocales[index];
Expand Down Expand Up @@ -997,8 +993,6 @@ S_setlocale_from_aggregate_LC_ALL(pTHX_ const char * locale, const line_t line)
* as the value may omit categories whose locale is 'C'. khw thinks it's
* better to store a complete LC_ALL. So calculate it. */
retval = savepv(calculate_LC_ALL(PL_curlocales));
Safefree(PL_curlocales[LC_ALL_INDEX_]);
PL_curlocales[LC_ALL_INDEX_] = retval;

Safefree(locale_on_entry);
return retval;
Expand Down Expand Up @@ -5274,7 +5268,8 @@ Perl_init_i18nl10n(pTHX_ int printwarn)

/* Similarly, in this case we need to fill in our records. */
for (i = 0; i < NOMINAL_LC_ALL_INDEX; i++) {
PL_curlocales[i] = savepv(curlocales[i]);
PL_curlocales_sizes[i] = 0;
save_to_buffer(curlocales[i], &PL_curlocales[i], &PL_curlocales_sizes[i]);
}

# endif
Expand Down
1 change: 1 addition & 0 deletions sv.c
Expand Up @@ -15648,6 +15648,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
#ifdef USE_PL_CURLOCALES
for (i = 0; i < (int) C_ARRAY_LENGTH(PL_curlocales); i++) {
PL_curlocales[i] = SAVEPV(proto_perl->Icurlocales[i]);
PL_curlocales_sizes[i] = strlen(PL_curlocales[i]);
}
#endif
#ifdef USE_LOCALE_CTYPE
Expand Down

0 comments on commit 5178e05

Please sign in to comment.