mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-07 23:51:14 +02:00
zsh-workers/8480
This commit is contained in:
parent
cfa7436ee6
commit
eaa5228eb1
4 changed files with 65 additions and 1 deletions
|
@ -113,6 +113,10 @@ fi
|
||||||
|
|
||||||
comppostfuncs=()
|
comppostfuncs=()
|
||||||
|
|
||||||
|
# Loading it now ensures that the `funcstack' parameter is always correct.
|
||||||
|
|
||||||
|
zmodload -i parameter
|
||||||
|
|
||||||
# This function is used to register or delete completion functions. For
|
# This function is used to register or delete completion functions. For
|
||||||
# registering completion functions, it is invoked with the name of the
|
# registering completion functions, it is invoked with the name of the
|
||||||
# function as it's first argument (after the options). The other
|
# function as it's first argument (after the options). The other
|
||||||
|
|
|
@ -137,4 +137,10 @@ item(tt(userdirs))(
|
||||||
This association maps user names to the pathnames of their home
|
This association maps user names to the pathnames of their home
|
||||||
directories.
|
directories.
|
||||||
)
|
)
|
||||||
|
vindex(funcstack)
|
||||||
|
item(tt(funcstack))(
|
||||||
|
This array contains the names of the functions currently being
|
||||||
|
executed. The first element is the name of the function using the
|
||||||
|
parameter.
|
||||||
|
)
|
||||||
enditem()
|
enditem()
|
||||||
|
|
|
@ -555,6 +555,44 @@ scanpmdisfunctions(HashTable ht, ScanFunc func, int flags)
|
||||||
scanfunctions(ht, func, flags, DISABLED);
|
scanfunctions(ht, func, flags, DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Functions for the funcstack special parameter. */
|
||||||
|
|
||||||
|
static LinkList funcstack;
|
||||||
|
|
||||||
|
/**/
|
||||||
|
static char **
|
||||||
|
funcstackgetfn(Param pm)
|
||||||
|
{
|
||||||
|
char **ret, **p;
|
||||||
|
LinkNode node;
|
||||||
|
|
||||||
|
ret = (char **) zhalloc((countlinknodes(funcstack) + 1) * sizeof(char *));
|
||||||
|
|
||||||
|
for (node = firstnode(funcstack), p = ret; node; incnode(node), p++)
|
||||||
|
*p = (char *) getdata(node);
|
||||||
|
*p = NULL;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
static int
|
||||||
|
func_wrapper(List list, FuncWrap w, char *name)
|
||||||
|
{
|
||||||
|
PERMALLOC {
|
||||||
|
pushnode(funcstack, ztrdup(name));
|
||||||
|
} LASTALLOC;
|
||||||
|
|
||||||
|
runshfunc(list, w, name);
|
||||||
|
|
||||||
|
DPUTS(strcmp(name, (char *) getdata(firstnode(funcstack))),
|
||||||
|
"funcstack wrapper with wrong function");
|
||||||
|
|
||||||
|
zsfree((char *) remnode(funcstack, firstnode(funcstack)));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Functions for the builtins special parameter. */
|
/* Functions for the builtins special parameter. */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
@ -1775,6 +1813,9 @@ static struct pardef partab[] = {
|
||||||
{ "disfunctions", 0,
|
{ "disfunctions", 0,
|
||||||
getpmdisfunction, scanpmdisfunctions, setpmdisfunctions,
|
getpmdisfunction, scanpmdisfunctions, setpmdisfunctions,
|
||||||
NULL, NULL, stdunsetfn, NULL },
|
NULL, NULL, stdunsetfn, NULL },
|
||||||
|
{ "funcstack", PM_ARRAY|PM_SPECIAL|PM_READONLY,
|
||||||
|
NULL, NULL, NULL,
|
||||||
|
arrsetfn, funcstackgetfn, stdunsetfn, NULL },
|
||||||
{ "builtins", PM_READONLY,
|
{ "builtins", PM_READONLY,
|
||||||
getpmbuiltin, scanpmbuiltins, hashsetfn,
|
getpmbuiltin, scanpmbuiltins, hashsetfn,
|
||||||
NULL, NULL, stdunsetfn, NULL },
|
NULL, NULL, stdunsetfn, NULL },
|
||||||
|
@ -1829,6 +1870,10 @@ static struct pardef partab[] = {
|
||||||
{ NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
|
{ NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct funcwrap wrapper[] = {
|
||||||
|
WRAPDEF(func_wrapper),
|
||||||
|
};
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
setup_parameter(Module m)
|
setup_parameter(Module m)
|
||||||
|
@ -1867,6 +1912,12 @@ boot_parameter(Module m)
|
||||||
def->pm->unsetfn = def->unsetfn;
|
def->pm->unsetfn = def->unsetfn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PERMALLOC {
|
||||||
|
funcstack = newlinklist();
|
||||||
|
} LASTALLOC;
|
||||||
|
|
||||||
|
addwrapper(m, wrapper);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1888,6 +1939,9 @@ cleanup_parameter(Module m)
|
||||||
unsetparam_pm(pm, 0, 1);
|
unsetparam_pm(pm, 0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
deletewrapper(m, wrapper);
|
||||||
|
freelinklist(funcstack, freestr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
autoparams="parameters commands functions disfunctions builtins disbuiltins reswords disreswords options modules dirstack history historywords jobtexts jobstates nameddirs userdirs raliases disraliases galiases disgaliases"
|
autoparams="parameters commands functions disfunctions funcstack builtins disbuiltins reswords disreswords options modules dirstack history historywords jobtexts jobstates nameddirs userdirs raliases disraliases galiases disgaliases"
|
||||||
|
|
||||||
objects="parameter.o"
|
objects="parameter.o"
|
||||||
|
|
Loading…
Reference in a new issue