bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

login_tty: Fix detection of declaration


From: Bruno Haible
Subject: login_tty: Fix detection of declaration
Date: Sat, 21 Jan 2023 21:04:34 +0100

One of the changes, two days ago, was wrong: The line

  gl_CHECK_FUNCS_ANDROID([login_tty], [[#include <utmp.h>]])

causes the declaration check to be performed with <utmp.h> on *all* platforms.
But the function login_tty is declared in <util.h> or <libutil.h> on BSD
platforms. Thus this test fails, ac_cv_func_login_tty comes out as 'no',
and Gnulib proceeds to compile the replacement code, although this is not
necessary on these platforms.

This patch fixes it.


2023-01-21  Bruno Haible  <bruno@clisp.org>

        login_tty: Fix detection of declaration (regression 2023-01-19).
        * m4/pty.m4 (gl_FUNC_LOGIN_TTY): Check for the three possible header
        files.

diff --git a/m4/pty.m4 b/m4/pty.m4
index 54523fdac0..f6b5bb3115 100644
--- a/m4/pty.m4
+++ b/m4/pty.m4
@@ -1,4 +1,4 @@
-# pty.m4 serial 16
+# pty.m4 serial 17
 dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -154,8 +154,19 @@ AC_DEFUN([gl_FUNC_LOGIN_TTY],
 [
   AC_REQUIRE([gl_PTY_LIB])
 
+  AC_CHECK_HEADERS_ONCE([utmp.h util.h libutil.h])
   gl_saved_libs="$LIBS"
   LIBS="$LIBS $PTY_LIB"
-  gl_CHECK_FUNCS_ANDROID([login_tty], [[#include <utmp.h>]])
+  gl_CHECK_FUNCS_ANDROID([login_tty], [[
+    #include <sys/types.h>
+    #if HAVE_UTMP_H
+    # include <utmp.h>
+    #endif
+    #if HAVE_UTIL_H
+    # include <util.h>
+    #elif HAVE_LIBUTIL_H
+    # include <libutil.h>
+    #endif
+  ]])
   LIBS="$gl_saved_LIBS"
 ])






reply via email to

[Prev in Thread] Current Thread [Next in Thread]