Patch #639371: Remove FreeBSD 5 specific test, test for ctermid_r, setgroups
prototypes explicitly.
diff --git a/configure b/configure
index f6a8cce..c07fae9 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.369 .
+# From configure.in Revision: 1.370 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.53 for python 2.3.
 #
@@ -1341,10 +1341,6 @@
   # even though select is a POSIX function. Reported by J. Ribbens.
   OpenBSD/2.* | OpenBSD/3.[012])
     define_xopen_source=no;;
-  # On FreeBSD 5.0, chroot and setgroups are not declared if _XOPEN_SOURCE
-  # is define. Reported by M. Recht.
-  FreeBSD/5.0*)
-    define_xopen_source=no;;
 esac
 
 if test $define_xopen_source = yes
@@ -11988,15 +11984,13 @@
 
 
 
-
-
-for ac_func in alarm chown clock confstr ctermid ctermid_r execv \
+for ac_func in alarm chown clock confstr ctermid execv \
  fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \
  gai_strerror getgroups getlogin getpeername getpgid getpid getpwent getwd \
  hstrerror inet_pton kill killpg lchown lstat mkfifo mknod mktime \
  mremap nice pathconf pause plock poll pthread_init \
  putenv readlink \
- select setegid seteuid setgid setgroups \
+ select setegid seteuid setgid \
  setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
  sigaction siginterrupt sigrelse strftime strptime \
  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
@@ -12220,6 +12214,114 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 
+# On some systems (eg. FreeBSD 5), we would find a definition of the
+# functions ctermid_r, setgroups in the library, but no prototype
+# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
+# address to avoid compiler warnings and potential miscompilations
+# because of the missing prototypes.
+
+echo "$as_me:$LINENO: checking for ctermid_r" >&5
+echo $ECHO_N "checking for ctermid_r... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#include "confdefs.h"
+#include <stdio.h>
+
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+void* p = ctermid_r
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_CTERMID_R 1
+_ACEOF
+
+  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+echo "$as_me:$LINENO: checking for setgroups" >&5
+echo $ECHO_N "checking for setgroups... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#include "confdefs.h"
+#include <unistd.h.h>
+
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+void* p = setgroups
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SETGROUPS 1
+_ACEOF
+
+  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
 # check for openpty and forkpty