Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: Compsys and KSH_AUTOLOAD
- X-seq: zsh-workers 19767
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: Re: Compsys and KSH_AUTOLOAD
- Date: Tue, 13 Apr 2004 17:29:48 +0200
- In-reply-to: <1040413053826.ZM20012@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <1040410174430.ZM10891@xxxxxxxxxxxxxxxxxxxxxxx> <1170.1081778412@athlon> <040412085942.ZM19035@xxxxxxxxxxxxxxxxxxxxxxx> <3571.1081806187@athlon> <1040413053826.ZM20012@xxxxxxxxxxxxxxxxxxxxxxx>
Bart wrote:
> } Presumably it also stores whether the function was autoloaded with the
> } -U option. Looks like there is a PM_UNALIASED flag. Maybe we can just
> } add PM_ZSHSTORED and PM_KSHSTORED flags.
>
> Yes, that would probably work.
It seems to. Try the patch below.
If autoload -X/+X is used with -k/-z options, those take precedence
over any set in the flags.
It's not in the patch but I've tried replacing `autoload -U' with
`autoload -Uz' in compinit/compdump and new completion seems to then
work with kshautoload set. Should I make that change?
In addition to documentation changes, I also need to make the new
options work for functions and typeset -f. Shouldn't running just
`functions -U' restrict the listed options to those with PM_UNALIASED
set? At the moment, it isn't entirely consistent with typeset. What
should `functions +U' do?
> Here's a possibly-silly idea: Those flags could be made to apply to
> arrays as well as functions, so one could have both zero-based and one-
> based indexing independent of the ksharrays option. (-k and -z are not
> currently used by typeset except in its autoload incarnation.)
It's not a bad idea, if it isn't hard to implement. Can you think of
cases where you would want a zero-based array?
Oliver
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.114
diff -u -r1.114 builtin.c
--- Src/builtin.c 6 Apr 2004 09:25:18 -0000 1.114
+++ Src/builtin.c 13 Apr 2004 15:07:16 -0000
@@ -2406,9 +2406,16 @@
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;
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.59
diff -u -r1.59 exec.c
--- Src/exec.c 6 Apr 2004 09:25:18 -0000 1.59
+++ Src/exec.c 13 Apr 2004 15:07:16 -0000
@@ -3398,8 +3398,12 @@
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 */
Index: Src/hashtable.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hashtable.c,v
retrieving revision 1.17
diff -u -r1.17 hashtable.c
--- Src/hashtable.c 11 Mar 2004 14:25:12 -0000 1.17
+++ Src/hashtable.c 13 Apr 2004 15:07:16 -0000
@@ -863,7 +863,7 @@
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 @@
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");
}
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.54
diff -u -r1.54 zsh.h
--- Src/zsh.h 11 Mar 2004 14:25:12 -0000 1.54
+++ Src/zsh.h 13 Apr 2004 15:07:16 -0000
@@ -1197,6 +1197,9 @@
#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 @@
#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"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author