[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
locale: get locale_t defined
From: |
Bruno Haible |
Subject: |
locale: get locale_t defined |
Date: |
Mon, 23 Nov 2009 01:28:33 +0100 |
User-agent: |
KMail/1.9.9 |
Hi,
According to POSIX:2008, <locale.h> should define the locale_t type. On
where the type is nowhere available, we cannot easily provide it. But
on glibc and MacOS X it is "nearly" available:
- On glibc, it is only available with -D_GNU_SOURCE.
- On MacOS X, it is only available with #include <xlocale.h>.
This patch provides a <locale.h> that allows you to forget about these
problems.
2009-11-22 Bruno Haible <address@hidden>
locale: Make locale_t available when possible.
* lib/locale.in.h: Include <xlocale.h> when it exists.
* m4/locale_h.m4 (gl_LOCALE_H): Check for <xlocale.h> and arrange to
replace <locale.h> if it does not define locale_t but <xlocale.h> 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.
*** lib/locale.in.h.orig 2009-11-22 23:29:24.000000000 +0100
--- lib/locale.in.h 2009-11-22 22:52:59.000000000 +0100
***************
*** 29,34 ****
--- 29,39 ----
/* NetBSD 5.0 mis-defines NULL. */
#include <stddef.h>
+ /* MacOS X 10.5 defines the locale_t type in <xlocale.h>. */
+ #if @HAVE_XLOCALE_H@
+ # include <xlocale.h>
+ #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
*** m4/locale_h.m4.orig 2009-11-22 23:29:24.000000000 +0100
--- m4/locale_h.m4 2009-11-22 23:29:07.000000000 +0100
***************
*** 1,4 ****
! # locale_h.m4 serial 3
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,
--- 1,4 ----
! # 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,22 ****
AC_DEFUN([gl_LOCALE_H],
[
! AC_CACHE_CHECK([whether locale.h conforms to POSIX],
! [gl_cv_header_working_locale_h],
! [AC_TRY_COMPILE([#include <locale.h>
! int x = LC_MESSAGES;], [],
! [gl_cv_header_working_locale_h=yes],
! [gl_cv_header_working_locale_h=no])])
dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
AC_REQUIRE([gl_STDDEF_H])
! if test $gl_cv_header_working_locale_h = yes && test -z "$STDDEF_H"; then
LOCALE_H=
else
gl_CHECK_NEXT_HEADERS([locale.h])
--- 6,52 ----
AC_DEFUN([gl_LOCALE_H],
[
! dnl Persuade glibc <locale.h> to define locale_t.
! AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
AC_REQUIRE([gl_STDDEF_H])
! AC_CACHE_CHECK([whether locale.h conforms to POSIX:2001],
! [gl_cv_header_locale_h_posix2001],
! [AC_TRY_COMPILE([#include <locale.h>
! int x = LC_MESSAGES;], [],
! [gl_cv_header_locale_h_posix2001=yes],
! [gl_cv_header_locale_h_posix2001=no])])
!
! dnl Check for <xlocale.h>.
! 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 <xlocale.h>,
! dnl e.g. on MacOS X 10.5. If <locale.h> does not define locale_t by
! dnl itself, we assume that <xlocale.h> will do so.
! AC_CACHE_CHECK([whether locale.h defines locale_t],
! [gl_cv_header_locale_has_locale_t],
! [AC_TRY_COMPILE([#include <locale.h>
! 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])
*** modules/locale.orig 2009-11-22 23:29:24.000000000 +0100
--- modules/locale 2009-11-22 22:54:24.000000000 +0100
***************
*** 7,12 ****
--- 7,13 ----
Depends-on:
include_next
+ extensions
stddef
configure.ac:
***************
*** 23,28 ****
--- 24,30 ----
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; \
} > address@hidden && \
mv address@hidden $@
*** doc/posix-headers/locale.texi.orig 2009-11-22 23:29:24.000000000 +0100
--- doc/posix-headers/locale.texi 2009-11-22 22:57:59.000000000 +0100
***************
*** 12,17 ****
--- 12,21 ----
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:
NetBSD 5.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- locale: get locale_t defined,
Bruno Haible <=