[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
new module 'localeconv'
From: |
Bruno Haible |
Subject: |
new module 'localeconv' |
Date: |
Sun, 25 Mar 2012 15:21:08 +0200 |
User-agent: |
KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; ) |
And here's the localeconv() override that is necessary when 'struct lconv'
is overridden.
2012-03-25 Bruno Haible <address@hidden>
New module 'localeconv'.
* lib/locale.in.h (localeconv): New declaration.
* lib/localeconv.c: New file.
* m4/localeconv.m4: New file.
* m4/locale_h.m4 (gl_LOCALE_H_DEFAULTS): Initialize GNULIB_LOCALECONV,
REPLACE_LOCALECONV.
* modules/locale (Makefile.am): Substitute GNULIB_LOCALECONV,
REPLACE_LOCALECONV.
* modules/localeconv: New file.
* modules/nl_langinfo (Depends-on): Add localeconv.
* modules/human (Depends-on): Likewise.
* doc/posix-functions/localeconv.texi: Mention the new module.
============================== lib/localeconv.c ==============================
/* Query locale dependent information for formatting numbers.
Copyright (C) 2012 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <locale.h>
#if HAVE_STRUCT_LCONV_DECIMAL_POINT
/* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_*
members. */
struct lconv *
localeconv (void)
{
static struct lconv result;
# undef lconv
# undef localeconv
struct lconv *sys_result = localeconv ();
result.decimal_point = sys_result->decimal_point;
result.thousands_sep = sys_result->thousands_sep;
result.grouping = sys_result->grouping;
result.mon_decimal_point = sys_result->mon_decimal_point;
result.mon_thousands_sep = sys_result->mon_thousands_sep;
result.mon_grouping = sys_result->mon_grouping;
result.positive_sign = sys_result->positive_sign;
result.negative_sign = sys_result->negative_sign;
result.currency_symbol = sys_result->currency_symbol;
result.frac_digits = sys_result->frac_digits;
result.p_cs_precedes = sys_result->p_cs_precedes;
result.p_sign_posn = sys_result->p_sign_posn;
result.p_sep_by_space = sys_result->p_sep_by_space;
result.n_cs_precedes = sys_result->n_cs_precedes;
result.n_sign_posn = sys_result->n_sign_posn;
result.n_sep_by_space = sys_result->n_sep_by_space;
result.int_curr_symbol = sys_result->int_curr_symbol;
result.int_frac_digits = sys_result->int_frac_digits;
result.int_p_cs_precedes = sys_result->p_cs_precedes;
result.int_p_sign_posn = sys_result->p_sign_posn;
result.int_p_sep_by_space = sys_result->p_sep_by_space;
result.int_n_cs_precedes = sys_result->n_cs_precedes;
result.int_n_sign_posn = sys_result->n_sign_posn;
result.int_n_sep_by_space = sys_result->n_sep_by_space;
return &result;
}
#else
/* Override for platforms where 'struct lconv' is a dummy. */
# include <limits.h>
struct lconv *
localeconv (void)
{
static /*const*/ struct lconv result =
{
/* decimal_point */ ".",
/* thousands_sep */ "",
/* grouping */ "",
/* mon_decimal_point */ "",
/* mon_thousands_sep */ "",
/* mon_grouping */ "",
/* positive_sign */ "",
/* negative_sign */ "",
/* currency_symbol */ "",
/* frac_digits */ CHAR_MAX,
/* p_cs_precedes */ CHAR_MAX,
/* p_sign_posn */ CHAR_MAX,
/* p_sep_by_space */ CHAR_MAX,
/* n_cs_precedes */ CHAR_MAX,
/* n_sign_posn */ CHAR_MAX,
/* n_sep_by_space */ CHAR_MAX,
/* int_curr_symbol */ "",
/* int_frac_digits */ CHAR_MAX,
/* int_p_cs_precedes */ CHAR_MAX,
/* int_p_sign_posn */ CHAR_MAX,
/* int_p_sep_by_space */ CHAR_MAX,
/* int_n_cs_precedes */ CHAR_MAX,
/* int_n_sign_posn */ CHAR_MAX,
/* int_n_sep_by_space */ CHAR_MAX
};
return &result;
}
#endif
============================== m4/localeconv.m4 ==============================
# localeconv.m4 serial 1
dnl Copyright (C) 2012 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_LOCALECONV],
[
AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
AC_REQUIRE([gl_LOCALE_H])
if test $REPLACE_STRUCT_LCONV = 1; then
REPLACE_LOCALECONV=1
fi
])
# Prerequisites of lib/localeconv.c.
AC_DEFUN([gl_PREREQ_LOCALECONV],
[
AC_CHECK_MEMBERS([struct lconv.decimal_point], [], [],
[[#include <locale.h>]])
])
============================= modules/localeconv =============================
Description:
localeconv() function: query locale dependent information for formatting
numbers.
Files:
lib/localeconv.c
m4/localeconv.m4
Depends-on:
locale
configure.ac:
gl_FUNC_LOCALECONV
if test $REPLACE_LOCALECONV = 1; then
AC_LIBOBJ([localeconv])
gl_PREREQ_LOCALECONV
fi
gl_LOCALE_MODULE_INDICATOR([localeconv])
Makefile.am:
Include:
<locale.h>
License:
LGPLv2+
Maintainer:
Bruno Haible
==============================================================================
--- doc/posix-functions/localeconv.texi.orig Sun Mar 25 15:12:34 2012
+++ doc/posix-functions/localeconv.texi Sun Mar 25 13:59:44 2012
@@ -4,10 +4,19 @@
POSIX specification:@*
@url{http://www.opengroup.org/onlinepubs/9699919799/functions/localeconv.html}
-Gnulib module: ---
+Gnulib module: localeconv
Portability problems fixed by Gnulib:
@itemize
address@hidden
+The @code{struct lconv} type does not contain any members on some platforms:
+Android.
address@hidden
+The @code{struct lconv} type does not contain the members
address@hidden, @code{int_p_sign_posn}, @code{int_p_sep_by_space},
address@hidden, @code{int_n_sign_posn}, @code{int_n_sep_by_space}
+on some platforms:
+glibc, OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 11 2011-11, Cygwin
1.5.x, mingw, MSVC 9.
@end itemize
Portability problems not fixed by Gnulib:
--- lib/locale.in.h.orig Sun Mar 25 15:12:34 2012
+++ lib/locale.in.h Sun Mar 25 14:11:17 2012
@@ -128,6 +128,30 @@
};
#endif
+#if @GNULIB_LOCALECONV@
+# if @REPLACE_LOCALECONV@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef localeconv
+# define localeconv rpl_localeconv
+# endif
+_GL_FUNCDECL_RPL (localeconv, struct lconv *, (void));
+_GL_CXXALIAS_RPL (localeconv, struct lconv *, (void));
+# else
+_GL_CXXALIAS_SYS (localeconv, struct lconv *, (void));
+# endif
+_GL_CXXALIASWARN (localeconv);
+#elif @REPLACE_STRUCT_LCONV@
+# undef localeconv
+# define localeconv localeconv_used_without_requesting_gnulib_module_localeconv
+#elif defined GNULIB_POSIXCHECK
+# undef localeconv
+# if HAVE_RAW_DECL_LOCALECONV
+_GL_WARN_ON_USE (localeconv,
+ "localeconv returns too few information on some platforms - "
+ "use gnulib module localeconv for portability");
+# endif
+#endif
+
#if @GNULIB_SETLOCALE@
# if @REPLACE_SETLOCALE@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
--- m4/locale_h.m4.orig Sun Mar 25 15:12:34 2012
+++ m4/locale_h.m4 Sun Mar 25 14:12:26 2012
@@ -1,4 +1,4 @@
-# locale_h.m4 serial 17
+# locale_h.m4 serial 18
dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -110,10 +110,12 @@
AC_DEFUN([gl_LOCALE_H_DEFAULTS],
[
+ GNULIB_LOCALECONV=0; AC_SUBST([GNULIB_LOCALECONV])
GNULIB_SETLOCALE=0; AC_SUBST([GNULIB_SETLOCALE])
GNULIB_DUPLOCALE=0; AC_SUBST([GNULIB_DUPLOCALE])
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE])
+ REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV])
REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE])
REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE])
REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV])
--- modules/human.orig Sun Mar 25 15:12:34 2012
+++ modules/human Sun Mar 25 14:48:49 2012
@@ -11,6 +11,7 @@
argmatch
error
intprops
+localeconv
memmove
xstrtoumax
stdbool
--- modules/locale.orig Sun Mar 25 15:12:34 2012
+++ modules/locale Sun Mar 25 14:13:21 2012
@@ -29,10 +29,12 @@
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \
+ -e 's/@''GNULIB_LOCALECONV''@/$(GNULIB_LOCALECONV)/g' \
-e 's/@''GNULIB_SETLOCALE''@/$(GNULIB_SETLOCALE)/g' \
-e 's/@''GNULIB_DUPLOCALE''@/$(GNULIB_DUPLOCALE)/g' \
-e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \
-e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \
+ -e 's|@''REPLACE_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \
-e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \
-e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \
-e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|g' \
--- modules/nl_langinfo.orig Sun Mar 25 15:12:34 2012
+++ modules/nl_langinfo Sun Mar 25 14:49:44 2012
@@ -7,6 +7,7 @@
Depends-on:
langinfo
+localeconv [test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1]
configure.ac:
gl_FUNC_NL_LANGINFO