From 27c46a344f7a8f574c054fb31ee36120fc033495 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 11 Dec 2009 19:57:37 +0100 Subject: [PATCH] New module 'langinfo'. --- ChangeLog | 8 ++ doc/posix-headers/langinfo.texi | 15 +++- lib/langinfo.in.h | 161 ++++++++++++++++++++++++++++++++++++++++ m4/langinfo_h.m4 | 76 +++++++++++++++++++ modules/langinfo | 44 +++++++++++ 5 files changed, 300 insertions(+), 4 deletions(-) create mode 100644 lib/langinfo.in.h create mode 100644 m4/langinfo_h.m4 create mode 100644 modules/langinfo diff --git a/ChangeLog b/ChangeLog index e96ec5df4..f4ae4cddd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2009-12-11 Bruno Haible + New module 'langinfo'. + * lib/langinfo.in.h: New file. + * m4/langinfo_h.m4: New file. + * modules/langinfo: New file. + * doc/posix-headers/langinfo.texi: Mention the new module. + +2009-12-11 Bruno Haible + * lib/config.charset: Untabify. 2009-12-11 Bruno Haible diff --git a/doc/posix-headers/langinfo.texi b/doc/posix-headers/langinfo.texi index 7fac03ac0..05fa9da89 100644 --- a/doc/posix-headers/langinfo.texi +++ b/doc/posix-headers/langinfo.texi @@ -3,15 +3,22 @@ POSIX specification: @url{http://www.opengroup.org/susv3xbd/langinfo.h.html} -Gnulib module: --- +Gnulib module: langinfo Portability problems fixed by Gnulib: @itemize +@item +This header file is missing on some platforms: +mingw, BeOS. +@item +The constant @code{CODESET} is not defined on some platforms: +glibc 2.0.6, OpenBSD 3.8. +@item +The constants @code{ERA}, @code{ERA_D_FMT}, @code{ERA_D_T_FMT}, +@code{ERA_T_FMT}, @code{ALT_DIGITS} are not defined on some platforms: +OpenBSD 3.8. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This header file is missing on some platforms: -mingw, BeOS. @end itemize diff --git a/lib/langinfo.in.h b/lib/langinfo.in.h new file mode 100644 index 000000000..fc2782614 --- /dev/null +++ b/lib/langinfo.in.h @@ -0,0 +1,161 @@ +/* Substitute for and wrapper around . + Copyright (C) 2009 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 2, 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, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* + * POSIX for platforms that lack it or have an incomplete one. + * + */ + +#ifndef _GL_LANGINFO_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_LANGINFO_H@ +# @INCLUDE_NEXT@ @NEXT_LANGINFO_H@ +#endif + +#ifndef _GL_LANGINFO_H +#define _GL_LANGINFO_H + + +#if !@HAVE_LANGINFO_H@ + +/* A platform that lacks . */ + +/* Assume that it also lacks and the nl_item type. */ +typedef int nl_item; + +/* nl_langinfo items of the LC_CTYPE category */ +# define CODESET 10000 +/* nl_langinfo items of the LC_NUMERIC category */ +# define RADIXCHAR 10001 +# define THOUSEP 10002 +/* nl_langinfo items of the LC_TIME category */ +# define D_T_FMT 10003 +# define D_FMT 10004 +# define T_FMT 10005 +# define T_FMT_AMPM 10006 +# define AM_STR 10007 +# define PM_STR 10008 +# define DAY_1 10009 +# define DAY_2 (DAY_1 + 1) +# define DAY_3 (DAY_1 + 2) +# define DAY_4 (DAY_1 + 3) +# define DAY_5 (DAY_1 + 4) +# define DAY_6 (DAY_1 + 5) +# define DAY_7 (DAY_1 + 6) +# define ABDAY_1 10016 +# define ABDAY_2 (ABDAY_1 + 1) +# define ABDAY_3 (ABDAY_1 + 2) +# define ABDAY_4 (ABDAY_1 + 3) +# define ABDAY_5 (ABDAY_1 + 4) +# define ABDAY_6 (ABDAY_1 + 5) +# define ABDAY_7 (ABDAY_1 + 6) +# define MON_1 10023 +# define MON_2 (MON_1 + 1) +# define MON_3 (MON_1 + 2) +# define MON_4 (MON_1 + 3) +# define MON_5 (MON_1 + 4) +# define MON_6 (MON_1 + 5) +# define MON_7 (MON_1 + 6) +# define MON_8 (MON_1 + 7) +# define MON_9 (MON_1 + 8) +# define MON_10 (MON_1 + 9) +# define MON_11 (MON_1 + 10) +# define MON_12 (MON_1 + 11) +# define ABMON_1 10035 +# define ABMON_2 (ABMON_1 + 1) +# define ABMON_3 (ABMON_1 + 2) +# define ABMON_4 (ABMON_1 + 3) +# define ABMON_5 (ABMON_1 + 4) +# define ABMON_6 (ABMON_1 + 5) +# define ABMON_7 (ABMON_1 + 6) +# define ABMON_8 (ABMON_1 + 7) +# define ABMON_9 (ABMON_1 + 8) +# define ABMON_10 (ABMON_1 + 9) +# define ABMON_11 (ABMON_1 + 10) +# define ABMON_12 (ABMON_1 + 11) +# define ERA 10047 +# define ERA_D_FMT 10048 +# define ERA_D_T_FMT 10049 +# define ERA_T_FMT 10050 +# define ALT_DIGITS 10051 +/* nl_langinfo items of the LC_MONETARY category */ +# define CRNCYSTR 10052 +/* nl_langinfo items of the LC_MESSAGES category */ +# define YESEXPR 10053 +# define NOEXPR 10054 + +#else + +/* A platform that has . */ + +# if !@HAVE_LANGINFO_CODESET@ +# define CODESET 10000 +# define GNULIB_defined_CODESET 1 +# endif + +# if !@HAVE_LANGINFO_ERA@ +# define ERA 10047 +# define ERA_D_FMT 10048 +# define ERA_D_T_FMT 10049 +# define ERA_T_FMT 10050 +# define ALT_DIGITS 10051 +# define GNULIB_defined_ERA 1 +# endif + +#endif + + +/* Declare overridden functions. */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Return a piece of locale dependent information. + Note: The difference between nl_langinfo (CODESET) and locale_charset () + is that the latter normalizes the encoding names to GNU conventions. */ + +#if @GNULIB_NL_LANGINFO@ +# if @REPLACE_NL_LANGINFO@ +# undef nl_langinfo +# define nl_langinfo rpl_nl_langinfo +# endif +# if !@HAVE_NL_LANGINFO@ || @REPLACE_NL_LANGINFO@ +extern char *nl_langinfo (nl_item item); +# endif +#elif defined GNULIB_POSIXCHECK +# undef nl_langinfo +# define nl_langinfo(i) \ + (GL_LINK_WARNING ("nl_langinfo is not portable - " \ + "use gnulib module nl_langinfo for portability"), \ + nl_langinfo (i)) +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* _GL_LANGINFO_H */ +#endif /* _GL_LANGINFO_H */ diff --git a/m4/langinfo_h.m4 b/m4/langinfo_h.m4 new file mode 100644 index 000000000..4975734cb --- /dev/null +++ b/m4/langinfo_h.m4 @@ -0,0 +1,76 @@ +# langinfo_h.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_LANGINFO_H], +[ + AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) + + dnl Persuade glibc-2.0.6 to define CODESET. + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + gl_CHECK_NEXT_HEADERS([langinfo.h]) + + dnl Determine whether exists. It is missing on mingw and BeOS. + HAVE_LANGINFO_CODESET=0 + HAVE_LANGINFO_ERA=0 + AC_CHECK_HEADERS_ONCE([langinfo.h]) + if test $ac_cv_header_langinfo_h = yes; then + HAVE_LANGINFO_H=1 + dnl Determine what defines. CODESET and ERA etc. are missing + dnl on OpenBSD 3.8. + AC_CACHE_CHECK([whether langinfo.h defines CODESET], + [gl_cv_header_langinfo_codeset], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include +int a = CODESET; +]])], + [gl_cv_header_langinfo_codeset=yes], + [gl_cv_header_langinfo_codeset=no]) + ]) + if test $gl_cv_header_langinfo_codeset = yes; then + HAVE_LANGINFO_CODESET=1 + fi + AC_CACHE_CHECK([whether langinfo.h defines ERA], + [gl_cv_header_langinfo_era], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include +int a = ERA; +]])], + [gl_cv_header_langinfo_era=yes], + [gl_cv_header_langinfo_era=no]) + ]) + if test $gl_cv_header_langinfo_era = yes; then + HAVE_LANGINFO_ERA=1 + fi + else + HAVE_LANGINFO_H=0 + fi + AC_SUBST([HAVE_LANGINFO_H]) + AC_SUBST([HAVE_LANGINFO_CODESET]) + AC_SUBST([HAVE_LANGINFO_ERA]) + + if test $HAVE_LANGINFO_H = 1 && test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1; then + LANGINFO_H= + else + LANGINFO_H='langinfo.h' + fi + AC_SUBST([LANGINFO_H]) +]) + +AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) + GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 +]) + +AC_DEFUN([gl_LANGINFO_H_DEFAULTS], +[ + GNULIB_NL_LANGINFO=0; AC_SUBST([GNULIB_NL_LANGINFO]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_NL_LANGINFO=1; AC_SUBST([HAVE_NL_LANGINFO]) + REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO]) +]) diff --git a/modules/langinfo b/modules/langinfo new file mode 100644 index 000000000..f9b0a2f4e --- /dev/null +++ b/modules/langinfo @@ -0,0 +1,44 @@ +Description: +A GNU-like . + +Files: +lib/langinfo.in.h +m4/langinfo_h.m4 + +Depends-on: +include_next +extensions + +configure.ac: +gl_LANGINFO_H + +Makefile.am: +BUILT_SOURCES += $(LANGINFO_H) + +# We need the following in order to create an empty placeholder for +# when the system doesn't have one. +langinfo.h: langinfo.in.h + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \ + -e 's|@''GNULIB_NL_LANGINFO''@|$(GNULIB_NL_LANGINFO)|g' \ + -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \ + -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \ + -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \ + -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \ + < $(srcdir)/langinfo.in.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += langinfo.h langinfo.h-t + +Include: + + +License: +LGPL + +Maintainer: +Bruno Haible -- 2.11.0