mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-28 05:00:59 +01:00
23665: autoloading of module features and related tweaks
This commit is contained in:
parent
018c9a2708
commit
1b52f47cf2
46 changed files with 1354 additions and 780 deletions
53
Src/exec.c
53
Src/exec.c
|
|
@ -871,7 +871,7 @@ execlist(Estate state, int dont_change_job, int exiting)
|
|||
/* Loop over all sets of comands separated by newline, *
|
||||
* semi-colon or ampersand (`sublists'). */
|
||||
code = *state->pc++;
|
||||
while (wc_code(code) == WC_LIST && !breaks && !retflag) {
|
||||
while (wc_code(code) == WC_LIST && !breaks && !retflag && !errflag) {
|
||||
int donedebug;
|
||||
|
||||
ltype = WC_LIST_TYPE(code);
|
||||
|
|
@ -1915,6 +1915,34 @@ execsubst(LinkList strs)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if a builtin requires an autoload and if so
|
||||
* deal with it. This may return NULL.
|
||||
*/
|
||||
|
||||
/**/
|
||||
static HashNode
|
||||
resolvebuiltin(const char *cmdarg, HashNode hn)
|
||||
{
|
||||
if (!((Builtin) hn)->handlerfunc) {
|
||||
/*
|
||||
* Ensure the module is loaded and the
|
||||
* feature corresponding to the builtin
|
||||
* is enabled.
|
||||
*/
|
||||
(void)ensurefeature(((Builtin) hn)->optstr, "b:",
|
||||
(hn->flags & BINF_AUTOALL) ? NULL :
|
||||
hn->nam);
|
||||
hn = builtintab->getnode(builtintab, cmdarg);
|
||||
if (!hn) {
|
||||
lastval = 1;
|
||||
zerr("unknown builtin: %s");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return hn;
|
||||
}
|
||||
|
||||
/**/
|
||||
static void
|
||||
execcmd(Estate state, int input, int output, int how, int last1)
|
||||
|
|
@ -2011,16 +2039,9 @@ execcmd(Estate state, int input, int output, int how, int last1)
|
|||
is_builtin = 1;
|
||||
|
||||
/* autoload the builtin if necessary */
|
||||
if (!((Builtin) hn)->handlerfunc) {
|
||||
/*
|
||||
* Ensure the module is loaded and the
|
||||
* feature corresponding to the builtin
|
||||
* is enabled.
|
||||
*/
|
||||
(void)ensurefeature(((Builtin) hn)->optstr, "b:", hn->nam);
|
||||
hn = builtintab->getnode(builtintab, cmdarg);
|
||||
}
|
||||
assign = (hn && (hn->flags & BINF_MAGICEQUALS));
|
||||
if (!(hn = resolvebuiltin(cmdarg, hn)))
|
||||
return;
|
||||
assign = (hn->flags & BINF_MAGICEQUALS);
|
||||
break;
|
||||
}
|
||||
cflags &= ~BINF_BUILTIN & ~BINF_COMMAND;
|
||||
|
|
@ -2233,10 +2254,8 @@ execcmd(Estate state, int input, int output, int how, int last1)
|
|||
is_builtin = 1;
|
||||
|
||||
/* autoload the builtin if necessary */
|
||||
if (!((Builtin) hn)->handlerfunc) {
|
||||
(void)ensurefeature(((Builtin) hn)->optstr, "b:", cmdarg);
|
||||
hn = builtintab->getnode(builtintab, cmdarg);
|
||||
}
|
||||
if (!(hn = resolvebuiltin(cmdarg, hn)))
|
||||
return;
|
||||
break;
|
||||
}
|
||||
cflags &= ~BINF_BUILTIN & ~BINF_COMMAND;
|
||||
|
|
@ -4104,8 +4123,8 @@ runshfunc(Eprog prog, FuncWrap wrap, char *name)
|
|||
wrap->module->wrapper--;
|
||||
|
||||
if (!wrap->module->wrapper &&
|
||||
(wrap->module->flags & MOD_UNLOAD))
|
||||
unload_module(wrap->module, NULL);
|
||||
(wrap->module->node.flags & MOD_UNLOAD))
|
||||
unload_module(wrap->module);
|
||||
|
||||
if (!cont)
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue