From: Bruno Haible Date: Sun, 22 Nov 2009 22:31:11 +0000 (+0100) Subject: locale: Make locale_t available when possible. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17d63e8427ebf2aaec12553ea3a58c582f564b90;p=pspp locale: Make locale_t available when possible. --- diff --git a/ChangeLog b/ChangeLog index 637578a559..3e7980f5c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-11-22 Bruno Haible + + locale: Make locale_t available when possible. + * lib/locale.in.h: Include when it exists. + * m4/locale_h.m4 (gl_LOCALE_H): Check for and arrange to + replace if it does not define locale_t but does. + * modules/locale (Depends-on): Add extensions. + (Makefile.am): Also substitute HAVE_XLOCALE_H. + * doc/posix-headers/locale.texi: Document the problem with locale_t. + 2009-11-22 Bruno Haible Add comments. diff --git a/doc/posix-headers/locale.texi b/doc/posix-headers/locale.texi index df0673b5a8..8f927770c0 100644 --- a/doc/posix-headers/locale.texi +++ b/doc/posix-headers/locale.texi @@ -11,6 +11,10 @@ Portability problems fixed by Gnulib: The definition of @samp{LC_MESSAGES} is missing on some platforms: mingw. +@item +The @code{locale_t} type is not defined on some platforms: +glibc 2.11, MacOS X 10.5. + @item Some platforms provide a @code{NULL} macro that cannot be used in arbitrary expressions: diff --git a/lib/locale.in.h b/lib/locale.in.h index 0557c9f170..49835c5cab 100644 --- a/lib/locale.in.h +++ b/lib/locale.in.h @@ -29,6 +29,11 @@ /* NetBSD 5.0 mis-defines NULL. */ #include +/* MacOS X 10.5 defines the locale_t type in . */ +#if @HAVE_XLOCALE_H@ +# include +#endif + /* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C. On systems that don't define it, use the same value as GNU libintl. */ #if !defined LC_MESSAGES diff --git a/m4/locale_h.m4 b/m4/locale_h.m4 index 86123670f9..913a2009bc 100644 --- a/m4/locale_h.m4 +++ b/m4/locale_h.m4 @@ -1,4 +1,4 @@ -# locale_h.m4 serial 3 +# locale_h.m4 serial 4 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,17 +6,47 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_LOCALE_H], [ - AC_CACHE_CHECK([whether locale.h conforms to POSIX], - [gl_cv_header_working_locale_h], - [AC_TRY_COMPILE([#include -int x = LC_MESSAGES;], [], - [gl_cv_header_working_locale_h=yes], - [gl_cv_header_working_locale_h=no])]) + dnl Persuade glibc to define locale_t. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) dnl If is replaced, then must also be replaced. AC_REQUIRE([gl_STDDEF_H]) - if test $gl_cv_header_working_locale_h = yes && test -z "$STDDEF_H"; then + AC_CACHE_CHECK([whether locale.h conforms to POSIX:2001], + [gl_cv_header_locale_h_posix2001], + [AC_TRY_COMPILE([#include +int x = LC_MESSAGES;], [], + [gl_cv_header_locale_h_posix2001=yes], + [gl_cv_header_locale_h_posix2001=no])]) + + dnl Check for . + AC_CHECK_HEADERS_ONCE([xlocale.h]) + if test $ac_cv_header_xlocale_h = yes; then + HAVE_XLOCALE_H=1 + dnl Check whether use of locale_t requires inclusion of , + dnl e.g. on MacOS X 10.5. If does not define locale_t by + dnl itself, we assume that will do so. + AC_CACHE_CHECK([whether locale.h defines locale_t], + [gl_cv_header_locale_has_locale_t], + [AC_TRY_COMPILE([#include +locale_t x;], [], + [gl_cv_header_locale_has_locale_t=yes], + [gl_cv_header_locale_has_locale_t=no]) + ]) + if test $gl_cv_header_locale_has_locale_t = yes; then + gl_cv_header_locale_h_needs_xlocale_h=no + else + gl_cv_header_locale_h_needs_xlocale_h=yes + fi + else + HAVE_XLOCALE_H=0 + gl_cv_header_locale_h_needs_xlocale_h=no + 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]) diff --git a/modules/locale b/modules/locale index 41f9e536e8..953237dea7 100644 --- a/modules/locale +++ b/modules/locale @@ -7,6 +7,7 @@ m4/locale_h.m4 Depends-on: include_next +extensions stddef configure.ac: @@ -23,6 +24,7 @@ locale.h: locale.in.h sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \ + -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \ < $(srcdir)/locale.in.h; \ } > $@-t && \ mv $@-t $@