diff options
author | Daniel Shahaf <d.s@daniel.shahaf.name> | 2016-07-30 16:16:22 +0000 |
---|---|---|
committer | Daniel Shahaf <d.s@daniel.shahaf.name> | 2016-08-22 03:34:30 +0000 |
commit | 7154052ebe3d810390164a05c39ff83f98a1d858 (patch) | |
tree | de329087e802a17df0dd93aee35fdb5e49b25ac3 /Src/utils.c | |
parent | 4b2810ab2d6be3d1cf811e53d3b4f57630821108 (diff) | |
download | zsh-7154052ebe3d810390164a05c39ff83f98a1d858.tar.gz zsh-7154052ebe3d810390164a05c39ff83f98a1d858.tar.xz zsh-7154052ebe3d810390164a05c39ff83f98a1d858.zip |
39046 + 39061: New :P history modifier.
Diffstat (limited to 'Src/utils.c')
-rw-r--r-- | Src/utils.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Src/utils.c b/Src/utils.c index 0a5954f65..45fd19286 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -801,9 +801,9 @@ findpwd(char *s) char *t; if (*s == '/') - return xsymlink(s); + return xsymlink(s, 0); s = tricat((pwd[1]) ? pwd : "", "/", s); - t = xsymlink(s); + t = xsymlink(s, 0); zsfree(s); return t; } @@ -969,11 +969,13 @@ xsymlinks(char *s, int full) /* * expand symlinks in s, and remove other weird things: * note that this always expands symlinks. + * + * 'heap' indicates whether to malloc() or allocate on the heap. */ /**/ char * -xsymlink(char *s) +xsymlink(char *s, int heap) { if (*s != '/') return NULL; @@ -981,8 +983,8 @@ xsymlink(char *s) if (xsymlinks(s + 1, 1) < 0) zwarn("path expansion failed, using root directory"); if (!*xbuf) - return ztrdup("/"); - return ztrdup(xbuf); + return heap ? dupstring("/") : ztrdup("/"); + return heap ? dupstring(xbuf) : ztrdup(xbuf); } /**/ @@ -1260,7 +1262,7 @@ getnameddir(char *name) /* Retrieve an entry from the password table/database for this user. */ struct passwd *pw; if ((pw = getpwnam(name))) { - char *dir = isset(CHASELINKS) ? xsymlink(pw->pw_dir) + char *dir = isset(CHASELINKS) ? xsymlink(pw->pw_dir, 0) : ztrdup(pw->pw_dir); if (dir) { adduserdir(name, dir, ND_USERNAME, 1); |