mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-04 20:40:57 +02:00
39181: Add PM_SINGLE and use for compstate.
This flags that compstate (or any other special) can only have a single instance and an attempt to create a new one is an error. Given the very fiddly semantics of compstate any other usage seems pointless. No investigation yet of other variables that could use this. Note it's still possible to hide such variables; only instances that keep the special nature are affected.
This commit is contained in:
parent
33a8a6f86c
commit
fe3a63fa6c
4 changed files with 13 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
2016-09-06 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 39181: Src/builtin.c, Src/zsh.h, Src/Zle/complete.c: Add
|
||||
PM_SINGLE for single instance and use for compstate.
|
||||
|
||||
2016-09-06 Marko Myllynen <myllynen@redhat.com>
|
||||
|
||||
* 39179 (plus tweak): Completion/Unix/Command/_libvirt: More
|
||||
|
|
|
@ -1238,8 +1238,9 @@ makecompparams(void)
|
|||
|
||||
addcompparams(comprparams, comprpms);
|
||||
|
||||
if (!(cpm = createparam(COMPSTATENAME,
|
||||
PM_SPECIAL|PM_REMOVABLE|PM_LOCAL|PM_HASHED)))
|
||||
if (!(cpm = createparam(
|
||||
COMPSTATENAME,
|
||||
PM_SPECIAL|PM_REMOVABLE|PM_SINGLE|PM_LOCAL|PM_HASHED)))
|
||||
cpm = (Param) paramtab->getnode(paramtab, COMPSTATENAME);
|
||||
DPUTS(!cpm, "param not set in makecompparams");
|
||||
|
||||
|
|
|
@ -2266,6 +2266,10 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func),
|
|||
zerrnam(cname, "%s: restricted", pname);
|
||||
return pm;
|
||||
}
|
||||
if (pm->node.flags & PM_SINGLE) {
|
||||
zerrnam(cname, "%s: can only have a single instance", pname);
|
||||
return pm;
|
||||
}
|
||||
/*
|
||||
* For specials, we keep the same struct but zero everything.
|
||||
* Maybe it would be easier to create a new struct but copy
|
||||
|
|
|
@ -1792,6 +1792,7 @@ struct tieddata {
|
|||
#define PM_ZSHSTORED (1<<18) /* function stored in zsh form */
|
||||
|
||||
/* Remaining flags do not correspond directly to command line arguments */
|
||||
#define PM_SINGLE (1<<20) /* special can only have a single instance */
|
||||
#define PM_LOCAL (1<<21) /* this parameter will be made local */
|
||||
#define PM_SPECIAL (1<<22) /* special builtin parameter */
|
||||
#define PM_DONTIMPORT (1<<23) /* do not import this variable */
|
||||
|
|
Loading…
Reference in a new issue