2009-09-17 Eric Blake <ebb9@byu.net>
+ canonicalize-lgpl: use native realpath if it works
+ * lib/canonicalize-lgpl.c (realpath): Guard with
+ FUNC_REALPATH_WORKS.
+ * lib/stdlib.in.h (realpath): Make declaration optional based on
+ HAVE_REALPATH.
+ * m4/canonicalize-lgpl.m4 (gl_CANONICALIZE_LGPL): Check whether
+ native realpath works.
+ * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Provide default.
+ * modules/stdlib (Makefile.am): Substitute witness.
+
canonicalize, canonicalize-lgpl: use <stdlib.h>
* modules/canonicalize-lgpl (Files): Drop canonicalize.h.
(Include): Mention <stdlib.h>.
# define __readlink readlink
#endif
+#if !FUNC_REALPATH_WORKS || defined _LIBC
/* Return the canonical absolute name of file NAME. A canonical name
does not contain any `.', `..' components nor any repeated path
separators ('/') or symlinks. All path components must exist. If
}
return NULL;
}
-#ifdef _LIBC
versioned_symbol (libc, __realpath, realpath, GLIBC_2_3);
-#endif
+#endif /* !FUNC_REALPATH_WORKS || defined _LIBC */
#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3)
#if @GNULIB_REALPATH@
# if @REPLACE_REALPATH@
# define realpath rpl_realpath
+# endif
+# if !@HAVE_REALPATH@ || @REPLACE_REALPATH@
extern char *realpath (const char *name, char *resolved);
# endif
#elif defined GNULIB_POSIXCHECK
-# canonicalize-lgpl.m4 serial 7
+# canonicalize-lgpl.m4 serial 8
dnl Copyright (C) 2003, 2006-2007, 2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl Do this replacement check manually because the file name is shorter
dnl than the function name.
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
- AC_CHECK_FUNCS_ONCE([canonicalize_file_name])
+ AC_CHECK_FUNCS_ONCE([canonicalize_file_name realpath])
dnl Assume that all platforms with canonicalize_file_name also have
- dnl a working realpath; otherwise assume realpath is broken.
+ dnl a working realpath.
if test $ac_cv_func_canonicalize_file_name = no; then
HAVE_CANONICALIZE_FILE_NAME=0
AC_LIBOBJ([canonicalize-lgpl])
- REPLACE_REALPATH=1
+ if test $ac_cv_func_realpath = no; then
+ HAVE_REALPATH=0
+ else
+ AC_CACHE_CHECK([whether realpath works], [gl_cv_func_realpath_works], [
+ touch conftest.a
+ AC_RUN_IFELSE([
+ AC_LANG_PROGRAM([[
+ #include <stdlib.h>
+ ]], [[
+ char *name1 = realpath ("conftest.a", NULL);
+ char *name2 = realpath ("conftest.b/../conftest.a", NULL);
+ return !(name1 && *name1 == '/' && !name2);
+ ]])
+ ], [gl_cv_func_realpath_works=yes], [gl_cv_func_realpath_works=no],
+ [gl_cv_func_realpath_works="guessing no"])
+ ])
+ if test $gl_cv_func_realpath_works != yes; then
+ REPLACE_REALPATH=1
+ else
+ AC_DEFINE([FUNC_REALPATH_WORKS], [1], [Define to 1 if realpath()
+ can malloc memory and always gives an absolute path.])
+ fi
+ fi
gl_PREREQ_CANONICALIZE_LGPL
fi
])
-# stdlib_h.m4 serial 18
+# stdlib_h.m4 serial 19
dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP])
HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
HAVE_REALLOC_POSIX=1; AC_SUBST([HAVE_REALLOC_POSIX])
+ HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH])
HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH])
HAVE_SETENV=1; AC_SUBST([HAVE_SETENV])
HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD])
-e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
-e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
-e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \
+ -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
-e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
-e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \
-e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \