On BSD, realpath(3) doesn't fail if the target doesn't exist, so test
authorPaul Smith <psmith@gnu.org>
Sun, 9 Sep 2012 23:14:55 +0000 (23:14 +0000)
committerPaul Smith <psmith@gnu.org>
Sun, 9 Sep 2012 23:14:55 +0000 (23:14 +0000)
explicitly with stat(2).  Fixes Savannah bug #35919.

ChangeLog
function.c

index 943552eec884fbd56e422ada735882557634a6bf..ba6ddaedc71c50d25883a70058a3a62899e1f5c9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2012-09-09  Paul Smith  <psmith@gnu.org>
 
+       * function.c (func_realpath): BSD realpath(3) doesn't fail if the
+       file does not exist: use stat.  Fixes Savannah bug #35919.
+
        * file.c (expand_deps): Duplicate the current variable buffer, not
        the old pointer.  Fixes Savannah bug #36925.
 
index 67405ccfb6b505843021695c5ed9c6fd62579eb1..325d9304387a64c38aeb84ca547e9f46a2cc94aa 100644 (file)
@@ -2066,9 +2066,7 @@ func_realpath (char *o, char **argv, const char *funcname UNUSED)
   const char *path = 0;
   int doneany = 0;
   unsigned int len = 0;
-#ifndef HAVE_REALPATH
   struct stat st;
-#endif
   PATH_VAR (in);
   PATH_VAR (out);
 
@@ -2083,9 +2081,9 @@ func_realpath (char *o, char **argv, const char *funcname UNUSED)
 #ifdef HAVE_REALPATH
               realpath (in, out)
 #else
-              abspath (in, out) && stat (out, &st) == 0
+              abspath (in, out)
 #endif
-             )
+              && stat (out, &st) == 0)
             {
               o = variable_buffer_output (o, out, strlen (out));
               o = variable_buffer_output (o, " ", 1);