diff options
Diffstat (limited to 'Src')
-rw-r--r-- | Src/builtin.c | 9 | ||||
-rw-r--r-- | Src/exec.c | 6 | ||||
-rw-r--r-- | Src/hashtable.c | 43 | ||||
-rw-r--r-- | Src/zsh.h | 5 |
4 files changed, 40 insertions, 23 deletions
diff --git a/Src/builtin.c b/Src/builtin.c index 8703ecead..b7a724cb7 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -2406,9 +2406,16 @@ bin_functions(char *name, char **argv, Options ops, int func) on |= PM_TAGGED; else if (OPT_PLUS(ops,'t')) off |= PM_TAGGED; + if (OPT_MINUS(ops,'z')) + on |= PM_ZSHSTORED; + else if (OPT_PLUS(ops,'z')) + off |= PM_ZSHSTORED; + if (OPT_MINUS(ops,'k')) + on |= PM_KSHSTORED; + else if (OPT_PLUS(ops,'k')) + off |= PM_KSHSTORED; if ((off & PM_UNDEFINED) || (OPT_ISSET(ops,'k') && OPT_ISSET(ops,'z')) || - (!OPT_PLUS(ops,'X') && (OPT_ISSET(ops,'k') || OPT_ISSET(ops,'z'))) || (OPT_MINUS(ops,'X') && (OPT_ISSET(ops,'m') || *argv || !scriptname))) { zwarnnam(name, "invalid option(s)", NULL, 0); return 1; diff --git a/Src/exec.c b/Src/exec.c index 8256910b3..ff34edb4b 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3398,8 +3398,12 @@ loadautofn(Shfunc shf, int fksh, int autol) prog = getfpfunc(shf->nam, &ksh); noaliases = noalias; - if (ksh == 1) + if (ksh == 1) { ksh = fksh; + if (ksh == 1) + ksh = (shf->flags & PM_KSHSTORED) ? 2 : + (shf->flags & PM_ZSHSTORED) ? 0 : 1; + } if (prog == &dummy_eprog) { /* We're not actually in the function; decrement locallevel */ diff --git a/Src/hashtable.c b/Src/hashtable.c index b09936fa8..8b310c516 100644 --- a/Src/hashtable.c +++ b/Src/hashtable.c @@ -863,7 +863,7 @@ static void printshfuncnode(HashNode hn, int printflags) { Shfunc f = (Shfunc) hn; - char *t; + char *t = 0; if ((printflags & PRINT_NAMEONLY) || ((printflags & PRINT_WHENCE_SIMPLE) && @@ -881,32 +881,35 @@ printshfuncnode(HashNode hn, int printflags) return; } - if (f->flags & PM_UNDEFINED) - t = tricat("builtin autoload -X", - ((f->flags & PM_UNALIASED)? "U" : ""), - ((f->flags & PM_TAGGED)? "t" : "")); - else { - if (!f->funcdef) - t = 0; - else - t = getpermtext(f->funcdef, NULL); - } - quotedzputs(f->nam, stdout); - if (t) { + if (f->funcdef || f->flags & PM_UNDEFINED) { printf(" () {\n\t"); if (f->flags & PM_UNDEFINED) printf("%c undefined\n\t", hashchar); + else + t = getpermtext(f->funcdef, NULL); if (f->flags & PM_TAGGED) printf("%c traced\n\t", hashchar); - zputs(t, stdout); - if (f->funcdef && (f->funcdef->flags & EF_RUN)) { - printf("\n\t"); - quotedzputs(f->nam, stdout); - printf(" \"$@\""); - } + if (!t) { + char *fopt = "Utkz"; + int flgs[] = { + PM_UNALIASED, PM_TAGGED, PM_KSHSTORED, PM_ZSHSTORED, 0 + }; + int fl;; + + zputs("builtin autoload -X", stdout); + for (fl=0;fopt[fl];fl++) + if (f->flags & flgs[fl]) putchar(fopt[fl]); + } else { + zputs(t, stdout); + zsfree(t); + if (f->funcdef->flags & EF_RUN) { + printf("\n\t"); + quotedzputs(f->nam, stdout); + printf(" \"$@\""); + } + } printf("\n}\n"); - zsfree(t); } else { printf(" () { }\n"); } diff --git a/Src/zsh.h b/Src/zsh.h index 523e8b2c3..a455c4f93 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -1197,6 +1197,9 @@ struct tieddata { #define PM_HIDEVAL (1<<15) /* Value not shown in `typeset' commands */ #define PM_TIED (1<<16) /* array tied to colon-path or v.v. */ +#define PM_KSHSTORED (1<<17) /* function stored in ksh form */ +#define PM_ZSHSTORED (1<<18) /* function stored in zsh form */ + /* Remaining flags do not correspond directly to command line arguments */ #define PM_LOCAL (1<<21) /* this parameter will be made local */ #define PM_SPECIAL (1<<22) /* special builtin parameter */ @@ -1210,7 +1213,7 @@ struct tieddata { #define PM_NAMEDDIR (1<<30) /* has a corresponding nameddirtab entry */ /* The option string corresponds to the first of the variables above */ -#define TYPESET_OPTSTR "aiEFALRZlurtxUhHT" +#define TYPESET_OPTSTR "aiEFALRZlurtxUhHTkz" /* These typeset options take an optional numeric argument */ #define TYPESET_OPTNUM "LRZiEF" |