annotate m4/locale_h.m4 @ 16717:474c0712e7aa

locale: Provide a working 'struct lconv'. * lib/locale.in.h (lconv): Override if REPLACE_STRUCT_LCONV is 1. * m4/locale_h.m4 (gl_LOCALE_H): Set REPLACE_STRUCT_LCONV to 1 if 'struct lconv' does not even contain decimal_point. (gl_LOCALE_H_DEFAULTS): Initialize REPLACE_STRUCT_LCONV. * modules/locale (Makefile.am): Substitute REPLACE_STRUCT_LCONV. * tests/test-locale.c (main): Check that 'struct lconv' is complete. * doc/posix-headers/locale.texi: Mention the problems with 'struct lconv'. Reported by Gianluigi Tiesi <sherpya@netfarm.it>.
author Bruno Haible <bruno@clisp.org>
date Sun, 25 Mar 2012 13:22:41 +0200
parents 8250f2777afc
children e4aad6f843ed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16717
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
1 # locale_h.m4 serial 15
16201
8250f2777afc maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents: 14685
diff changeset
2 dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
8660
f682656899d3 New module 'locale'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
f682656899d3 New module 'locale'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
f682656899d3 New module 'locale'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
f682656899d3 New module 'locale'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
f682656899d3 New module 'locale'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 AC_DEFUN([gl_LOCALE_H],
f682656899d3 New module 'locale'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 [
12342
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
9 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
10 dnl once only, before all statements that occur in other macros.
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
11 AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
12
16717
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
13 dnl Persuade glibc <locale.h> to define locale_t and the int_p_*, int_n_*
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
14 dnl members of 'struct lconv'.
12340
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
15 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
11832
ff3dd373542b stddef: fix NetBSD 5.0 NULL bug, rather than working around it
Eric Blake <ebb9@byu.net>
parents: 8998
diff changeset
16
ff3dd373542b stddef: fix NetBSD 5.0 NULL bug, rather than working around it
Eric Blake <ebb9@byu.net>
parents: 8998
diff changeset
17 dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
ff3dd373542b stddef: fix NetBSD 5.0 NULL bug, rather than working around it
Eric Blake <ebb9@byu.net>
parents: 8998
diff changeset
18 AC_REQUIRE([gl_STDDEF_H])
ff3dd373542b stddef: fix NetBSD 5.0 NULL bug, rather than working around it
Eric Blake <ebb9@byu.net>
parents: 8998
diff changeset
19
12340
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
20 AC_CACHE_CHECK([whether locale.h conforms to POSIX:2001],
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
21 [gl_cv_header_locale_h_posix2001],
13577
d53740f6f336 Modernize AC_TRY_COMPILE invocations.
Bruno Haible <bruno@clisp.org>
parents: 13071
diff changeset
22 [AC_COMPILE_IFELSE(
d53740f6f336 Modernize AC_TRY_COMPILE invocations.
Bruno Haible <bruno@clisp.org>
parents: 13071
diff changeset
23 [AC_LANG_PROGRAM(
d53740f6f336 Modernize AC_TRY_COMPILE invocations.
Bruno Haible <bruno@clisp.org>
parents: 13071
diff changeset
24 [[#include <locale.h>
16717
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
25 int x = LC_MESSAGES;
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
26 int y = sizeof (((struct lconv *) 0)->decimal_point);]],
13577
d53740f6f336 Modernize AC_TRY_COMPILE invocations.
Bruno Haible <bruno@clisp.org>
parents: 13071
diff changeset
27 [[]])],
12340
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
28 [gl_cv_header_locale_h_posix2001=yes],
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
29 [gl_cv_header_locale_h_posix2001=no])])
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
30
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
31 dnl Check for <xlocale.h>.
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
32 AC_CHECK_HEADERS_ONCE([xlocale.h])
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
33 if test $ac_cv_header_xlocale_h = yes; then
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
34 HAVE_XLOCALE_H=1
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
35 dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
36 dnl e.g. on MacOS X 10.5. If <locale.h> does not define locale_t by
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
37 dnl itself, we assume that <xlocale.h> will do so.
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
38 AC_CACHE_CHECK([whether locale.h defines locale_t],
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
39 [gl_cv_header_locale_has_locale_t],
13577
d53740f6f336 Modernize AC_TRY_COMPILE invocations.
Bruno Haible <bruno@clisp.org>
parents: 13071
diff changeset
40 [AC_COMPILE_IFELSE(
d53740f6f336 Modernize AC_TRY_COMPILE invocations.
Bruno Haible <bruno@clisp.org>
parents: 13071
diff changeset
41 [AC_LANG_PROGRAM(
d53740f6f336 Modernize AC_TRY_COMPILE invocations.
Bruno Haible <bruno@clisp.org>
parents: 13071
diff changeset
42 [[#include <locale.h>
d53740f6f336 Modernize AC_TRY_COMPILE invocations.
Bruno Haible <bruno@clisp.org>
parents: 13071
diff changeset
43 locale_t x;]],
d53740f6f336 Modernize AC_TRY_COMPILE invocations.
Bruno Haible <bruno@clisp.org>
parents: 13071
diff changeset
44 [[]])],
12340
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
45 [gl_cv_header_locale_has_locale_t=yes],
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
46 [gl_cv_header_locale_has_locale_t=no])
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
47 ])
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
48 if test $gl_cv_header_locale_has_locale_t = yes; then
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
49 gl_cv_header_locale_h_needs_xlocale_h=no
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
50 else
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
51 gl_cv_header_locale_h_needs_xlocale_h=yes
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
52 fi
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
53 else
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
54 HAVE_XLOCALE_H=0
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
55 gl_cv_header_locale_h_needs_xlocale_h=no
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
56 fi
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
57 AC_SUBST([HAVE_XLOCALE_H])
2da64958ab60 locale: Make locale_t available when possible.
Bruno Haible <bruno@clisp.org>
parents: 11832
diff changeset
58
16717
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
59 dnl Check whether 'struct lconv' is well-defined.
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
60 dnl Bionic libc's 'struct lconv' is just a dummy.
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
61 AC_CACHE_CHECK([whether struct lconv is properly defined],
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
62 [gl_cv_sys_struct_lconv_ok],
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
63 [AC_COMPILE_IFELSE(
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
64 [AC_LANG_PROGRAM(
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
65 [[#include <locale.h>
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
66 struct lconv l;
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
67 int x = sizeof (l.decimal_point);]],
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
68 [[]])],
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
69 [gl_cv_sys_struct_lconv_ok=yes],
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
70 [gl_cv_sys_struct_lconv_ok=no])
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
71 ])
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
72 if test $gl_cv_sys_struct_lconv_ok = no; then
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
73 REPLACE_STRUCT_LCONV=1
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
74 fi
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
75
12547
6d50d2a81c7d Further updates, following today's commits.
Bruno Haible <bruno@clisp.org>
parents: 12536
diff changeset
76 dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK.
14186
cd4635d4dbe6 assume <ctype.h>, ..., <time.h> exist
Paul Eggert <eggert@cs.ucla.edu>
parents: 14079
diff changeset
77 gl_NEXT_HEADERS([locale.h])
12342
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
78
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12559
diff changeset
79 dnl Check for declarations of anything we want to poison if the
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12559
diff changeset
80 dnl corresponding gnulib module is not in use.
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12559
diff changeset
81 gl_WARN_ON_USE_PREPARE([[#include <locale.h>
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12559
diff changeset
82 /* Some systems provide declarations in a non-standard header. */
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12559
diff changeset
83 #if HAVE_XLOCALE_H
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12559
diff changeset
84 # include <xlocale.h>
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12559
diff changeset
85 #endif
14330
960b09d2f33f New module 'setlocale'.
Bruno Haible <bruno@clisp.org>
parents: 14186
diff changeset
86 ]],
960b09d2f33f New module 'setlocale'.
Bruno Haible <bruno@clisp.org>
parents: 14186
diff changeset
87 [setlocale duplocale])
12342
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
88 ])
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
89
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
90 AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
91 [
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
92 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
93 AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
13066
fc8c984b0733 Factorize common .m4 code.
Bruno Haible <bruno@clisp.org>
parents: 12959
diff changeset
94 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
12959
55bb113c21f1 Tests of module 'locale' in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12935
diff changeset
95 dnl Define it also as a C macro, for the benefit of the unit tests.
13071
b2385e7b332e Distinguish two kinds of module indicators.
Bruno Haible <bruno@clisp.org>
parents: 13066
diff changeset
96 gl_MODULE_INDICATOR_FOR_TESTS([$1])
12342
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
97 ])
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
98
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
99 AC_DEFUN([gl_LOCALE_H_DEFAULTS],
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
100 [
14330
960b09d2f33f New module 'setlocale'.
Bruno Haible <bruno@clisp.org>
parents: 14186
diff changeset
101 GNULIB_SETLOCALE=0; AC_SUBST([GNULIB_SETLOCALE])
12342
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
102 GNULIB_DUPLOCALE=0; AC_SUBST([GNULIB_DUPLOCALE])
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
103 dnl Assume proper GNU behavior unless another module says otherwise.
16717
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
104 HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE])
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
105 REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE])
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
106 REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE])
474c0712e7aa locale: Provide a working 'struct lconv'.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
107 REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV])
12342
f214e6acb33b New module 'duplocale'.
Bruno Haible <bruno@clisp.org>
parents: 12340
diff changeset
108 ])