Skip to content

Commit

Permalink
f Configure
Browse files Browse the repository at this point in the history
  • Loading branch information
khwilliamson committed May 6, 2023
1 parent c4f89da commit ac7afc0
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 116 deletions.
119 changes: 28 additions & 91 deletions Configure
Expand Up @@ -953,11 +953,11 @@ d_wcsxfrm=''
d_wctomb=''
d_writev=''
default_inc_excludes_dot=''
d_lc_all_category_positions_init=''
d_lc_all_separator=''
d_lc_all_uses_name_value_pairs=''
lc_all_category_positions_init=''
lc_all_separator=''
d_perl_lc_all_category_positions_init=''
d_perl_lc_all_separator=''
d_perl_lc_all_uses_name_value_pairs=''
perl_lc_all_category_positions_init=''
perl_lc_all_separator=''
dlext=''
bin_ELF=''
cccdlflags=''
Expand Down Expand Up @@ -16371,23 +16371,23 @@ if eval $compile_ok; then
echo "'$separator'" >&4
case $separator in
"\"=;\"")
d_lc_all_uses_name_value_pairs="$define"
d_lc_all_separator="$undef"
lc_all_separator=
d_lc_all_category_positions_init="$undef"
lc_all_category_positions_init=
d_perl_lc_all_uses_name_value_pairs="$define"
d_perl_lc_all_separator="$undef"
perl_lc_all_separator=
d_perl_lc_all_category_positions_init="$undef"
perl_lc_all_category_positions_init=
;;
"") d_lc_all_uses_name_value_pairs="$undef"
d_lc_all_separator="$undef"
lc_all_separator=
d_lc_all_category_positions_init="$undef"
lc_all_category_positions_init=
"") d_perl_lc_all_uses_name_value_pairs="$undef"
d_perl_lc_all_separator="$undef"
perl_lc_all_separator=
d_perl_lc_all_category_positions_init="$undef"
perl_lc_all_category_positions_init=
;;
*) d_lc_all_uses_name_value_pairs="$undef"
d_lc_all_separator="$define"
lc_all_separator="$separator"
d_lc_all_category_positions_init="$define"
lc_all_category_positions_init=`echo "$output" | sed -n 2p`
*) d_perl_lc_all_uses_name_value_pairs="$undef"
d_perl_lc_all_separator="$define"
perl_lc_all_separator="$separator"
d_perl_lc_all_category_positions_init="$define"
perl_lc_all_category_positions_init=`echo "$output" | sed -n 2p`
;;
esac

Expand Down Expand Up @@ -18529,72 +18529,9 @@ int main() {

}

#if 0

/* Currently unused code to determine if LC_ALL with disparate values uses
* category = value pairs or positional, and to determine the separator
* between the categories. We could add code so that if the separator were
* > '9', we subtract 10; similarly for 'Z' and 'z', and then just about
* every possible ASCII separator would fit in the 5 bits available in the
* exit code. This would not be true in EBCDIC. And then if LC_ALL is
* positional, we probably would want to know the order of the categories.
* Using a file between the C program and the shell script would really be
* require to do that */
#ifdef LC_ALL

unsigned char min_separator = ' ' - 1;
unsigned char separator = min_separator;
int uses_name_value_pair_names = 0;

name = setlocale(LC_ALL, "C");
if (name == NULL || strcmp(name, "C") != 0) {
exit(bad_setlocale);
}

if (has_C_UTF8) {
char * pos;

name = setlocale(LC_CTYPE, "C.UTF-8");
if (name == NULL) {
exit(bad_setlocale);
}
name = setlocale(LC_ALL, NULL);
if (name == NULL) {
exit(bad_setlocale);
}

pos = strstr(name, "LC_CTYPE" "=C.UTF-8");
if (pos != NULL) {
uses_name_value_pair_names = 1;
if (pos == name) {
separator = name[sizeof("LC_CTYPE=C.UTF-8") - 1];
}
else {
separator = *(pos - 1);
}
}
else {
pos = strstr(name, "C.UTF-8");
if (pos == NULL) {
/* bad */
}
else if (pos == name) {
separator = name[sizeof("C.UTF-8") - 1];
}
else {
separator = *(pos - 1);
}
}
}

#endif
#endif

