Skip to content

Commit

Permalink
locale.c: Move #define to perl.h; use it elsewhere
Browse files Browse the repository at this point in the history
 Rather than recalculate this combined conditional, do it once in
 perl.h.
  • Loading branch information
khwilliamson committed May 6, 2021
1 parent f582fef commit cad5013
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
4 changes: 1 addition & 3 deletions intrpvar.h
Expand Up @@ -717,9 +717,7 @@ PERLVAR(I, constpadix, PADOFFSET) /* lowest unused for constants */

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

#if defined(USE_POSIX_2008_LOCALE) \
&& defined(USE_THREAD_SAFE_LOCALE) \
&& ! defined(HAS_QUERYLOCALE)
#ifdef USE_PL_CURLOCALES

/* This is the most number of categories we've encountered so far on any
* platform */
Expand Down
4 changes: 1 addition & 3 deletions locale.c
Expand Up @@ -571,9 +571,7 @@ Perl_locale_panic(const char * msg,
# define querylocale_c(cat) querylocale_i(cat##_INDEX_)
# define querylocale_r(cat) querylocale_i(get_category_index(cat,NULL))

# ifndef USE_QUERYLOCALE
# define USE_PL_CURLOCALES
# else
# ifdef USE_QUERYLOCALE
# define isSINGLE_BIT_SET(mask) isPOWER_OF_2(mask)

/* This code used to think querylocale() was valid on LC_ALL. Make sure
Expand Down
8 changes: 7 additions & 1 deletion makedef.pl
Expand Up @@ -159,6 +159,12 @@ BEGIN
$define{USE_POSIX_2008_LOCALE} = 1 if $define{HAS_POSIX_2008_LOCALE};
}

if ( ($define{USE_POSIX_2008_LOCALE} && ! $define{HAS_QUERYLOCALE})
|| ($define{USE_LOCALE_THREADS} && ! $define{USE_THREAD_SAFE_LOCALE}))
{
$define{USE_PL_CURLOCALES} = 1;
}

if ( $ARGS{PLATFORM} eq 'win32'
&& $define{USE_THREAD_SAFE_LOCALE}
&& $cctype < 140)
Expand Down Expand Up @@ -417,7 +423,7 @@ sub readvar {
PL_underlying_numeric_obj
);
}
unless ($define{USE_POSIX_2008_LOCALE} && ! $define{HAS_QUERY_LOCALE})
unless ($define{USE_PL_CURLOCALES})
{
++$skip{$_} foreach qw(
PL_curlocales
Expand Down
4 changes: 1 addition & 3 deletions perl.c
Expand Up @@ -1109,9 +1109,7 @@ perl_destruct(pTHXx)
Safefree(PL_collation_name);
PL_collation_name = NULL;
#endif
#if defined(USE_POSIX_2008_LOCALE) \
&& defined(USE_THREAD_SAFE_LOCALE) \
&& ! defined(HAS_QUERYLOCALE)
#if defined(USE_PL_CURLOCALES)
for (i = 0; i < (int) C_ARRAY_LENGTH(PL_curlocales); i++) {
Safefree(PL_curlocales[i]);
PL_curlocales[i] = NULL;
Expand Down
5 changes: 5 additions & 0 deletions perl.h
Expand Up @@ -1118,6 +1118,11 @@ Example usage:
# endif
# endif

# if (defined(USE_POSIX_2008_LOCALE) && ! defined(USE_QUERYLOCALE)) \
|| (defined(USE_LOCALE_THREADS) && ! defined(USE_THREAD_SAFE_LOCALE))
# define USE_PL_CURLOCALES
# endif

/* Microsoft documentation reads in the change log for VS 2015:
* "The localeconv function declared in locale.h now works correctly when
* per-thread locale is enabled. In previous versions of the library, this
Expand Down
4 changes: 1 addition & 3 deletions sv.c
Expand Up @@ -15645,9 +15645,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,

PL_subname = sv_dup_inc(proto_perl->Isubname, param);

#if defined(USE_POSIX_2008_LOCALE) \
&& defined(USE_THREAD_SAFE_LOCALE) \
&& ! defined(HAS_QUERYLOCALE)
#ifdef USE_PL_CURLOCALES
for (i = 0; i < (int) C_ARRAY_LENGTH(PL_curlocales); i++) {
PL_curlocales[i] = SAVEPV(proto_perl->Icurlocales[i]);
}
Expand Down

0 comments on commit cad5013

Please sign in to comment.