Skip to content

Commit

Permalink
Initialize PL_numeric_name, PL_collation_name
Browse files Browse the repository at this point in the history
Having these initialized to the C locale aoids some otherwise required
conditionals.
  • Loading branch information
khwilliamson committed Aug 10, 2022
1 parent 48bf7c2 commit 616697b
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions locale.c
Expand Up @@ -1638,7 +1638,7 @@ S_new_numeric(pTHX_ const char *newnum)

if (! newnum) {
Safefree(PL_numeric_name);
PL_numeric_name = NULL;
PL_numeric_name = savepv("C");
PL_numeric_standard = TRUE;
PL_numeric_underlying = TRUE;
PL_numeric_underlying_is_standard = TRUE;
Expand All @@ -1664,7 +1664,7 @@ S_new_numeric(pTHX_ const char *newnum)
# endif

/* Save the new name if it isn't the same as the previous one, if any */
if (! PL_numeric_name || strNE(PL_numeric_name, save_newnum)) {
if (strNE(PL_numeric_name, save_newnum)) {
/* Save the locale name for future use */
Safefree(PL_numeric_name);
PL_numeric_name = save_newnum;
Expand Down Expand Up @@ -2138,11 +2138,9 @@ S_new_collate(pTHX_ const char *newcoll)
* an unlikely bug */

if (! newcoll) {
if (PL_collation_name) {
++PL_collation_ix;
Safefree(PL_collation_name);
PL_collation_name = NULL;
}
++PL_collation_ix;
Safefree(PL_collation_name);
PL_collation_name = NULL;
PL_collation_standard = TRUE;
is_standard_collation:
PL_collxfrm_base = 0;
Expand All @@ -2154,7 +2152,7 @@ S_new_collate(pTHX_ const char *newcoll)
}

/* If this is not the same locale as currently, set the new one up */
if (! PL_collation_name || strNE(PL_collation_name, newcoll)) {
if (strNE(PL_collation_name, newcoll)) {
++PL_collation_ix;
Safefree(PL_collation_name);
PL_collation_name = savepv(newcoll);
Expand Down Expand Up @@ -3726,6 +3724,14 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
# ifdef USE_LOCALE_NUMERIC

PL_numeric_radix_sv = newSVpvs(".");
Newx(PL_numeric_name, 2, char);
Copy("C", PL_numeric_name, 2, char);

# endif
# ifdef USE_LOCALE_COLLATE

Newx(PL_collation_name, 2, char);
Copy("C", PL_collation_name, 2, char);

# endif
# ifdef USE_PL_CURLOCALES
Expand Down

0 comments on commit 616697b

Please sign in to comment.