openpty: fix bug where HAVE_OPENPTY wasn't defined
authorReuben Thomas <rrt@sc3d.org>
Thu, 31 Jan 2013 21:55:55 +0000 (13:55 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 31 Jan 2013 21:56:24 +0000 (13:56 -0800)
See the thread starting at:
http://lists.gnu.org/archive/html/bug-gnulib/2013-01/msg00185.html
* m4/pty.m4 (gl_FUNC_OPENPTY): Define HAVE_OPENPTY when the
openpty function exists, not merely when we intend to replace it.

ChangeLog
m4/pty.m4

index 36408d7..c18cbad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2013-01-31  Reuben Thomas  <rrt@sc3d.org>
+
+       openpty: fix bug where HAVE_OPENPTY wasn't defined
+       See the thread starting at:
+       http://lists.gnu.org/archive/html/bug-gnulib/2013-01/msg00185.html
+       * m4/pty.m4 (gl_FUNC_OPENPTY): Define HAVE_OPENPTY when the
+       openpty function exists, not merely when we intend to replace it.
+
 2013-01-30  Paul Eggert  <eggert@cs.ucla.edu>
 
        sys_time: port to Solaris 2.6
index c6b3579..12e681b 100644 (file)
--- a/m4/pty.m4
+++ b/m4/pty.m4
@@ -122,16 +122,18 @@ AC_DEFUN([gl_FUNC_OPENPTY],
         ],
         [gl_cv_func_openpty_const=yes], [gl_cv_func_openpty_const=no])
       ])
-    if test $gl_cv_func_openpty_const != yes; then
-      REPLACE_OPENPTY=1
-      AC_DEFINE([HAVE_OPENPTY], [1],
-        [Define to 1 if the system has the 'openpty' function.])
-    fi
+  fi
+  if test $gl_cv_func_openpty_const = yes; then
+    HAVE_OPENPTY=1
   else
-    dnl The system does not have openpty.
-    HAVE_OPENPTY=0
+    dnl We need gnulib's openpty.
     dnl Prerequisites of lib/openpty.c in this case.
-    AC_CHECK_FUNCS([_getpty posix_openpt])
+    AC_CHECK_FUNCS([_getpty posix_openpt], [HAVE_OPENPTY=1], [HAVE_OPENPTY=0])
+    REPLACE_OPENPTY=$HAVE_OPENPTY
+  fi
+  if test $HAVE_OPENPTY = 1; then
+    AC_DEFINE([HAVE_OPENPTY], [1],
+      [Define to 1 if the system has the 'openpty' function.])
   fi
 ])