nl_langinfo: fix YESEXPR on Irix 6.5
authorEric Blake <eblake@redhat.com>
Fri, 31 Dec 2010 18:42:21 +0000 (11:42 -0700)
committerEric Blake <eblake@redhat.com>
Fri, 31 Dec 2010 23:13:43 +0000 (16:13 -0700)
* 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 <eblake@redhat.com>
ChangeLog
doc/posix-functions/nl_langinfo.texi
lib/nl_langinfo.c
m4/nl_langinfo.m4

index 452045a..3cb5bbe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-12-31  Eric Blake  <eblake@redhat.com>
+
+       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  <bruno@clisp.org>
 
        iconv: Document HP-UX 11 bug.
index 710ee74..24b641a 100644 (file)
@@ -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:
index a3d0d11..a4bde12 100644 (file)
@@ -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:
index ad456a2..0b44f99 100644 (file)
@@ -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 <langinfo.h>
+]], [[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