1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-17 15:01:40 +02:00

19801: implement autoloading of trap functions

This commit is contained in:
Peter Stephenson 2004-04-20 12:57:27 +00:00
parent 2c1f42366d
commit c1e47cb71f
2 changed files with 26 additions and 3 deletions

View file

@ -1,3 +1,8 @@
2004-04-20 Peter Stephenson <pws@csr.com>
* 19801: Src/builtin.c: Autoloading of TRAP functions was never
implemented.
2004-04-20 Oliver Kiddle <opk@zsh.org>
* 19767, 19785: Src/builtin.c, Src/exec.c, Src/hashtable.c,

View file

@ -2508,14 +2508,32 @@ bin_functions(char *name, char **argv, Options ops, int func)
/* no flags, so just print */
shfunctab->printnode((HashNode) shf, pflags);
} else if (on & PM_UNDEFINED) {
int signum, ok = 1;
/* Add a new undefined (autoloaded) function to the *
* hash table with the corresponding flags set. */
shf = (Shfunc) zshcalloc(sizeof *shf);
shf->flags = on;
shf->funcdef = mkautofn(shf);
shfunctab->addnode(shfunctab, ztrdup(*argv), shf);
if (OPT_ISSET(ops,'X') && eval_autoload(shf, shf->nam, ops, func))
returnval = 1;
if (!strncmp(*argv, "TRAP", 4) &&
(signum = getsignum(*argv + 4)) != -1) {
if (settrap(signum, shf->funcdef)) {
freeeprog(shf->funcdef);
zfree(shf, sizeof(*shf));
returnval = 1;
ok = 0;
}
else
sigtrapped[signum] |= ZSIG_FUNC;
}
if (ok) {
shfunctab->addnode(shfunctab, ztrdup(*argv), shf);
if (OPT_ISSET(ops,'X') &&
eval_autoload(shf, shf->nam, ops, func))
returnval = 1;
}
} else
returnval = 1;
}