From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@sunsite.dk
Subject: PATCH: Re: Compsys and KSH_AUTOLOAD
Date: Tue, 13 Apr 2004 17:29:48 +0200 [thread overview]
Message-ID: <18035.1081870188@trentino.logica.co.uk> (raw)
In-Reply-To: <1040413053826.ZM20012@candle.brasslantern.com>
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"
next prev parent reply other threads:[~2004-04-13 15:31 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-10 17:44 Bart Schaefer
2004-04-12 14:00 ` Oliver Kiddle
2004-04-12 15:59 ` Bart Schaefer
2004-04-12 21:43 ` Oliver Kiddle
2004-04-13 5:32 ` While we're on the subject of zcompile Bart Schaefer
2004-04-17 21:08 ` Oliver Kiddle
2004-04-13 5:38 ` Compsys and KSH_AUTOLOAD Bart Schaefer
2004-04-13 15:29 ` Oliver Kiddle [this message]
2004-04-13 17:51 ` PATCH: " Bart Schaefer
2004-04-16 16:49 ` Oliver Kiddle
2004-04-16 17:25 ` Bart Schaefer
2004-04-18 13:46 ` Oliver Kiddle
2004-04-16 17:30 ` Bart Schaefer
2004-04-17 19:51 ` Oliver Kiddle
2004-04-19 0:14 ` Bart Schaefer
2004-04-19 10:18 ` Oliver Kiddle
2004-04-20 4:11 ` Bart Schaefer
2004-04-20 10:08 ` Oliver Kiddle
2004-04-14 5:04 ` Bart Schaefer
2004-04-14 19:55 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=18035.1081870188@trentino.logica.co.uk \
--to=okiddle@yahoo.co.uk \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).