Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
zmodload builtin improvements
- X-seq: zsh-workers 2620
- From: Zefram <zefram@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (Z Shell workers mailing list)
- Subject: zmodload builtin improvements
- Date: Mon, 23 Dec 1996 20:00:47 +0000 (GMT)
-----BEGIN PGP SIGNED MESSAGE-----
This patch makes a few improvements to the zmodload builtin:
* Make it complain about incompatible options (-a, -u, -d).
* Make "zmodload -a" (with no arguments) list the autoloaded builtins.
* Add -L option, in the style of alias and compctl, to output information
in the form of zmodload commands. Also use it in reporter.
* A trivial fix of English usage in an error message.
-zefram
Index: Doc/zshbuiltins.man
===================================================================
RCS file: /home/zefram/usr/cvsroot/zsh/Doc/zshbuiltins.man,v
retrieving revision 1.15
diff -c -r1.15 zshbuiltins.man
*** Doc/zshbuiltins.man 1996/12/22 04:50:13 1.15
--- Doc/zshbuiltins.man 1996/12/23 01:24:03
***************
*** 1201,1211 ****
Same as \fBwhence \-c\fP.
%IFDYN%.TP
%IFDYN%.PD 0
! %IFDYN%\fBzmodload\fP [\-\fBiu\fP] [ \fIname\fP ... ]
%IFDYN%.TP
! %IFDYN%\fBzmodload\fP [\-\fBd\fP] [ \fIname\fP ... ]
%IFDYN%.TP
! %IFDYN%\fBzmodload\fP [\-\fBa\fP] \fIbuiltin\fP [ \fIname\fP ]
%IFDYN%.PD
%IFDYN%Load (or, with
%IFDYN%.BR -u ,
--- 1201,1213 ----
Same as \fBwhence \-c\fP.
%IFDYN%.TP
%IFDYN%.PD 0
! %IFDYN%\fBzmodload\fP [\-\fBiL\fP] [ \fIname\fP ... ]
%IFDYN%.TP
! %IFDYN%\fBzmodload\fP \-\fBu\fP [\-\fBi\fP] \fIname\fP ...
%IFDYN%.TP
! %IFDYN%\fBzmodload\fP \-\fBd\fP [\-\fBL\fP] [ \fIname\fP [ \fIname\fP ... ] ]
! %IFDYN%.TP
! %IFDYN%\fBzmodload\fP \-\fBa\fP [\-\fBL\fP] [ \fIbuiltin\fP [ \fIname\fP ] ]
%IFDYN%.PD
%IFDYN%Load (or, with
%IFDYN%.BR -u ,
***************
*** 1248,1263 ****
--- 1250,1281 ----
%IFDYN%can only be unloaded if its cleanup function runs successfully.
%IFDYN%.PP
%IFDYN%Without arguments all currently loaded binary modules are printed.
+ %IFDYN%The
+ %IFDYN%.B -L
+ %IFDYN%option causes this list to be in the form of a series of
+ %IFDYN%.B zmodload
+ %IFDYN%commands.
%IFDYN%.PP
%IFDYN%The \fB\-d\fP option can be used to secify module dependencies.
%IFDYN%The modules named in the second and subsequent arguments will be
%IFDYN%loaded before the module named in the first argument. With one
%IFDYN%argument all dependencies for that module are removed. With no
%IFDYN%arguments, all module dependencies are printed in Makefile format.
+ %IFDYN%The
+ %IFDYN%.B -L
+ %IFDYN%option changes this format to a list of
+ %IFDYN%.B zmodload -d
+ %IFDYN%commands.
%IFDYN%.PP
%IFDYN%The \fB\-a\fP option defines autoloaded builtins. It defines a new
%IFDYN%builtin given by the first argument. When that builtin is called
%IFDYN%the module specified in the second argument is loaded. With one
%IFDYN%argument the module name defaults to the name of the builtin.
+ %IFDYN%With no arguments, all autoloaded builtins are listed, with the module
+ %IFDYN%name (if different) shown in parentheses after the builtin name. The
+ %IFDYN%.B -L
+ %IFDYN%option changes this format to a list of
+ %IFDYN%.B zmodload -a
+ %IFDYN%commands.
%IFDYN%.RE
.RE
Index: Src/hashtable.h
===================================================================
RCS file: /home/zefram/usr/cvsroot/zsh/Src/hashtable.h,v
retrieving revision 1.23
diff -c -r1.23 hashtable.h
*** Src/hashtable.h 1996/12/22 04:50:28 1.23
--- Src/hashtable.h 1996/12/23 00:24:50
***************
*** 304,310 ****
#endif
#ifdef DYNAMIC
! {NULL, "zmodload", 0, bin_zmodload, 0, -1, 0, "audi", NULL},
#endif
{NULL, "popd", 0, bin_cd, 0, 2, BIN_POPD, NULL, NULL},
{NULL, "print", BINF_PRINTOPTS, bin_print, 0, -1, BIN_PRINT, "RDPnrslzNu0123456789pioOcm-", NULL},
--- 304,310 ----
#endif
#ifdef DYNAMIC
! {NULL, "zmodload", 0, bin_zmodload, 0, -1, 0, "Laudi", NULL},
#endif
{NULL, "popd", 0, bin_cd, 0, 2, BIN_POPD, NULL, NULL},
{NULL, "print", BINF_PRINTOPTS, bin_print, 0, -1, BIN_PRINT, "RDPnrslzNu0123456789pioOcm-", NULL},
Index: Src/module.c
===================================================================
RCS file: /home/zefram/usr/cvsroot/zsh/Src/module.c,v
retrieving revision 1.14
diff -c -r1.14 module.c
*** Src/module.c 1996/12/22 04:50:31 1.14
--- Src/module.c 1996/12/23 01:12:08
***************
*** 297,302 ****
--- 297,329 ----
} LASTALLOC;
}
+ static void autoloadscan _((HashNode, int));
+
+ static void
+ autoloadscan(HashNode hn, int printflags)
+ {
+ Builtin bn = (Builtin) hn;
+
+ if(bn->handlerfunc || (bn->flags & BINF_PREFIX))
+ return;
+ if(printflags & PRINT_LIST) {
+ fputs("zmodload -a ", stdout);
+ quotedzputs(bn->nam, stdout);
+ if(strcmp(bn->nam, bn->optstr)) {
+ putchar(' ');
+ quotedzputs(bn->optstr, stdout);
+ }
+ } else {
+ nicezputs(bn->nam, stdout);
+ if(strcmp(bn->nam, bn->optstr)) {
+ fputs(" (", stdout);
+ nicezputs(bn->optstr, stdout);
+ putchar(')');
+ }
+ }
+ putchar('\n');
+ }
+
/**/
int
bin_zmodload(char *nam, char **args, char *ops, int func)
***************
*** 305,331 ****
Module m = NULL;
int ret = 0;
if (!*args) {
if (ops['u']) {
zwarnnam(nam, "which module do you want to unload?", NULL, 0);
return 1;
}
for (node = firstnode(modules); node; incnode(node)) {
m = (Module) getdata(node);
if (ops['d']) {
if (m->deps) {
LinkNode n;
! zputs(m->nam, stdout);
! putchar(':');
for (n = firstnode(m->deps); n; incnode(n)) {
putchar(' ');
! zputs((char *) getdata(n), stdout);
}
putchar('\n');
}
} else if (m->handle) {
! zputs(m->nam, stdout);
putchar('\n');
}
}
--- 332,379 ----
Module m = NULL;
int ret = 0;
+ if((ops['d'] + ops['a'] + ops['u']) > 1) {
+ zwarnnam(nam, "only use one of -d, -a and -u", NULL, 0);
+ return 1;
+ }
if (!*args) {
if (ops['u']) {
zwarnnam(nam, "which module do you want to unload?", NULL, 0);
return 1;
}
+ if(ops['a']) {
+ scanhashtable(builtintab, 0, 0, 0,
+ autoloadscan, ops['L'] ? PRINT_LIST : 0);
+ return 0;
+ }
for (node = firstnode(modules); node; incnode(node)) {
m = (Module) getdata(node);
if (ops['d']) {
if (m->deps) {
LinkNode n;
! if(ops['L']) {
! printf("zmodload -d ");
! quotedzputs(m->nam, stdout);
! } else {
! nicezputs(m->nam, stdout);
! putchar(':');
! }
for (n = firstnode(m->deps); n; incnode(n)) {
putchar(' ');
! if(ops['L'])
! quotedzputs((char *) getdata(n), stdout);
! else
! nicezputs((char *) getdata(n), stdout);
}
putchar('\n');
}
} else if (m->handle) {
! if(ops['L']) {
! printf("zmodload ");
! quotedzputs(m->nam, stdout);
! } else
! nicezputs(m->nam, stdout);
putchar('\n');
}
}
***************
*** 375,381 ****
if (m->deps && m->handle)
for (dn = firstnode(m->deps); dn; incnode(dn))
if (!strcmp((char *) getdata(dn), *args)) {
! zwarnnam(nam, "module %s is used by an other module, I cannot remove it.", *args, 0);
ret++;
goto cont;
}
--- 423,429 ----
if (m->deps && m->handle)
for (dn = firstnode(m->deps); dn; incnode(dn))
if (!strcmp((char *) getdata(dn), *args)) {
! zwarnnam(nam, "module %s is in use by another module and cannot be unloaded", *args, 0);
ret++;
goto cont;
}
Index: Util/reporter
===================================================================
RCS file: /home/zefram/usr/cvsroot/zsh/Util/reporter,v
retrieving revision 1.5
diff -c -r1.5 reporter
*** Util/reporter 1996/12/22 04:50:58 1.5
--- Util/reporter 1996/12/23 01:46:58
***************
*** 30,35 ****
--- 30,36 ----
# "completion" prints only "compctl" commands.
# "functions" prints "autoload" commands or actual functions.
# "limits" prints "limit" commands for things like cputime, etc.
+ # "modules" prints "zmodload" commands.
# "options" prints "setopt" commands.
# "variables" prints both shell and environment variables.
#
***************
*** 100,105 ****
--- 101,107 ----
c*) reporter_do_compctl=yes; reporter_do_all=no ;;
f*) reporter_do_fun=yes; reporter_do_all=no ;;
l*) reporter_do_lim=yes; reporter_do_all=no ;;
+ m*) reporter_do_mod=yes; reporter_do_all=no ;;
o*) reporter_do_setopt=yes; reporter_do_all=no ;;
v*) reporter_do_vars=yes; reporter_do_all=no ;;
*) ;;
***************
*** 298,303 ****
--- 300,325 ----
limit | grep -v "cputime" | grep -v "unlimited" |
sed -e 's/Mb/m/' -e 's/Kb/k/' |
${AWK} 'NF > 1 {print "limit " $0}'
+ fi
+
+ #
+ # MODULE LOADING COMMANDS
+ #
+
+ if test "$reporter_do_all" = "yes" -o "$reporter_do_mod" = "yes"
+ then
+ echo
+ if ( zmodload ) >& /dev/null; then
+ echo "# Modules."
+ echo
+ zmodload -d -L
+ echo
+ zmodload -a -L
+ echo
+ zmodload -L
+ else
+ echo "# Modules: zmodload not available."
+ fi
fi
#
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
iQCVAwUBMr3lJnD/+HJTpU/hAQEtlAP9Hb5hRzaLeCLDrNLpmsg1+SRE6fD1emo7
sK1UwuOjigq7PrM/0fcVT5qs0erWweuOUcaZaBw00WWSHlYDC17DecZtPEli8dqU
9gtKcRhGh5mDfvQAiUN9ZSkgN2E2ZKLdcf8lrmZZhqphOrzaojQzf12z5Rx8ID3g
VA5fxTmIlx0=
=2knV
-----END PGP SIGNATURE-----
Messages sorted by:
Reverse Date,
Date,
Thread,
Author