prepare NEWS.stable
[gnulib.git] / m4 / ttyname_r.m4
index ad76070..5d26bc9 100644 (file)
@@ -1,5 +1,5 @@
-# ttyname_r.m4 serial 6
-dnl Copyright (C) 2010 Free Software Foundation, Inc.
+# ttyname_r.m4 serial 7
+dnl Copyright (C) 2010-2011 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.
 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.
@@ -43,6 +43,8 @@ AC_DEFUN([gl_FUNC_TTYNAME_R],
       dnl On Solaris 10, both ttyname_r functions (the one with the non-POSIX
       dnl declaration and the one with the POSIX declaration) refuse to do
       dnl anything when the output buffer is less than 128 bytes large.
       dnl On Solaris 10, both ttyname_r functions (the one with the non-POSIX
       dnl declaration and the one with the POSIX declaration) refuse to do
       dnl anything when the output buffer is less than 128 bytes large.
+      dnl On OSF/1 5.1, ttyname_r ignores the buffer size and assumes the
+      dnl buffer is large enough.
       AC_REQUIRE([AC_CANONICAL_HOST])
       AC_CACHE_CHECK([whether ttyname_r works with small buffers],
         [gl_cv_func_ttyname_r_works],
       AC_REQUIRE([AC_CANONICAL_HOST])
       AC_CACHE_CHECK([whether ttyname_r works with small buffers],
         [gl_cv_func_ttyname_r_works],
@@ -53,6 +55,8 @@ changequote(,)dnl
           case "$host_os" in
                       # Guess no on Solaris.
             solaris*) gl_cv_func_ttyname_r_works="guessing no" ;;
           case "$host_os" in
                       # Guess no on Solaris.
             solaris*) gl_cv_func_ttyname_r_works="guessing no" ;;
+                      # Guess no on OSF/1.
+            osf*)     gl_cv_func_ttyname_r_works="guessing no" ;;
                       # Guess yes otherwise.
             *)        gl_cv_func_ttyname_r_works="guessing yes" ;;
           esac
                       # Guess yes otherwise.
             *)        gl_cv_func_ttyname_r_works="guessing yes" ;;
           esac
@@ -70,13 +74,17 @@ main (void)
 
   fd = open ("/dev/tty", O_RDONLY);
   if (fd < 0)
 
   fd = open ("/dev/tty", O_RDONLY);
   if (fd < 0)
-    result |= 1;
+    result |= 16;
   else if (ttyname_r (fd, buf, sizeof (buf)) != 0)
   else if (ttyname_r (fd, buf, sizeof (buf)) != 0)
-    result |= 2;
+    result |= 17;
+  else if (ttyname_r (fd, buf, 1) == 0)
+    result |= 18;
   return result;
 }]])],
             [gl_cv_func_ttyname_r_works=yes],
   return result;
 }]])],
             [gl_cv_func_ttyname_r_works=yes],
-            [:],
+            [case $? in
+               17 | 18) gl_cv_func_ttyname_r_works=no ;;
+             esac],
             [:])
         ])
       case "$gl_cv_func_ttyname_r_works" in
             [:])
         ])
       case "$gl_cv_func_ttyname_r_works" in