diff options
author | Tony Cook <tony@develop-help.com> | 2021-06-24 14:49:55 +1000 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2021-08-11 14:40:22 +1000 |
commit | 68f1b6d700b9662cfdec43ceddbd086d4b59c87e (patch) | |
tree | 63621a829b468f50b903296b5259e9ebfa80ce02 | |
parent | 7e12ee61fac08d210b4f192160a1de75771f27c9 (diff) | |
download | perl-68f1b6d700b9662cfdec43ceddbd086d4b59c87e.tar.gz |
only #include <xlocale.h> when it is actually needed
This header was originally only needed for builds on darwin and
FreeBSD, but was being included whenever it was detected.
This has caused problems when what was an internal header was
removed (from glibc) and in general wasn't needed anyway.
On FreeBSD only localeconv_l() requires xlocale.h, so we test
specifically for that.
-rwxr-xr-x | Configure | 50 | ||||
-rw-r--r-- | Cross/config.sh-arm-linux | 1 | ||||
-rw-r--r-- | Cross/config.sh-arm-linux-n770 | 1 | ||||
-rw-r--r-- | NetWare/config.wc | 1 | ||||
-rw-r--r-- | Porting/config.sh | 1 | ||||
-rwxr-xr-x | config_h.SH | 9 | ||||
-rw-r--r-- | configure.com | 1 | ||||
-rw-r--r-- | perl.h | 2 | ||||
-rw-r--r-- | plan9/config_sh.sample | 1 | ||||
-rw-r--r-- | uconfig.h | 13 | ||||
-rw-r--r-- | uconfig.sh | 1 | ||||
-rw-r--r-- | uconfig64.sh | 1 | ||||
-rw-r--r-- | win32/config.gc | 1 | ||||
-rw-r--r-- | win32/config.vc | 1 |
14 files changed, 77 insertions, 7 deletions
@@ -1401,6 +1401,7 @@ installvendorscript='' vendorscript='' vendorscriptexp='' versiononly='' +xlocale_needed='' yacc='' yaccflags='' CONFIG='' @@ -16095,6 +16096,54 @@ eval $inlibc set localeconv_l d_localeconv_l eval $inlibc +: if we have xlocale.h, check whether it is needed +case "$i_xlocale$d_newlocale$xlocale_needed" in +"$define$define") + echo "Checking if xlocale.h is needed..." >&4 + $cat >try.c <<EOF +#include <locale.h> +#include <stdio.h> +#ifdef TRY_XLOCALE +#include <xlocale.h> +#endif +#$d_localeconv_l HAVE_LOCALECONV_L + +#ifdef HAVE_LOCALECONV_L +struct lconv *(*lcptr)(locale_t) = localeconv_l; +#endif + +int main(void) { + locale_t lc = newlocale(LC_ALL_MASK, "C", (locale_t)0); + +#ifdef HAVE_LOCALECONV_L + /* FreeBSD hides only localeconv_l() in xlocale.h */ + struct lconv *lcbuf = localeconv_l(lc); + printf("decimal: %s\n", lcbuf->decimal_point); +#endif + + freelocale(lc); + return 0; +} +EOF + set try + if eval $compile && $run ./try > /dev/null 2>&1 ; then + echo "xlocale.h isn't needed" >&4 + xlocale_needed=$undef + else + set try -DTRY_XLOCALE + if eval $compile && $run ./try > /dev/null 2>&1 ; then + xlocale_needed=$define + echo "xlocale.h is needed" >&4 + else + echo "I can't build my test either way" >&4 + xlocale_needed=$undef + fi + fi + $rm_try + ;; +*) xlocale_needed=$undef ;; +esac + : see if localtime_r exists set localtime_r d_localtime_r eval $inlibc @@ -25368,6 +25417,7 @@ version_patchlevel_string='$version_patchlevel_string' versiononly='$versiononly' vi='$vi' xlibpth='$xlibpth' +xlocale_needed='$xlocale_needed' yacc='$yacc' yaccflags='$yaccflags' zcat='$zcat' diff --git a/Cross/config.sh-arm-linux b/Cross/config.sh-arm-linux index 3534d3734f..dc3e95e59b 100644 --- a/Cross/config.sh-arm-linux +++ b/Cross/config.sh-arm-linux @@ -1189,6 +1189,7 @@ version_patchlevel_string='version 35 subversion 3' versiononly='undef' vi='' xlibpth='/usr/lib/386 /lib/386' +xlocale_needed='undef' yacc='yacc' yaccflags='' zcat='' diff --git a/Cross/config.sh-arm-linux-n770 b/Cross/config.sh-arm-linux-n770 index d3aad6985a..37460a9859 100644 --- a/Cross/config.sh-arm-linux-n770 +++ b/Cross/config.sh-arm-linux-n770 @@ -1187,6 +1187,7 @@ version_patchlevel_string='version 35 subversion 3' versiononly='undef' vi='' xlibpth='/usr/lib/386 /lib/386' +xlocale_needed='undef' yacc='yacc' yaccflags='' zcat='' diff --git a/NetWare/config.wc b/NetWare/config.wc index cd2ec73619..e6f9650a2e 100644 --- a/NetWare/config.wc +++ b/NetWare/config.wc @@ -1140,6 +1140,7 @@ vendorprefixexp='' version='~VERSION~' vi='' xlibpth='/usr/lib/386 /lib/386' +xlocale_needed='undef' zcat='' zip='zip' PERL_REVISION='~PERL_REVISION~' diff --git a/Porting/config.sh b/Porting/config.sh index 8a6ab5d17f..89f6bd952d 100644 --- a/Porting/config.sh +++ b/Porting/config.sh @@ -1225,6 +1225,7 @@ version_patchlevel_string='version 35 subversion 3' versiononly='define' vi='' xlibpth='/usr/lib/386 /lib/386' +xlocale_needed='undef' yacc='yacc' yaccflags='' zcat='' diff --git a/config_h.SH b/config_h.SH index 40a80e312e..834dc9f2ee 100755 --- a/config_h.SH +++ b/config_h.SH @@ -3142,8 +3142,12 @@ sed <<!GROK!THIS! >$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un * available to return the name of the locale for a category mask. */ /* I_XLOCALE: - * This symbol, if defined, indicates to the C program that it should - * include <xlocale.h> to get uselocale() and its friends. + * This symbol, if defined, indicates to the C program that the + * xlocale.h header is available. See also NEED_XLOCALE_H. + */ +/* NEED_XLOCALE_H: + * This symbol, if defined, indicates that the C program should + * include <xlocale.h> to get newlocale() and its friends. */ #$d_newlocale HAS_NEWLOCALE /**/ #$d_freelocale HAS_FREELOCALE /**/ @@ -3151,6 +3155,7 @@ sed <<!GROK!THIS! >$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un #$d_duplocale HAS_DUPLOCALE /**/ #$d_querylocale HAS_QUERYLOCALE /**/ #$i_xlocale I_XLOCALE /**/ +#$xlocale_needed NEED_XLOCALE_H /**/ /* HAS_NEXTAFTER: * This symbol, if defined, indicates that the nextafter routine is diff --git a/configure.com b/configure.com index 2704cb2459..126a372e5b 100644 --- a/configure.com +++ b/configure.com @@ -6790,6 +6790,7 @@ $ WC "i_vfork='undef'" $ WC "i_wchar='define'" $ WC "i_wctype='define'" $ WC "i_xlocale='undef'" +$ WC "xlocale_needed='undef'" $ WC "inc_version_list='0'" $ WC "inc_version_list_init='0'" $ WC "installarchlib='" + installarchlib + "'" @@ -926,7 +926,7 @@ Example usage: # include <locale.h> #endif -#ifdef I_XLOCALE +#ifdef NEED_XLOCALE_H # include <xlocale.h> #endif diff --git a/plan9/config_sh.sample b/plan9/config_sh.sample index 4da1f0f682..23c15a3e90 100644 --- a/plan9/config_sh.sample +++ b/plan9/config_sh.sample @@ -1150,6 +1150,7 @@ version_patchlevel_string='version 35 subversion 3' versiononly='undef' vi='' xlibpth='' +xlocale_needed='undef' yacc='yacc' yaccflags='' zcat='' @@ -3107,8 +3107,12 @@ * available to return the name of the locale for a category mask. */ /* I_XLOCALE: - * This symbol, if defined, indicates to the C program that it should - * include <xlocale.h> to get uselocale() and its friends. + * This symbol, if defined, indicates to the C program that the + * xlocale.h header is available. See also NEED_XLOCALE_H. + */ +/* NEED_XLOCALE_H: + * This symbol, if defined, indicates that the C program should + * include <xlocale.h> to get newlocale() and its friends. */ /*#define HAS_NEWLOCALE / **/ /*#define HAS_FREELOCALE / **/ @@ -3116,6 +3120,7 @@ /*#define HAS_DUPLOCALE / **/ /*#define HAS_QUERYLOCALE / **/ /*#define I_XLOCALE / **/ +/*#define NEED_XLOCALE_H / **/ /* HAS_NEXTAFTER: * This symbol, if defined, indicates that the nextafter routine is @@ -5313,6 +5318,6 @@ #endif /* Generated from: - * 55a531381747550c11c2c61b9a9da2dacde4df465b874df55a9c923e495deb3a config_h.SH - * 2fece1e405c60ae089fe55acaa42471b6fba78b7ab4cefc6d5e18a94b72fc2c4 uconfig.sh + * c0ae90ad8256740b1a7872cebe079e964a7a9a5c8128038a60de0ab610d9e9fe config_h.SH + * 24570f2ff38b22b436d34127ff85a3f3a075a4dea1359c56f16196bdbe376b1c uconfig.sh * ex: set ro: */ diff --git a/uconfig.sh b/uconfig.sh index 898ff9979f..0be83882a0 100644 --- a/uconfig.sh +++ b/uconfig.sh @@ -922,4 +922,5 @@ vendorarchexp='' vendorlib_stem='' vendorlibexp='' versiononly='undef' +xlocale_needed='undef' zip='' diff --git a/uconfig64.sh b/uconfig64.sh index c9a9559af7..307e502946 100644 --- a/uconfig64.sh +++ b/uconfig64.sh @@ -922,4 +922,5 @@ vendorarchexp='' vendorlib_stem='' vendorlibexp='' versiononly='undef' +xlocale_needed='undef' zip='' diff --git a/win32/config.gc b/win32/config.gc index 4abd85395f..25fe7f0549 100644 --- a/win32/config.gc +++ b/win32/config.gc @@ -1184,6 +1184,7 @@ version_patchlevel_string='' versiononly='undef' vi='' xlibpth='/usr/lib/386 /lib/386' +xlocale_needed='undef' yacc='yacc' yaccflags='' zcat='' diff --git a/win32/config.vc b/win32/config.vc index 0f89bc6ee0..dbc8967bd6 100644 --- a/win32/config.vc +++ b/win32/config.vc @@ -1183,6 +1183,7 @@ version_patchlevel_string='' versiononly='undef' vi='' xlibpth='/usr/lib/386 /lib/386' +xlocale_needed='undef' yacc='yacc' yaccflags='' zcat='' |