about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2014-08-15 10:19:54 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2014-08-15 10:19:54 -0700
commit47d91c5fba6bc90d79503b7c69c6146abb8825f5 (patch)
treeee7065daedfa8a9b7ddf5ba8f9a6925b907a9fdb
parent2be0d8bdef401b6bca0c80a7bd78d658e862e38e (diff)
downloadzsh-47d91c5fba6bc90d79503b7c69c6146abb8825f5.tar.gz
zsh-47d91c5fba6bc90d79503b7c69c6146abb8825f5.tar.xz
zsh-47d91c5fba6bc90d79503b7c69c6146abb8825f5.zip
33012: add an error return value (-1) to xsymlinks()
-rw-r--r--ChangeLog6
-rw-r--r--Src/utils.c15
2 files changed, 14 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index f70718cab..aa08a26a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-08-15  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 33012: Src/utils.c: add an error return value (-1) to xsymlinks()
+	to differentiate when xbuf is set to the empty string; silences
+	bogus warning about failed expansion
+
 2014-08-14  Oliver Kiddle  <opk@zsh.org>
 
 	* 32998: Completion/Unix/Command/_dsh, Completion/Unix/Command/_nm,
diff --git a/Src/utils.c b/Src/utils.c
index 998e46a36..076a33c0f 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -716,7 +716,6 @@ slashsplit(char *s)
 }
 
 /* expands symlinks and .. or . expressions */
-/* if flag = 0, only expand .. and . expressions */
 
 /**/
 static int
@@ -753,6 +752,7 @@ xsymlinks(char *s)
 		strcat(xbuf, *pp);
 	    } else {
 		*xbuf = 0;
+		ret = -1;
 		break;
 	    }
 	} else {
@@ -760,9 +760,11 @@ xsymlinks(char *s)
 	    metafy(xbuf3, t0, META_NOALLOC);
 	    if (*xbuf3 == '/') {
 		strcpy(xbuf, "");
-		xsymlinks(xbuf3 + 1);
+		if (xsymlinks(xbuf3 + 1) < 0)
+		    ret = -1;
 	    } else
-		xsymlinks(xbuf3);
+		if (xsymlinks(xbuf3) < 0)
+		    ret = -1;
 	}
     }
     freearray(opp);
@@ -781,11 +783,10 @@ xsymlink(char *s)
     if (*s != '/')
 	return NULL;
     *xbuf = '\0';
-    xsymlinks(s + 1);
-    if (!*xbuf) {
+    if (xsymlinks(s + 1) < 0)
 	zwarn("path expansion failed, using root directory");
+    if (!*xbuf)
 	return ztrdup("/");
-    }
     return ztrdup(xbuf);
 }
 
@@ -795,7 +796,7 @@ print_if_link(char *s)
 {
     if (*s == '/') {
 	*xbuf = '\0';
-	if (xsymlinks(s + 1))
+	if (xsymlinks(s + 1) > 0)
 	    printf(" -> "), zputs(*xbuf ? xbuf : "/", stdout);
     }
 }