bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* login_tty: Fix detection of declaration
@ 2023-01-21 20:04 Bruno Haible
  0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2023-01-21 20:04 UTC (permalink / raw)
  To: bug-gnulib

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"
 ])





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-21 20:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-21 20:04 login_tty: Fix detection of declaration Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).