X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fttyname_r.m4;h=682a9d8236db2f18721bcffa15874f0da49b3b02;hb=da8054d48dc22e1c051db54049e005d51a006e69;hp=dc221ed142feb96fe7b014428acdbcfd470a3002;hpb=64865499c9cf8748356a0857a8481d74b394bd79;p=gnulib.git diff --git a/m4/ttyname_r.m4 b/m4/ttyname_r.m4 index dc221ed14..682a9d823 100644 --- a/m4/ttyname_r.m4 +++ b/m4/ttyname_r.m4 @@ -1,5 +1,5 @@ -# ttyname_r.m4 serial 4 -dnl Copyright (C) 2010 Free Software Foundation, Inc. +# ttyname_r.m4 serial 9 +dnl Copyright (C) 2010-2013 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. @@ -12,11 +12,17 @@ AC_DEFUN([gl_FUNC_TTYNAME_R], dnl ttyname_r(). AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_DECLS_ONCE([ttyname_r]) + if test $ac_cv_have_decl_ttyname_r = no; then + HAVE_DECL_TTYNAME_R=0 + fi + AC_CHECK_FUNCS([ttyname_r]) if test $ac_cv_func_ttyname_r = no; then HAVE_TTYNAME_R=0 else - dnl On MacOS X 10.4 (and Solaris 10 without gl_USE_SYSTEM_EXTENSIONS) + HAVE_TTYNAME_R=1 + dnl On Mac OS X 10.4 (and Solaris 10 without gl_USE_SYSTEM_EXTENSIONS) dnl the return type is 'char *', not 'int'. AC_CACHE_CHECK([whether ttyname_r is compatible with its POSIX signature], [gl_cv_func_ttyname_r_posix], @@ -37,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 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], @@ -47,6 +55,8 @@ changequote(,)dnl 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 @@ -58,18 +68,23 @@ changequote([,])dnl int main (void) { + int result = 0; int fd; char buf[31]; /* use any size < 128 here */ fd = open ("/dev/tty", O_RDONLY); if (fd < 0) - return 1; - if (ttyname_r (fd, buf, sizeof (buf)) != 0) - return 1; - return 0; + result |= 16; + else if (ttyname_r (fd, buf, sizeof (buf)) != 0) + result |= 17; + else if (ttyname_r (fd, buf, 1) == 0) + result |= 18; + 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 @@ -78,10 +93,6 @@ main (void) esac fi fi - if test $HAVE_TTYNAME_R = 0 || test $REPLACE_TTYNAME_R = 1; then - AC_LIBOBJ([ttyname_r]) - gl_PREREQ_TTYNAME_R - fi ]) # Prerequisites of lib/ttyname_r.c.