From: Eric Blake Date: Fri, 31 Dec 2010 18:42:21 +0000 (-0700) Subject: nl_langinfo: fix YESEXPR on Irix 6.5 X-Git-Tag: v0.1~3420 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=c6fb743caa960cd140819012a34086a62e3571b2;p=gnulib.git nl_langinfo: fix YESEXPR on Irix 6.5 * m4/nl_langinfo.m4 (gl_FUNC_NL_LANGINFO): Test for Irix bug. * lib/nl_langinfo.c (rpl_nl_langinfo): Work around it. * doc/posix-functions/nl_langinfo.texi (nl_langinfo): Document it. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index 452045a4d..3cb5bbee2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-12-31 Eric Blake + + nl_langinfo: fix YESEXPR on Irix 6.5 + * m4/nl_langinfo.m4 (gl_FUNC_NL_LANGINFO): Test for Irix bug. + * lib/nl_langinfo.c (rpl_nl_langinfo): Work around it. + * doc/posix-functions/nl_langinfo.texi (nl_langinfo): Document + it. + 2010-12-31 Bruno Haible iconv: Document HP-UX 11 bug. diff --git a/doc/posix-functions/nl_langinfo.texi b/doc/posix-functions/nl_langinfo.texi index 710ee749e..24b641a5f 100644 --- a/doc/posix-functions/nl_langinfo.texi +++ b/doc/posix-functions/nl_langinfo.texi @@ -22,6 +22,10 @@ OpenBSD 3.8. The constants @code{T_FMT_AMPM}, @code{YESEXPR}, @code{NOEXPR} are not supported on some platforms: IRIX 5.3. +@item +The constants @code{YESEXPR} and @code{NOEXPR} do not return a valid +string on some platforms: +Irix 6.5. @end itemize Portability problems not fixed by Gnulib: diff --git a/lib/nl_langinfo.c b/lib/nl_langinfo.c index a3d0d11eb..a4bde1217 100644 --- a/lib/nl_langinfo.c +++ b/lib/nl_langinfo.c @@ -97,7 +97,7 @@ rpl_nl_langinfo (nl_item item) strings, appended in memory. */ return "\0\0\0\0\0\0\0\0\0\0"; # endif -# if GNULIB_defined_YESEXPR +# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS case YESEXPR: return "^[yY]"; case NOEXPR: diff --git a/m4/nl_langinfo.m4 b/m4/nl_langinfo.m4 index ad456a264..0b44f99fd 100644 --- a/m4/nl_langinfo.m4 +++ b/m4/nl_langinfo.m4 @@ -1,4 +1,4 @@ -# nl_langinfo.m4 serial 3 +# nl_langinfo.m4 serial 4 dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,8 +9,35 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO], AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) AC_REQUIRE([gl_LANGINFO_H]) AC_CHECK_FUNCS_ONCE([nl_langinfo]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles if test $ac_cv_func_nl_langinfo = yes; then - if test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1; then + # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken. + AC_CACHE_CHECK([whether YESEXPR works], + [gl_cv_func_nl_langinfo_yesexpr_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[#include +]], [[return !*nl_langinfo(YESEXPR); +]])], + [gl_cv_func_nl_langinfo_yesexpr_works=yes], + [gl_cv_func_nl_langinfo_yesexpr_works=no], + [ + case "$host_os" in + # Guess no on irix systems. + irix*) gl_cv_func_nl_langinfo_yesexpr_works="guessing no";; + # Guess yes elsewhere. + *) gl_cv_func_nl_langinfo_yesexpr_works="guessing yes";; + esac + ]) + ]) + case $gl_cv_func_nl_langinfo_yesexpr_works in + *yes) FUNC_NL_LANGINFO_YESEXPR_WORKS=1 ;; + *) FUNC_NL_LANGINFO_YESEXPR_WORKS=0 ;; + esac + AC_DEFINE_UNQUOTED([FUNC_NL_LANGINFO_YESEXPR_WORKS], + [$FUNC_NL_LANGINFO_YESEXPR_WORKS], + [Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string.]) + if test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1 \ + && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1; then : else REPLACE_NL_LANGINFO=1