summaryrefslogtreecommitdiff
path: root/m4/readlink.m4
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-09-22 17:15:04 -0600
committerEric Blake <ebb9@byu.net>2009-09-23 05:39:19 -0600
commit5835d9b52879c334f16e747c54be8ec9c62e8536 (patch)
treed0475406eb50450b7c62e44c7fd1f675b3c0a9e3 /m4/readlink.m4
parent5b192b3998d3b3bcea45594d180200cd44f35e3b (diff)
downloadgnulib-5835d9b52879c334f16e747c54be8ec9c62e8536.tar.gz
readlink: fix Solaris 9 bug with trailing slash
readlink("link/",buf,len) mistakenly succeeded. * lib/readlink.c (rpl_readlink): Work around trailing slash bug. * m4/readlink.m4 (gl_FUNC_READLINK): Detect the bug. * doc/posix-functions/readlink.texi (readlink): Document this. * modules/readlink-tests: New test. * tests/test-readlink.c: Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'm4/readlink.m4')
-rw-r--r--m4/readlink.m421
1 files changed, 19 insertions, 2 deletions
diff --git a/m4/readlink.m4 b/m4/readlink.m4
index b7b74de1e9..fa7c2ddcb1 100644
--- a/m4/readlink.m4
+++ b/m4/readlink.m4
@@ -1,4 +1,4 @@
-# readlink.m4 serial 6
+# readlink.m4 serial 7
dnl Copyright (C) 2003, 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,
@@ -21,7 +21,24 @@ AC_DEFUN([gl_FUNC_READLINK],
/* Cause compilation failure if original declaration has wrong type. */
ssize_t readlink (const char *, char *, size_t);]])],
[gl_cv_decl_readlink_works=yes], [gl_cv_decl_readlink_works=no])])
- if test "$gl_cv_decl_readlink_works" != yes; then
+ AC_CACHE_CHECK([whether readlink handles trailing slash correctly],
+ [gl_cv_func_readlink_works],
+ [# We have readlink, so assume ln -s works.
+ ln -s conftest.no-such conftest.link
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <unistd.h>
+]], [[char buf[20];
+ return readlink ("conftest.link/", buf, sizeof buf) != -1;]])],
+ [gl_cv_func_readlink_works=yes], [gl_cv_func_readlink_works=no],
+ [gl_cv_func_readlink_works="guessing no"])
+ rm -f conftest.link])
+ if test "$gl_cv_func_readlink_works" != yes; then
+ AC_DEFINE([READLINK_TRAILING_SLASH_BUG], [1], [Define to 1 if readlink
+ fails to recognize a trailing slash.])
+ REPLACE_READLINK=1
+ AC_LIBOBJ([readlink])
+ elif test "$gl_cv_decl_readlink_works" != yes; then
REPLACE_READLINK=1
AC_LIBOBJ([readlink])
fi