rktio: detect and use xlocale
This commit is contained in:
parent
1091536361
commit
7411b7ffa7
56
racket/src/rktio/configure
vendored
56
racket/src/rktio/configure
vendored
|
@ -4188,6 +4188,62 @@ $as_echo "#define HAVE_DIRENT_NAMLEN 1" >>confdefs.h
|
|||
fi
|
||||
|
||||
|
||||
msg="for xlocale.h"
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $msg" >&5
|
||||
$as_echo_n "checking $msg... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
# include <xlocale.h>
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
|
||||
$as_echo "#define RKTIO_USE_XLOCALE_HEADER 1" >>confdefs.h
|
||||
|
||||
xlocalehon=yes
|
||||
else
|
||||
xlocalehon=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xlocalehon" >&5
|
||||
$as_echo "$xlocalehon" >&6; }
|
||||
|
||||
SAVE_CFLAGS="$CFLAGS"
|
||||
if test "${xlocalehon}" = "yes" ; then
|
||||
CFLAGS="$CFLAGS -DRKTIO_USE_XLOCALE_HEADER"
|
||||
fi
|
||||
msg="for xlocale functions"
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $msg" >&5
|
||||
$as_echo_n "checking $msg... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#ifdef RKTIO_USE_XLOCALE_HEADER
|
||||
# include <xlocale.h>
|
||||
#endif
|
||||
#include <locale.h>
|
||||
int main() {
|
||||
locale_t l = newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK, "C", NULL);
|
||||
freelocale(l);
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
|
||||
$as_echo "#define RKTIO_USE_XLOCALE 1" >>confdefs.h
|
||||
|
||||
xlocaleon=yes
|
||||
else
|
||||
xlocaleon=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xlocaleon" >&5
|
||||
$as_echo "$xlocaleon" >&6; }
|
||||
CFLAGS="$SAVE_CFLAGS"
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for getaddrinfo" >&5
|
||||
$as_echo_n "checking for getaddrinfo... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
|
|
|
@ -158,6 +158,38 @@ AC_CHECK_MEMBER([struct dirent.d_namlen],
|
|||
[AC_DEFINE(HAVE_DIRENT_NAMLEN, 1, [struct dirent has field namlen])],,
|
||||
[#include <dirent.h>])
|
||||
|
||||
[ msg="for xlocale.h" ]
|
||||
AC_MSG_CHECKING($msg)
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||
# include <xlocale.h>
|
||||
int main() {
|
||||
return 0;
|
||||
}])],
|
||||
AC_DEFINE(RKTIO_USE_XLOCALE_HEADER,1,[Use xlocale.h])
|
||||
xlocalehon=yes, xlocalehon=no)
|
||||
AC_MSG_RESULT($xlocalehon)
|
||||
|
||||
SAVE_CFLAGS="$CFLAGS"
|
||||
if test "${xlocalehon}" = "yes" ; then
|
||||
CFLAGS="$CFLAGS -DRKTIO_USE_XLOCALE_HEADER"
|
||||
fi
|
||||
[ msg="for xlocale functions" ]
|
||||
AC_MSG_CHECKING($msg)
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||
#ifdef RKTIO_USE_XLOCALE_HEADER
|
||||
# include <xlocale.h>
|
||||
#endif
|
||||
#include <locale.h>
|
||||
int main() {
|
||||
locale_t l = newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK, "C", NULL);
|
||||
freelocale(l);
|
||||
return 0;
|
||||
}])],
|
||||
AC_DEFINE(RKTIO_USE_XLOCALE,1,[Use xlocale])
|
||||
xlocaleon=yes, xlocaleon=no)
|
||||
AC_MSG_RESULT($xlocaleon)
|
||||
CFLAGS="$SAVE_CFLAGS"
|
||||
|
||||
AC_MSG_CHECKING([for getaddrinfo])
|
||||
AC_TRY_LINK([#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
|
|
@ -65,3 +65,6 @@ typedef unsigned long long rktio_uint64_t;
|
|||
#undef HAVE_DIRENT_NAMLEN
|
||||
#undef HAVE_DIRENT_NAMELEN
|
||||
|
||||
/* In case xlocale is not available: */
|
||||
#undef RKTIO_USE_XLOCALE
|
||||
#undef RKTIO_USE_XLOCALE_HEADER
|
||||
|
|
|
@ -595,14 +595,12 @@ char *rktio_locale_recase(rktio_t *rktio,
|
|||
wchar_t *wc, *ws, wcbuf[RKTIO_WC_BUF_SIZE], cwc;
|
||||
const char *s;
|
||||
unsigned int j;
|
||||
# ifdef RKTIO_USE_XLOCALE
|
||||
# define mz_mbsnrtowcs(t, f, fl, tl, s) mbsrtowcs_l(t, f, tl, s, rktio->locale)
|
||||
# define mz_wcsnrtombs(t, f, fl, tl, s) wcsrtombs_l(t, f, tl, s, rktio->locale)
|
||||
# else
|
||||
/* The "n" versions are apparently not too standard: */
|
||||
# define mz_mbsnrtowcs(t, f, fl, tl, s) mbsrtowcs(t, f, tl, s)
|
||||
# define mz_wcsnrtombs(t, f, fl, tl, s) wcsrtombs(t, f, tl, s)
|
||||
# if defined(RKTIO_USE_XLOCALE)
|
||||
locale_t old_l = uselocale(rktio->locale);
|
||||
# endif
|
||||
/* The "n" versions are apparently not too standard: */
|
||||
# define mz_mbsnrtowcs(t, f, fl, tl, s) mbsrtowcs(t, f, tl, s)
|
||||
# define mz_wcsnrtombs(t, f, fl, tl, s) wcsrtombs(t, f, tl, s)
|
||||
|
||||
/* ----- to wide char ---- */
|
||||
|
||||
|
@ -670,6 +668,10 @@ char *rktio_locale_recase(rktio_t *rktio,
|
|||
|
||||
if (wc != wcbuf) free(wc);
|
||||
|
||||
# if defined(RKTIO_USE_XLOCALE)
|
||||
(void)uselocale(old_l);
|
||||
# endif
|
||||
|
||||
return out;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
# include <pthread.h>
|
||||
#endif
|
||||
#ifdef RKTIO_USE_XLOCALE
|
||||
# include <xlocale.h>
|
||||
# ifdef RKTIO_USE_XLOCALE_HEADER
|
||||
# include <xlocale.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(RKTIO_SYSTEM_UNIX) && !defined(RKTIO_STATIC_FDSET_SIZE)
|
||||
|
|
Loading…
Reference in New Issue
Block a user