From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9230 invoked from network); 13 Apr 2004 15:31:11 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 13 Apr 2004 15:31:11 -0000 Received: (qmail 7581 invoked by alias); 13 Apr 2004 15:31:06 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19767 Received: (qmail 7568 invoked from network); 13 Apr 2004 15:31:05 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 13 Apr 2004 15:31:05 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.225.247.86] by sunsite.dk (MessageWall 1.0.8) with SMTP; 13 Apr 2004 15:31:5 -0000 Received: (qmail 3250 invoked from network); 13 Apr 2004 15:31:05 -0000 Received: from mail36.messagelabs.com (193.109.254.211) by a.mx.sunsite.dk with SMTP; 13 Apr 2004 15:31:02 -0000 X-VirusChecked: Checked X-Env-Sender: okiddle@yahoo.co.uk X-Msg-Ref: server-23.tower-36.messagelabs.com!1081870233!5422612 X-StarScan-Version: 5.2.10; banners=-,-,- X-Originating-IP: [158.234.9.163] Received: (qmail 13920 invoked from network); 13 Apr 2004 15:30:33 -0000 Received: from iris.logica.co.uk (158.234.9.163) by server-23.tower-36.messagelabs.com with SMTP; 13 Apr 2004 15:30:33 -0000 Received: from trentino.logica.co.uk ([158.234.142.61]) by iris.logica.co.uk (8.12.3/8.12.3/Debian -4) with ESMTP id i3DFUXMO001133 for ; Tue, 13 Apr 2004 16:30:33 +0100 Received: from trentino.logica.co.uk (localhost [127.0.0.1]) by trentino.logica.co.uk (Postfix) with ESMTP id F289A790E26C for ; Tue, 13 Apr 2004 17:29:48 +0200 (CEST) X-VirusChecked: Checked X-StarScan-Version: 5.0.7; banners=.,-,- In-reply-to: <1040413053826.ZM20012@candle.brasslantern.com> From: Oliver Kiddle References: <1040410174430.ZM10891@candle.brasslantern.com> <1170.1081778412@athlon> <040412085942.ZM19035@candle.brasslantern.com> <3571.1081806187@athlon> <1040413053826.ZM20012@candle.brasslantern.com> To: zsh-workers@sunsite.dk Subject: PATCH: Re: Compsys and KSH_AUTOLOAD Date: Tue, 13 Apr 2004 17:29:48 +0200 Message-ID: <18035.1081870188@trentino.logica.co.uk> X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 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"