diff options
author | Peter Stephenson <pws@zsh.org> | 2017-01-16 10:31:56 +0000 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2017-01-16 10:31:56 +0000 |
commit | f90a0447aada3ad2fa114210c62b855a3e60cb1d (patch) | |
tree | f1756619779fb93985c53fc2a39cf313f2e130c5 /Src/hashtable.c | |
parent | ebd7fdd9326cf36feda3b0ca906d7b9b8bf79cb5 (diff) | |
download | zsh-f90a0447aada3ad2fa114210c62b855a3e60cb1d.tar.gz zsh-f90a0447aada3ad2fa114210c62b855a3e60cb1d.tar.xz zsh-f90a0447aada3ad2fa114210c62b855a3e60cb1d.zip |
40353 with tweaks to whence -v: extend directory cache use.
Now used for all autoloaded functions after load, including those where the file was found along fpath, reducing duplication of directory names.
Diffstat (limited to 'Src/hashtable.c')
-rw-r--r-- | Src/hashtable.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/Src/hashtable.c b/Src/hashtable.c index a3a38f705..1f2789d07 100644 --- a/Src/hashtable.c +++ b/Src/hashtable.c @@ -926,10 +926,13 @@ printshfuncnode(HashNode hn, int printflags) (f->node.flags & PM_UNDEFINED) ? " is an autoload shell function" : " is a shell function"); - if (f->filename && (printflags & PRINT_WHENCE_VERBOSE) && - strcmp(f->filename, f->node.nam) != 0) { + if ((printflags & PRINT_WHENCE_VERBOSE) && f->filename) { printf(" from "); quotedzputs(f->filename, stdout); + if (f->node.flags & PM_LOADDIR) { + printf("/"); + quotedzputs(f->node.nam, stdout); + } } putchar('\n'); return; @@ -959,7 +962,7 @@ printshfuncnode(HashNode hn, int printflags) zputs("builtin autoload -X", stdout); for (fl=0;fopt[fl];fl++) if (f->node.flags & flgs[fl]) putchar(fopt[fl]); - if (f->filename) { + if (f->filename && (f->node.flags & PM_LOADDIR)) { putchar(' '); zputs(f->filename, stdout); } @@ -1041,6 +1044,24 @@ printshfuncexpand(HashNode hn, int printflags, int expand) text_expand_tabs = save_expand; } +/* + * Get a heap-duplicated name of the shell function, for + * use in tracing. + */ + +/**/ +mod_export char * +getshfuncfile(Shfunc shf) +{ + if (shf->node.flags & PM_LOADDIR) { + return zhtricat(shf->filename, "/", shf->node.nam); + } else if (shf->filename) { + return dupstring(shf->filename); + } else { + return NULL; + } +} + /**************************************/ /* Reserved Word Hash Table Functions */ /**************************************/ |