Skip to content

Commit

Permalink
locale.c: Rmv unused code
Browse files Browse the repository at this point in the history
The code to handle changing LC_NUMERIC and LC_COLLATION handled the
possibility of being passed a NULL locale name.  But we're not changing
things unless we have a new locale, and know its name, so a name is
always passed
  • Loading branch information
khwilliamson committed May 5, 2021
1 parent e2c7260 commit f318a04
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 29 deletions.
4 changes: 2 additions & 2 deletions embed.fnc
Expand Up @@ -3280,15 +3280,15 @@ S |const char *|calculate_LC_ALL|const locale_t cur_obj
# else
S |const char *|calculate_LC_ALL|NN const char ** individ_locales
# endif
S |void |new_collate |NULLOK const char* newcoll
S |void |new_collate |NN const char* newcoll
S |void |new_ctype |NN const char* newctype
Sr |void |setlocale_failure_panic_i|const unsigned int cat_index \
|NULLOK const char * current \
|NN const char * failed \
|const line_t caller_0_line \
|const line_t caller_1_line
S |void |set_numeric_radix|const bool use_locale
S |void |new_numeric |NULLOK const char* newnum
S |void |new_numeric |NN const char* newnum
S |void |new_LC_ALL |NULLOK const char* unused
S |const char *|toggle_locale_i|const unsigned switch_cat_index \
|NN const char * new_locale
Expand Down
34 changes: 9 additions & 25 deletions locale.c
Expand Up @@ -1557,6 +1557,8 @@ S_new_numeric(pTHX_ const char *newnum)
{
const char *save_newnum;

PERL_ARGS_ASSERT_NEW_NUMERIC;

# ifndef USE_LOCALE_NUMERIC

PERL_UNUSED_ARG(newnum);
Expand Down Expand Up @@ -1605,15 +1607,6 @@ S_new_numeric(pTHX_ const char *newnum)
* such platforms.
*/

if (! newnum) {
Safefree(PL_numeric_name);
PL_numeric_name = NULL;
PL_numeric_standard = TRUE;
PL_numeric_underlying = TRUE;
PL_numeric_underlying_is_standard = TRUE;
return;
}

save_newnum = savepv(newnum);
PL_numeric_underlying = TRUE;

Expand Down Expand Up @@ -2134,6 +2127,7 @@ S_new_LC_ALL(pTHX_ const char *unused)
STATIC void
S_new_collate(pTHX_ const char *newcoll)
{
PERL_ARGS_ASSERT_NEW_COLLATE;

# ifndef USE_LOCALE_COLLATE

Expand All @@ -2159,21 +2153,6 @@ S_new_collate(pTHX_ const char *newcoll)
* that a transformation would improperly be considered valid, leading to
* an unlikely bug */

if (! newcoll) {
if (PL_collation_name) {
++PL_collation_ix;
Safefree(PL_collation_name);
PL_collation_name = NULL;
}
PL_collation_standard = TRUE;
is_standard_collation:
PL_collxfrm_base = 0;
PL_collxfrm_mult = 2;
PL_in_utf8_COLLATE_locale = FALSE;
PL_strxfrm_NUL_replacement = '\0';
PL_strxfrm_max_cp = 0;
return;
}

/* If this is not the same locale as currently, set the new one up */
if (! PL_collation_name || strNE(PL_collation_name, newcoll)) {
Expand All @@ -2182,7 +2161,12 @@ S_new_collate(pTHX_ const char *newcoll)
PL_collation_name = savepv(newcoll);
PL_collation_standard = isNAME_C_OR_POSIX(newcoll);
if (PL_collation_standard) {
goto is_standard_collation;
PL_collxfrm_base = 0;
PL_collxfrm_mult = 2;
PL_in_utf8_COLLATE_locale = FALSE;
PL_strxfrm_NUL_replacement = '\0';
PL_strxfrm_max_cp = 0;
return;
}

PL_in_utf8_COLLATE_locale = is_locale_utf8(newcoll);
Expand Down
6 changes: 4 additions & 2 deletions proto.h
Expand Up @@ -5181,12 +5181,14 @@ STATIC bool S_is_locale_utf8(pTHX_ const char * locale);
STATIC void S_new_LC_ALL(pTHX_ const char* unused);
#define PERL_ARGS_ASSERT_NEW_LC_ALL
STATIC void S_new_collate(pTHX_ const char* newcoll);
#define PERL_ARGS_ASSERT_NEW_COLLATE
#define PERL_ARGS_ASSERT_NEW_COLLATE \
assert(newcoll)
STATIC void S_new_ctype(pTHX_ const char* newctype);
#define PERL_ARGS_ASSERT_NEW_CTYPE \
assert(newctype)
STATIC void S_new_numeric(pTHX_ const char* newnum);
#define PERL_ARGS_ASSERT_NEW_NUMERIC
#define PERL_ARGS_ASSERT_NEW_NUMERIC \
assert(newnum)
STATIC void S_restore_toggled_locale_i(pTHX_ const unsigned cat_index, const char * original_locale);
#define PERL_ARGS_ASSERT_RESTORE_TOGGLED_LOCALE_I
STATIC const char * S_save_to_buffer(const char * string, const char **buf, Size_t *buf_size)
Expand Down

0 comments on commit f318a04

Please sign in to comment.