exit( 0 /* (separator - min_separator) << 3
| uses_name_value_pair_names << 2
*/
| has_C_UTF8 << 1
| accepts_any_locale_name);
exit( 0
| has_C_UTF8 << 1
| accepts_any_locale_name);

}
EOCP
Expand Down Expand Up @@ -25160,9 +25097,9 @@ d_isnormal='$d_isnormal'
d_j0='$d_j0'
d_j0l='$d_j0l'
d_killpg='$d_killpg'
d_lc_all_category_positions_init='$d_lc_all_category_positions_init'
d_lc_all_separator='$d_lc_all_separator'
d_lc_all_uses_name_value_pairs='$d_lc_all_uses_name_value_pairs'
d_perl_lc_all_category_positions_init='$d_perl_lc_all_category_positions_init'
d_perl_lc_all_separator='$d_perl_lc_all_separator'
d_perl_lc_all_uses_name_value_pairs='$d_perl_lc_all_uses_name_value_pairs'
d_lc_monetary_2008='$d_lc_monetary_2008'
d_lchown='$d_lchown'
d_ldbl_dig='$d_ldbl_dig'
Expand Down Expand Up @@ -25705,8 +25642,8 @@ ivsize='$ivsize'
ivtype='$ivtype'
known_extensions='$known_extensions'
ksh='$ksh'
lc_all_category_positions_init='$lc_all_category_positions_init'
lc_all_separator='$lc_all_separator'
perl_lc_all_category_positions_init='$perl_lc_all_category_positions_init'
perl_lc_all_separator='$perl_lc_all_separator'
ld='$ld'
ld_can_script='$ld_can_script'
lddlflags='$lddlflags'
Expand Down
32 changes: 16 additions & 16 deletions locale.c
Expand Up @@ -375,7 +375,7 @@ S_positional_newlocale(int mask, const char * locale, locale_t base)
/* This is a starting guess as to when this is true. It definititely isn't
* true on *BSD where positional LC_ALL notation is used. Likely this will end
* up being defined in hints files. */
#ifdef LC_ALL_USES_NAME_VALUE_PAIRS
#ifdef PERL_LC_ALL_USES_NAME_VALUE_PAIRS
# define NEWLOCALE_HANDLES_DISPARATE_LC_ALL
#endif

Expand All @@ -398,15 +398,15 @@ S_positional_newlocale(int mask, const char * locale, locale_t base)
* 'name' which represents LC_ALL is uniform or disparate. There are two
* situations: 1) the platform uses unordered name=value pairs; 2) the platform
* uses ordered positional values, with a separator string between them */
# ifdef LC_ALL_SEPARATOR /* positional */
# define is_disparate_LC_ALL(name) cBOOL(instr(name, LC_ALL_SEPARATOR))
# ifdef PERL_LC_ALL_SEPARATOR /* positional */
# define is_disparate_LC_ALL(name) cBOOL(instr(name, PERL_LC_ALL_SEPARATOR))
# else /* name=value */

/* In the, hopefully never occurring, event that the platform doesn't use
* either mechanism for disparate LC_ALL's, assume the name=value pairs
* form, rather than taking the extreme step of refusing to compile. Many
* programs won't have disparate locales, so will generally work */
# define LC_ALL_SEPARATOR ";"
# define PERL_LC_ALL_SEPARATOR ";"
# define is_disparate_LC_ALL(name) cBOOL( strchr(name, ';') \
&& strchr(name, '='))
# endif
Expand Down Expand Up @@ -1056,7 +1056,7 @@ STATIC const int category_masks[] = {
};

# endif
# if ! defined(LC_ALL_USES_NAME_VALUE_PAIRS)
# if ! defined(PERL_LC_ALL_USES_NAME_VALUE_PAIRS)

/* On platforms that use positional notation for expressing LC_ALL, this maps
* the position of each category to our corresponding internal index for it.
Expand Down Expand Up @@ -1389,7 +1389,7 @@ S_parse_LC_ALL_string(pTHX_ const char * string,
"\nnew='%s'\nCalled from %" LINE_Tf "\n",
string, caller_line));

# ifdef LC_ALL_USES_NAME_VALUE_PAIRS
# ifdef PERL_LC_ALL_USES_NAME_VALUE_PAIRS

const char separator[] = ";";
const Size_t separator_len = 1;
Expand All @@ -1410,8 +1410,8 @@ S_parse_LC_ALL_string(pTHX_ const char * string,
single_component = false; /* Since has both [;=], must be multi */
}
else {
separator = LC_ALL_SEPARATOR;
separator_len = STRLENs(LC_ALL_SEPARATOR);
separator = PERL_LC_ALL_SEPARATOR;
separator_len = STRLENs(PERL_LC_ALL_SEPARATOR);
single_component = instr(string, separator) == NULL;
}

Expand Down Expand Up @@ -1482,7 +1482,7 @@ S_parse_LC_ALL_string(pTHX_ const char * string,
next_sep = e;
}

# ifndef LC_ALL_USES_NAME_VALUE_PAIRS
# ifndef PERL_LC_ALL_USES_NAME_VALUE_PAIRS

