changeset 13695:8a06cdf65b57

Take over the maintenance of some older macros from Autoconf. * m4/error.m4 (AC_FUNC_ERROR_AT_LINE): New macro, from GNU Autoconf. * m4/lstat.m4 (AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK): New macro, from GNU Autoconf. * m4/memcmp.m4 (AC_FUNC_MEMCMP): New macro, from GNU Autoconf. * m4/mktime.m4 (AC_FUNC_MKTIME): Change comment. Signed-off-by: Eric Blake <eblake@redhat.com>
author Bruno Haible <bruno@clisp.org>
date Fri, 17 Sep 2010 10:18:38 -0600
parents 5a8df829305e
children bfe487360d66
files ChangeLog m4/error.m4 m4/lstat.m4 m4/memcmp.m4 m4/mktime.m4
diffstat 5 files changed, 109 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-09-17  Bruno Haible  <bruno@clisp.org>
+
+	Take over the maintenance of some older macros from Autoconf.
+	* m4/error.m4 (AC_FUNC_ERROR_AT_LINE): New macro, from GNU Autoconf.
+	* m4/lstat.m4 (AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK): New macro, from
+	GNU Autoconf.
+	* m4/memcmp.m4 (AC_FUNC_MEMCMP): New macro, from GNU Autoconf.
+	* m4/mktime.m4 (AC_FUNC_MKTIME): Change comment.
+
 2010-09-17  Eric Blake  <eblake@redhat.com>
 
 	fdutimensat: drop atflag validation
--- a/m4/error.m4
+++ b/m4/error.m4
@@ -1,4 +1,4 @@
-#serial 12
+#serial 13
 
 # Copyright (C) 1996-1998, 2001-2004, 2009-2010 Free Software Foundation, Inc.
 #
@@ -13,6 +13,23 @@
   gl_PREREQ_ERROR
 ])
 
+# Redefine AC_FUNC_ERROR_AT_LINE, because it is no longer maintained in
+# Autoconf.
+AC_DEFUN([AC_FUNC_ERROR_AT_LINE],
+[
+  AC_LIBSOURCES([error.h, error.c])dnl
+  AC_CACHE_CHECK([for error_at_line], [ac_cv_lib_error_at_line],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <error.h>]],
+          [[error_at_line (0, 0, "", 0, "an error occurred");]])],
+       [ac_cv_lib_error_at_line=yes],
+       [ac_cv_lib_error_at_line=no])])
+  if test $ac_cv_lib_error_at_line = no; then
+    AC_LIBOBJ([error])
+  fi
+])
+
 # Prerequisites of lib/error.c.
 AC_DEFUN([gl_PREREQ_ERROR],
 [
--- a/m4/lstat.m4
+++ b/m4/lstat.m4
@@ -1,4 +1,4 @@
-# serial 20
+# serial 21
 
 # Copyright (C) 1997-2001, 2003-2010 Free Software Foundation, Inc.
 #
@@ -26,3 +26,44 @@
     HAVE_LSTAT=0
   fi
 ])
+
+# Redefine AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK, because it is no longer
+# maintained in Autoconf.
+AC_DEFUN([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
+[
+  AC_CACHE_CHECK([whether lstat correctly handles trailing slash],
+    [ac_cv_func_lstat_dereferences_slashed_symlink],
+    [rm -f conftest.sym conftest.file
+     echo >conftest.file
+     if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
+       AC_RUN_IFELSE(
+         [AC_LANG_PROGRAM(
+            [AC_INCLUDES_DEFAULT],
+            [[struct stat sbuf;
+              /* Linux will dereference the symlink and fail, as required by
+                 POSIX.  That is better in the sense that it means we will not
+                 have to compile and use the lstat wrapper.  */
+              return lstat ("conftest.sym/", &sbuf) == 0;
+            ]])],
+         [ac_cv_func_lstat_dereferences_slashed_symlink=yes],
+         [ac_cv_func_lstat_dereferences_slashed_symlink=no],
+         [# When cross-compiling, be pessimistic so we will end up using the
+          # replacement version of lstat that checks for trailing slashes and
+          # calls lstat a second time when necessary.
+          ac_cv_func_lstat_dereferences_slashed_symlink=no
+         ])
+     else
+       # If the 'ln -s' command failed, then we probably don't even
+       # have an lstat function.
+       ac_cv_func_lstat_dereferences_slashed_symlink=no
+     fi
+     rm -f conftest.sym conftest.file
+    ])
+  test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
+    AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
+      [Define to 1 if `lstat' dereferences a symlink specified
+       with a trailing slash.])
+  if test "x$ac_cv_func_lstat_dereferences_slashed_symlink" = xno; then
+    AC_LIBOBJ([lstat])
+  fi
+])
--- a/m4/memcmp.m4
+++ b/m4/memcmp.m4
@@ -1,4 +1,4 @@
-# memcmp.m4 serial 14
+# memcmp.m4 serial 15
 dnl Copyright (C) 2002-2004, 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -27,5 +27,42 @@
   fi
 ])
 
+# Redefine AC_FUNC_MEMCMP, because it is no longer maintained in Autoconf.
+AC_DEFUN([AC_FUNC_MEMCMP],
+[
+  AC_CACHE_CHECK([for working memcmp], [ac_cv_func_memcmp_working],
+    [AC_RUN_IFELSE(
+       [AC_LANG_PROGRAM(
+          [AC_INCLUDES_DEFAULT],
+          [[/* Some versions of memcmp are not 8-bit clean.  */
+            char c0 = '\100', c1 = '\200', c2 = '\201';
+            if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
+              return 1;
+            /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
+               or more and with at least one buffer not starting on a 4-byte
+               boundary.  William Lewis provided this test program.   */
+            {
+              char foo[21];
+              char bar[21];
+              int i;
+              for (i = 0; i < 4; i++)
+                {
+                  char *a = foo + i;
+                  char *b = bar + i;
+                  strcpy (a, "--------01111111");
+                  strcpy (b, "--------10000000");
+                  if (memcmp (a, b, 16) >= 0)
+                    return 1;
+                }
+              return 0;
+            }
+          ]])],
+       [ac_cv_func_memcmp_working=yes],
+       [ac_cv_func_memcmp_working=no],
+       [ac_cv_func_memcmp_working=no])])
+  test $ac_cv_func_memcmp_working = no &&
+    AC_LIBOBJ([memcmp])
+])
+
 # Prerequisites of lib/memcmp.c.
 AC_DEFUN([gl_PREREQ_MEMCMP], [:])
--- a/m4/mktime.m4
+++ b/m4/mktime.m4
@@ -1,4 +1,4 @@
-# serial 15
+# serial 16
 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2010 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -7,10 +7,7 @@
 
 dnl From Jim Meyering.
 
-# Redefine AC_FUNC_MKTIME, to fix a bug in Autoconf 2.61a and earlier.
-# This redefinition can be removed once a new version of Autoconf is assumed.
-# The redefinition is taken from
-# <http://cvs.sv.gnu.org/viewcvs/*checkout*/autoconf/autoconf/lib/autoconf/functions.m4?rev=1.119>.
+# Redefine AC_FUNC_MKTIME, because it is no longer maintained in Autoconf.
 # AC_FUNC_MKTIME
 # --------------
 AC_DEFUN([AC_FUNC_MKTIME],