diff options
Diffstat (limited to 'Src/Zle/zleparameter.c')
-rw-r--r-- | Src/Zle/zleparameter.c | 52 |
1 files changed, 18 insertions, 34 deletions
diff --git a/Src/Zle/zleparameter.c b/Src/Zle/zleparameter.c index 38b2a3608..ed415c960 100644 --- a/Src/Zle/zleparameter.c +++ b/Src/Zle/zleparameter.c @@ -51,11 +51,8 @@ createspecialhash(char *name, GetNodeFunc get, ScanTabFunc scan) return NULL; pm->level = pm->old ? locallevel : 0; - pm->gets.hfn = hashgetfn; - pm->sets.hfn = hashsetfn; - pm->unsetfn = stdunsetfn; + pm->gsu.h = &stdhash_gsu; pm->u.hash = ht = newhashtable(0, name, NULL); - pm->ct = 0; ht->hash = hasher; ht->emptytable = (TableFunc) shempty; @@ -101,17 +98,11 @@ getpmwidgets(UNUSED(HashTable ht), char *name) Param pm = NULL; Thingy th; - pm = (Param) zhalloc(sizeof(struct param)); + pm = (Param) hcalloc(sizeof(struct param)); pm->nam = dupstring(name); pm->flags = PM_SCALAR | PM_READONLY; - pm->sets.cfn = NULL; - pm->gets.cfn = strgetfn; - pm->unsetfn = NULL; - pm->ct = 0; - pm->env = NULL; - pm->ename = NULL; - pm->old = NULL; - pm->level = 0; + pm->gsu.s = &nullsetscalar_gsu; + if ((th = (Thingy) thingytab->getnode(thingytab, name)) && !(th->flags & DISABLED)) pm->u.str = widgetstr(th->widget); @@ -130,15 +121,9 @@ scanpmwidgets(UNUSED(HashTable ht), ScanFunc func, int flags) int i; HashNode hn; + memset((void *)&pm, 0, sizeof(struct param)); pm.flags = PM_SCALAR | PM_READONLY; - pm.sets.cfn = NULL; - pm.gets.cfn = strgetfn; - pm.unsetfn = NULL; - pm.ct = 0; - pm.env = NULL; - pm.ename = NULL; - pm.old = NULL; - pm.level = 0; + pm.gsu.s = &nullsetscalar_gsu; for (i = 0; i < thingytab->hsize; i++) for (hn = thingytab->nodes[i]; hn; hn = hn->next) { @@ -177,21 +162,22 @@ struct pardef { int flags; GetNodeFunc getnfn; ScanTabFunc scantfn; - void (*hsetfn) _((Param, HashTable)); - void (*setfn) _((Param, char **)); - char **(*getfn) _((Param)); - void (*unsetfn) _((Param, int)); + GsuHash hash_gsu; + GsuArray array_gsu; Param pm; }; +static const struct gsu_array keymaps_gsu = +{ keymapsgetfn, arrsetfn, stdunsetfn }; + static struct pardef partab[] = { { "widgets", PM_READONLY, - getpmwidgets, scanpmwidgets, hashsetfn, - NULL, NULL, stdunsetfn, NULL }, + getpmwidgets, scanpmwidgets, &stdhash_gsu, + NULL, NULL }, { "keymaps", PM_ARRAY|PM_SPECIAL|PM_READONLY, NULL, NULL, NULL, - arrsetfn, keymapsgetfn, stdunsetfn, NULL }, - { NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL } + &keymaps_gsu, NULL }, + { NULL, 0, NULL, NULL, NULL, NULL, NULL } }; /**/ @@ -215,14 +201,12 @@ boot_(UNUSED(Module m)) def->scantfn))) return 1; def->pm->flags |= def->flags; - if (def->hsetfn) - def->pm->sets.hfn = def->hsetfn; + if (def->hash_gsu) + def->pm->gsu.h = def->hash_gsu; } else { if (!(def->pm = createparam(def->name, def->flags | PM_HIDE))) return 1; - def->pm->sets.afn = def->setfn; - def->pm->gets.afn = def->getfn; - def->pm->unsetfn = def->unsetfn; + def->pm->gsu.a = def->array_gsu; } } return 0; |