if (! name_value) {
/* Get the index of the category in this position */
Expand Down Expand Up @@ -1565,7 +1565,7 @@ S_parse_LC_ALL_string(pTHX_ const char * string,
*
* Check if the input was incomplete. */

# ifndef LC_ALL_USES_NAME_VALUE_PAIRS
# ifndef PERL_LC_ALL_USES_NAME_VALUE_PAIRS

if (! name_value) { /* Positional notation */
if (component_number != LOCALE_CATEGORIES_COUNT_) {
Expand Down Expand Up @@ -3283,7 +3283,7 @@ S_calculate_LC_ALL_string(pTHX_ const char ** category_locales_list,
Size_t total_len;
const char *separator;

# ifdef LC_ALL_USES_NAME_VALUE_PAIRS /* Positional formatted LC_ALL */
# ifdef PERL_LC_ALL_USES_NAME_VALUE_PAIRS /* Positional formatted LC_ALL */
PERL_UNUSED_ARG(format);
# else

Expand All @@ -3292,9 +3292,9 @@ S_calculate_LC_ALL_string(pTHX_ const char ** category_locales_list,
/* Here, we will be using positional notation. it includes n-1
* separators */
total_len = ( LOCALE_CATEGORIES_COUNT_ - 1)
* STRLENs(LC_ALL_SEPARATOR)
* STRLENs(PERL_LC_ALL_SEPARATOR)
+ 1; /* And a trailing NUL */
separator = LC_ALL_SEPARATOR;
separator = PERL_LC_ALL_SEPARATOR;
}
else

Expand Down Expand Up @@ -3369,7 +3369,7 @@ S_calculate_LC_ALL_string(pTHX_ const char ** category_locales_list,
Size_t needed_len;
unsigned int i = j;

# ifndef LC_ALL_USES_NAME_VALUE_PAIRS
# ifndef PERL_LC_ALL_USES_NAME_VALUE_PAIRS

if (UNLIKELY(format != INTERNAL_FORMAT)) {

Expand Down Expand Up @@ -7537,7 +7537,7 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
PL_restore_locale[i] = NULL;
}
# endif
# if ! defined(LC_ALL_USES_NAME_VALUE_PAIRS) && defined(LC_ALL)
# if ! defined(PERL_LC_ALL_USES_NAME_VALUE_PAIRS) && defined(LC_ALL)

LOCALE_LOCK;

Expand All @@ -7546,7 +7546,7 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
if (map_LC_ALL_position_to_index[0] == LC_ALL_INDEX_) {

/* Use this array initialized by a config.h constant */
int lc_all_category_positions[] = LC_ALL_CATEGORY_POSITIONS_INIT;
int lc_all_category_positions[] = PERL_LC_ALL_CATEGORY_POSITIONS_INIT;
STATIC_ASSERT_STMT( C_ARRAY_LENGTH(lc_all_category_positions)
== LOCALE_CATEGORIES_COUNT_);

Expand Down
6 changes: 3 additions & 3 deletions metaconfig.h
Expand Up @@ -15,7 +15,7 @@
*
* HAS_NON_INT_BITFIELDS
* I_SYS_SYSCALL
* LC_ALL_USES_NAME_VALUE_PAIRS
* LC_ALL_SEPARATOR
* LC_ALL_CATEGORY_POSITIONS_INIT
* PERL_LC_ALL_USES_NAME_VALUE_PAIRS
* PERL_LC_ALL_SEPARATOR
* PERL_LC_ALL_CATEGORY_POSITIONS_INIT
*/
14 changes: 8 additions & 6 deletions perl.h
Expand Up @@ -1325,12 +1325,14 @@ typedef enum {
* many bugs without trying it out on a real such platform. It would be
* possible to create the reverse definitions for people who have ready access
* to a posiional notation box, but harder to get a name=value box */
#if defined(USE_FAKE_LC_ALL_POSITIONAL_NOTATION) \
&& defined(LC_ALL_USES_NAME_VALUE_PAIRS)
# undef LC_ALL_USES_NAME_VALUE_PAIRS /**/
# define LC_ALL_CATEGORY_POSITIONS_INIT { 12, 11, 10, 9, 8, 7, 5, 4, 3, 2, 1, 0 }
# define LC_ALL_SEPARATOR "/ = /"
#endif
# if defined(USE_FAKE_LC_ALL_POSITIONAL_NOTATION) \
&& defined(PERL_LC_ALL_USES_NAME_VALUE_PAIRS)
# undef PERL_LC_ALL_USES_NAME_VALUE_PAIRS

# define PERL_LC_ALL_CATEGORY_POSITIONS_INIT /* Assumes glibc cateories */\
{ 12, 11, 10, 9, 8, 7, 5, 4, 3, 2, 1, 0 }
# define PERL_LC_ALL_SEPARATOR "/ = /"
# endif
/* =========================================================================
* The defines from here to the following ===== line are unfortunately
* duplicated in makedef.pl, and changes here MUST also be made there */
Expand Down

0 comments on commit ac7afc0

Please sign in to comment.