ICU-480 detect nl_langinfo() and then tries to pass it CODESET and

_NL_CTYPE_CODESET_NAME, and set U_NL_LANGINFO_CODESET accordingly. If neither
works, define U_HAVE_NL_LANGINFO_CODESET to 0, for these NetBSD boxes...

X-SVN-Rev: 2690
This commit is contained in:
Yves Arrouye 2000-10-16 17:26:31 +00:00
parent d388f7cca2
commit 614eb112b5
4 changed files with 91 additions and 79 deletions

View File

@ -134,7 +134,13 @@ static char* u_bottomNBytesOfDouble(double* d, int n);
# define U_POSIX_LOCALE 1
#endif
#if U_HAVE_NL_LANGINFO
/*
* Only include langinfo.h if we have a way to get the codeset. If we later
* depend on more feature, we can test on U_HAVE_NL_LANGINFO.
*
*/
#if U_HAVE_NL_LANGINFO_CODESET
#include <langinfo.h>
#endif
@ -1621,14 +1627,9 @@ const char* uprv_getDefaultCodepage()
{
uprv_memset(codesetName, 0, 100);
}
#if U_HAVE_NL_LANGINFO
#if U_HAVE_NL_LANGINFO_CODESET
/**/ {
const char *codeset;
#if U_HAVE_CODESET
codeset = nl_langinfo(CODESET);
#else
codeset = nl_langinfo(_NL_CTYPE_CODESET_NAME);
#endif
const char *codeset = nl_langinfo(U_NL_LANGINFO_CODESET);
if (codeset != NULL) {
uprv_strcpy(codesetName, codeset);
}

View File

@ -171,8 +171,9 @@ typedef unsigned short uint16_t;
/* Information about POSIX support */
/*===========================================================================*/
#define U_HAVE_NL_LANGINFO @U_HAVE_NL_LANGINFO@
#define U_HAVE_CODESET @U_HAVE_CODESET@
#define U_HAVE_NL_LANGINFO @U_HAVE_NL_LANGINFO@
#define U_HAVE_NL_LANGINFO_CODESET @U_HAVE_NL_LANGINFO_CODESET@
#define U_NL_LANGINFO_CODESET @U_NL_LANGINFO_CODESET@
#define U_TZSET @U_TZSET@
#define U_TIMEZONE @U_TIMEZONE@

130
icu4c/source/configure vendored
View File

@ -1221,7 +1221,7 @@ case "${host}" in
fi ;;
*-*-mips*) icu_cv_host_frag=$srcdir/config/mh-irix ;;
*-*-linux*) icu_cv_host_frag=$srcdir/config/mh-linux ;;
*-*-freebsd*) icu_cv_host_frag=$srcdir/config/mh-freebsd ;;
*-*-freebsd*|*-*-netbsd*) icu_cv_host_frag=$srcdir/config/mh-freebsd ;;
*-*-aix*)
case "$CXX" in
*vacpp*)icu_cv_host_frag=$srcdir/config/mh-aix-va ;;
@ -2730,13 +2730,14 @@ fi
U_NL_LANGINFO_CODESET=0
echo $ac_n "checking for nl_langinfo""... $ac_c" 1>&6
echo "configure:2735: checking for nl_langinfo" >&5
echo "configure:2736: checking for nl_langinfo" >&5
if eval "test \"`echo '$''{'ac_cv_func_nl_langinfo'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2740 "configure"
#line 2741 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char nl_langinfo(); below. */
@ -2759,7 +2760,7 @@ nl_langinfo();
; return 0; }
EOF
if { (eval echo configure:2763: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_nl_langinfo=yes"
else
@ -2780,47 +2781,49 @@ U_HAVE_NL_LANGINFO=0
fi
U_HAVE_CODESET=0
if test $U_HAVE_NL_LANGINFO -eq 1; then
echo $ac_n "checking if nl_langinfo(CODESET) works""... $ac_c" 1>&6
echo "configure:2787: checking if nl_langinfo(CODESET) works" >&5
if eval "test \"`echo '$''{'ac_cv_have_codeset'+set}'`\" = set"; then
echo $ac_n "checking what to pass nl_langinfo to obtain the codeset""... $ac_c" 1>&6
echo "configure:2787: checking what to pass nl_langinfo to obtain the codeset" >&5
if eval "test \"`echo '$''{'ac_cv_nl_langinfo_codeset'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_nl_langinfo_codeset="not found"
for a in CODESET _NL_CTYPE_CODESET_NAME; do
cat > conftest.$ac_ext <<EOF
#line 2792 "configure"
#line 2794 "configure"
#include "confdefs.h"
#include <langinfo.h>
int main() {
nl_langinfo(CODESET);
nl_langinfo($a);
; return 0; }
EOF
if { (eval echo configure:2799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2801: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_have_codeset=yes
ac_cv_nl_langinfo_codeset="$a"; break
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
ac_cv_have_codeset=no
fi
rm -f conftest*
done
fi
echo "$ac_t""$ac_cv_have_codeset" 1>&6
if test x$ac_cv_have_codeset = xyes
echo "$ac_t""$ac_cv_nl_langinfo_codeset" 1>&6
if test x$ac_cv_nl_langinfo_codeset != x"not found"
then
U_HAVE_CODESET=1
U_HAVE_NL_LANGINFO_CODESET=1
U_NL_LANGINFO_CODESET=$ac_cv_nl_langinfo_codeset
fi
fi
echo $ac_n "checking for tzset""... $ac_c" 1>&6
echo "configure:2819: checking for tzset" >&5
echo "configure:2822: checking for tzset" >&5
if eval "test \"`echo '$''{'ac_cv_func_tzset'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2824 "configure"
#line 2827 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char tzset(); below. */
@ -2843,7 +2846,7 @@ tzset();
; return 0; }
EOF
if { (eval echo configure:2847: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2850: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_tzset=yes"
else
@ -2867,12 +2870,12 @@ then
U_TZSET=tzset
else
echo $ac_n "checking for _tzset""... $ac_c" 1>&6
echo "configure:2871: checking for _tzset" >&5
echo "configure:2874: checking for _tzset" >&5
if eval "test \"`echo '$''{'ac_cv_func__tzset'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2876 "configure"
#line 2879 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char _tzset(); below. */
@ -2895,7 +2898,7 @@ _tzset();
; return 0; }
EOF
if { (eval echo configure:2899: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2902: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func__tzset=yes"
else
@ -2921,12 +2924,12 @@ fi
fi
echo $ac_n "checking for tzname""... $ac_c" 1>&6
echo "configure:2925: checking for tzname" >&5
echo "configure:2928: checking for tzname" >&5
if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2930 "configure"
#line 2933 "configure"
#include "confdefs.h"
#ifndef __USE_POSIX
#define __USE_POSIX
@ -2939,7 +2942,7 @@ int main() {
atoi(*tzname);
; return 0; }
EOF
if { (eval echo configure:2943: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2946: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_var_tzname=yes
else
@ -2956,12 +2959,12 @@ if test $ac_cv_var_tzname = yes; then
U_TZNAME=tzname
else
echo $ac_n "checking for _tzname""... $ac_c" 1>&6
echo "configure:2960: checking for _tzname" >&5
echo "configure:2963: checking for _tzname" >&5
if eval "test \"`echo '$''{'ac_cv_var__tzname'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2965 "configure"
#line 2968 "configure"
#include "confdefs.h"
#include <time.h>
extern char *_tzname[];
@ -2970,7 +2973,7 @@ int main() {
atoi(*_tzname);
; return 0; }
EOF
if { (eval echo configure:2974: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_var__tzname=yes
else
@ -2989,12 +2992,12 @@ echo "$ac_t""$ac_cv_var__tzname" 1>&6
fi
echo $ac_n "checking for timezone""... $ac_c" 1>&6
echo "configure:2993: checking for timezone" >&5
echo "configure:2996: checking for timezone" >&5
if eval "test \"`echo '$''{'ac_cv_var_timezone'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2998 "configure"
#line 3001 "configure"
#include "confdefs.h"
#ifndef __USE_POSIX
#define __USE_POSIX
@ -3008,7 +3011,7 @@ int main() {
timezone = 1;
; return 0; }
EOF
if { (eval echo configure:3012: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3015: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_var_timezone=yes
else
@ -3025,12 +3028,12 @@ if test $ac_cv_var_timezone = yes; then
U_TIMEZONE=timezone
else
echo $ac_n "checking for __timezone""... $ac_c" 1>&6
echo "configure:3029: checking for __timezone" >&5
echo "configure:3032: checking for __timezone" >&5
if eval "test \"`echo '$''{'ac_cv_var___timezone'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3034 "configure"
#line 3037 "configure"
#include "confdefs.h"
#include <time.h>
@ -3038,7 +3041,7 @@ int main() {
__timezone = 1;
; return 0; }
EOF
if { (eval echo configure:3042: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3045: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_var___timezone=yes
else
@ -3055,12 +3058,12 @@ echo "$ac_t""$ac_cv_var___timezone" 1>&6
U_TIMEZONE=__timezone
else
echo $ac_n "checking for _timezone""... $ac_c" 1>&6
echo "configure:3059: checking for _timezone" >&5
echo "configure:3062: checking for _timezone" >&5
if eval "test \"`echo '$''{'ac_cv_var__timezone'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3064 "configure"
#line 3067 "configure"
#include "confdefs.h"
#include <time.h>
@ -3068,7 +3071,7 @@ int main() {
_timezone = 1;
; return 0; }
EOF
if { (eval echo configure:3072: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3075: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_var__timezone=yes
else
@ -3090,7 +3093,7 @@ fi
ac_default_sizeof_wchar_t=4
echo $ac_n "checking size of wchar_t""... $ac_c" 1>&6
echo "configure:3094: checking size of wchar_t" >&5
echo "configure:3097: checking size of wchar_t" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_wchar_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -3098,7 +3101,7 @@ else
ac_cv_sizeof_wchar_t=$ac_default_sizeof_wchar_t
else
cat > conftest.$ac_ext <<EOF
#line 3102 "configure"
#line 3105 "configure"
#include "confdefs.h"
#if STDC_HEADERS
#include <stddef.h>
@ -3115,7 +3118,7 @@ main()
exit(0);
}
EOF
if { (eval echo configure:3119: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:3122: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_wchar_t=`cat conftestval`
else
@ -3138,12 +3141,12 @@ U_SIZEOF_WCHAR_T=$ac_cv_sizeof_wchar_t
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
echo "configure:3142: checking for ANSI C header files" >&5
echo "configure:3145: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3147 "configure"
#line 3150 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@ -3151,7 +3154,7 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:3155: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:3158: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@ -3168,7 +3171,7 @@ rm -f conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
#line 3172 "configure"
#line 3175 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@ -3186,7 +3189,7 @@ fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
#line 3190 "configure"
#line 3193 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@ -3207,7 +3210,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
#line 3211 "configure"
#line 3214 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@ -3218,7 +3221,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
if { (eval echo configure:3222: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:3225: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@ -3242,12 +3245,12 @@ EOF
fi
echo $ac_n "checking for int8_t""... $ac_c" 1>&6
echo "configure:3246: checking for int8_t" >&5
echo "configure:3249: checking for int8_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_int8_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3251 "configure"
#line 3254 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@ -3275,12 +3278,12 @@ EOF
fi
echo $ac_n "checking for uint8_t""... $ac_c" 1>&6
echo "configure:3279: checking for uint8_t" >&5
echo "configure:3282: checking for uint8_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_uint8_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3284 "configure"
#line 3287 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@ -3308,12 +3311,12 @@ EOF
fi
echo $ac_n "checking for int16_t""... $ac_c" 1>&6
echo "configure:3312: checking for int16_t" >&5
echo "configure:3315: checking for int16_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_int16_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3317 "configure"
#line 3320 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@ -3341,12 +3344,12 @@ EOF
fi
echo $ac_n "checking for uint16_t""... $ac_c" 1>&6
echo "configure:3345: checking for uint16_t" >&5
echo "configure:3348: checking for uint16_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_uint16_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3350 "configure"
#line 3353 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@ -3374,12 +3377,12 @@ EOF
fi
echo $ac_n "checking for int32_t""... $ac_c" 1>&6
echo "configure:3378: checking for int32_t" >&5
echo "configure:3381: checking for int32_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_int32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3383 "configure"
#line 3386 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@ -3407,12 +3410,12 @@ EOF
fi
echo $ac_n "checking for uint32_t""... $ac_c" 1>&6
echo "configure:3411: checking for uint32_t" >&5
echo "configure:3414: checking for uint32_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_uint32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3416 "configure"
#line 3419 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@ -3440,12 +3443,12 @@ EOF
fi
echo $ac_n "checking for bool_t""... $ac_c" 1>&6
echo "configure:3444: checking for bool_t" >&5
echo "configure:3447: checking for bool_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_bool_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3449 "configure"
#line 3452 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@ -3918,7 +3921,8 @@ s%@U_IS_BIG_ENDIAN@%$U_IS_BIG_ENDIAN%g
s%@U_HAVE_WCHAR_H@%$U_HAVE_WCHAR_H%g
s%@U_HAVE_WCSCPY@%$U_HAVE_WCSCPY%g
s%@U_HAVE_NL_LANGINFO@%$U_HAVE_NL_LANGINFO%g
s%@U_HAVE_CODESET@%$U_HAVE_CODESET%g
s%@U_HAVE_NL_LANGINFO_CODESET@%$U_HAVE_NL_LANGINFO_CODESET%g
s%@U_NL_LANGINFO_CODESET@%$U_NL_LANGINFO_CODESET%g
s%@U_TZSET@%$U_TZSET%g
s%@U_TZNAME@%$U_TZNAME%g
s%@U_TIMEZONE@%$U_TIMEZONE%g

View File

@ -323,18 +323,24 @@ AC_SUBST(U_HAVE_WCHAR_H)
AC_SUBST(U_HAVE_WCSCPY)
dnl Do various POSIX related checks
U_NL_LANGINFO_CODESET=0
AC_CHECK_FUNC(nl_langinfo,[U_HAVE_NL_LANGINFO=1],[U_HAVE_NL_LANGINFO=0])
AC_SUBST(U_HAVE_NL_LANGINFO)
U_HAVE_CODESET=0
if test $U_HAVE_NL_LANGINFO -eq 1; then
AC_CACHE_CHECK([if nl_langinfo(CODESET) works],ac_cv_have_codeset,
[AC_TRY_LINK([#include <langinfo.h>],[nl_langinfo(CODESET);],[ac_cv_have_codeset=yes],[ac_cv_have_codeset=no])])
if test x$ac_cv_have_codeset = xyes
AC_CACHE_CHECK([what to pass nl_langinfo to obtain the codeset],
ac_cv_nl_langinfo_codeset,
[ac_cv_nl_langinfo_codeset="not found"
for a in CODESET _NL_CTYPE_CODESET_NAME; do
AC_TRY_LINK([#include <langinfo.h>],[nl_langinfo($a);],[ac_cv_nl_langinfo_codeset="$a"; break])]
done)
if test x$ac_cv_nl_langinfo_codeset != x"not found"
then
U_HAVE_CODESET=1
U_HAVE_NL_LANGINFO_CODESET=1
U_NL_LANGINFO_CODESET=$ac_cv_nl_langinfo_codeset
fi
fi
AC_SUBST(U_HAVE_CODESET)
AC_SUBST(U_HAVE_NL_LANGINFO_CODESET)
AC_SUBST(U_NL_LANGINFO_CODESET)
AC_CHECK_FUNC(tzset)
if test x$ac_cv_func_tzset = xyes
then