1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-11 13:01:28 +02:00

33012: add an error return value (-1) to xsymlinks()

This commit is contained in:
Barton E. Schaefer 2014-08-15 10:19:54 -07:00
parent 2be0d8bdef
commit 47d91c5fba
2 changed files with 14 additions and 7 deletions

View file

@ -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> 2014-08-14 Oliver Kiddle <opk@zsh.org>
* 32998: Completion/Unix/Command/_dsh, Completion/Unix/Command/_nm, * 32998: Completion/Unix/Command/_dsh, Completion/Unix/Command/_nm,

View file

@ -716,7 +716,6 @@ slashsplit(char *s)
} }
/* expands symlinks and .. or . expressions */ /* expands symlinks and .. or . expressions */
/* if flag = 0, only expand .. and . expressions */
/**/ /**/
static int static int
@ -753,6 +752,7 @@ xsymlinks(char *s)
strcat(xbuf, *pp); strcat(xbuf, *pp);
} else { } else {
*xbuf = 0; *xbuf = 0;
ret = -1;
break; break;
} }
} else { } else {
@ -760,9 +760,11 @@ xsymlinks(char *s)
metafy(xbuf3, t0, META_NOALLOC); metafy(xbuf3, t0, META_NOALLOC);
if (*xbuf3 == '/') { if (*xbuf3 == '/') {
strcpy(xbuf, ""); strcpy(xbuf, "");
xsymlinks(xbuf3 + 1); if (xsymlinks(xbuf3 + 1) < 0)
ret = -1;
} else } else
xsymlinks(xbuf3); if (xsymlinks(xbuf3) < 0)
ret = -1;
} }
} }
freearray(opp); freearray(opp);
@ -781,11 +783,10 @@ xsymlink(char *s)
if (*s != '/') if (*s != '/')
return NULL; return NULL;
*xbuf = '\0'; *xbuf = '\0';
xsymlinks(s + 1); if (xsymlinks(s + 1) < 0)
if (!*xbuf) {
zwarn("path expansion failed, using root directory"); zwarn("path expansion failed, using root directory");
if (!*xbuf)
return ztrdup("/"); return ztrdup("/");
}
return ztrdup(xbuf); return ztrdup(xbuf);
} }
@ -795,7 +796,7 @@ print_if_link(char *s)
{ {
if (*s == '/') { if (*s == '/') {
*xbuf = '\0'; *xbuf = '\0';
if (xsymlinks(s + 1)) if (xsymlinks(s + 1) > 0)
printf(" -> "), zputs(*xbuf ? xbuf : "/", stdout); printf(" -> "), zputs(*xbuf ? xbuf : "/", stdout);
} }
} }