diff options
author | Bruno Haible <bruno@clisp.org> | 2009-11-23 01:46:00 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2009-11-23 01:48:36 +0100 |
commit | 3f0d472e052865baf722ea457e35dd067b94a477 (patch) | |
tree | 1a6f787abe701f0b87c23d2291012b743268c419 /m4 | |
parent | 15b8a93426dff14b43cc5e1dc340a869a0096f02 (diff) | |
download | gnulib-3f0d472e052865baf722ea457e35dd067b94a477.tar.gz |
New module 'duplocale'.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/duplocale.m4 | 56 | ||||
-rw-r--r-- | m4/locale_h.m4 | 44 |
2 files changed, 91 insertions, 9 deletions
diff --git a/m4/duplocale.m4 b/m4/duplocale.m4 new file mode 100644 index 0000000000..7e0a0714ca --- /dev/null +++ b/m4/duplocale.m4 @@ -0,0 +1,56 @@ +# duplocale.m4 serial 1 +dnl Copyright (C) 2009 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_DUPLOCALE], +[ + AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_FUNCS_ONCE([duplocale]) + if test $ac_cv_func_duplocale = yes; then + dnl Check against glibc bug where duplocale crashes. + dnl See <http://sourceware.org/bugzilla/show_bug.cgi?id=10969>. + AC_REQUIRE([gl_LOCALE_H]) + AC_CACHE_CHECK([whether duplocale(LC_GLOBAL_LOCALE) works], + [gl_cv_func_duplocale_works], + [AC_TRY_RUN([ +#include <locale.h> +#if HAVE_XLOCALE_H +# include <xlocale.h> +#endif +int main () +{ + (void) duplocale (LC_GLOBAL_LOCALE); + return 0; +}], [gl_cv_func_duplocale_works=yes], [gl_cv_func_duplocale_works=no], + [dnl Guess it works except on glibc < 2.12. + AC_EGREP_CPP([Unlucky GNU user], [ +#include <features.h> +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 12) + Unlucky GNU user + #endif +#endif + ], + [gl_cv_func_duplocale_works="guessing no"], + [gl_cv_func_duplocale_works="guessing yes"]) + ]) + ]) + case "$gl_cv_func_duplocale_works" in + *no) REPLACE_DUPLOCALE=1 ;; + esac + fi + if test $REPLACE_DUPLOCALE = 1; then + gl_REPLACE_LOCALE_H + AC_LIBOBJ([duplocale]) + gl_PREREQ_DUPLOCALE + fi +]) + +# Prerequisites of lib/duplocale.c. +AC_DEFUN([gl_PREREQ_DUPLOCALE], +[ + : +]) diff --git a/m4/locale_h.m4 b/m4/locale_h.m4 index 913a2009bc..35b8b322fb 100644 --- a/m4/locale_h.m4 +++ b/m4/locale_h.m4 @@ -1,4 +1,4 @@ -# locale_h.m4 serial 4 +# locale_h.m4 serial 5 dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,6 +6,10 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_LOCALE_H], [ + dnl Use AC_REQUIRE here, so that the default behavior below is expanded + dnl once only, before all statements that occur in other macros. + AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) + dnl Persuade glibc <locale.h> to define locale_t. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) @@ -44,13 +48,35 @@ locale_t x;], [], fi AC_SUBST([HAVE_XLOCALE_H]) - if test -z "$STDDEF_H" \ - && test $gl_cv_header_locale_h_posix2001 = yes \ - && test $gl_cv_header_locale_h_needs_xlocale_h = no; then - LOCALE_H= - else - gl_CHECK_NEXT_HEADERS([locale.h]) - LOCALE_H=locale.h + dnl Execute this unconditionally, because LOCALE_H may be set by other + dnl modules, after this code is executed. + gl_CHECK_NEXT_HEADERS([locale.h]) + + if test -n "$STDDEF_H" \ + || test $gl_cv_header_locale_h_posix2001 = no \ + || test $gl_cv_header_locale_h_needs_xlocale_h = yes; then + gl_REPLACE_LOCALE_H fi - AC_SUBST([LOCALE_H]) +]) + +dnl Unconditionally enables the replacement of <locale.h>. +AC_DEFUN([gl_REPLACE_LOCALE_H], +[ + AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) + LOCALE_H=locale.h +]) + +AC_DEFUN([gl_LOCALE_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) + GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 +]) + +AC_DEFUN([gl_LOCALE_H_DEFAULTS], +[ + GNULIB_DUPLOCALE=0; AC_SUBST([GNULIB_DUPLOCALE]) + dnl Assume proper GNU behavior unless another module says otherwise. + REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE]) + LOCALE_H=''; AC_SUBST([LOCALE_H]) ]) |