use list functions for Key
This commit is contained in:
parent
66507b0401
commit
b08c343b65
41
config.c
41
config.c
|
@ -199,59 +199,40 @@ set_key_info(Key *key, cfg_t *cfg)
|
||||||
static Key *
|
static Key *
|
||||||
section_keys(cfg_t *cfg_keys)
|
section_keys(cfg_t *cfg_keys)
|
||||||
{
|
{
|
||||||
Key *key, *head;
|
Key *key = NULL, *head = NULL;
|
||||||
unsigned int i, j, numkeys;
|
int i, j, numkeys;
|
||||||
cfg_t *cfgkeytmp;
|
cfg_t *cfgkeytmp;
|
||||||
|
|
||||||
head = key = NULL;
|
for(i = cfg_size(cfg_keys, "key") - 1; i >= 0; i--)
|
||||||
for(i = 0; i < cfg_size(cfg_keys, "key"); i++)
|
|
||||||
{
|
{
|
||||||
if (i == 0)
|
key = p_new(Key, 1);
|
||||||
key = head = p_new(Key, 1);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
key->next = p_new(Key, 1);
|
|
||||||
key = key->next;
|
|
||||||
}
|
|
||||||
cfgkeytmp = cfg_getnsec(cfg_keys, "key", i);
|
cfgkeytmp = cfg_getnsec(cfg_keys, "key", i);
|
||||||
set_key_info(key, cfgkeytmp);
|
set_key_info(key, cfgkeytmp);
|
||||||
key->keysym = XStringToKeysym(cfg_getstr(cfgkeytmp, "key"));
|
key->keysym = XStringToKeysym(cfg_getstr(cfgkeytmp, "key"));
|
||||||
key->arg = a_strdup(cfg_getstr(cfgkeytmp, "arg"));
|
key->arg = a_strdup(cfg_getstr(cfgkeytmp, "arg"));
|
||||||
|
key_list_push(&head, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < cfg_size(cfg_keys, "keylist"); i++)
|
for(i = cfg_size(cfg_keys, "keylist") - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
cfgkeytmp = cfg_getnsec(cfg_keys, "keylist", i);
|
cfgkeytmp = cfg_getnsec(cfg_keys, "keylist", i);
|
||||||
numkeys = cfg_size(cfgkeytmp, "keylist");
|
numkeys = cfg_size(cfgkeytmp, "keylist");
|
||||||
if (numkeys != cfg_size(cfgkeytmp, "arglist"))
|
if(numkeys != (int) cfg_size(cfgkeytmp, "arglist"))
|
||||||
{
|
{
|
||||||
warn("number of keys != number of args in keylist");
|
warn("number of keys != number of args in keylist");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for(j=0; j < numkeys; j++)
|
|
||||||
{
|
for(j = 0; j < numkeys; j++)
|
||||||
if (head == NULL)
|
|
||||||
{
|
{
|
||||||
key = p_new(Key, 1);
|
key = p_new(Key, 1);
|
||||||
head = key;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
key->next = p_new(Key, 1);
|
|
||||||
key = key->next;
|
|
||||||
}
|
|
||||||
set_key_info(key, cfgkeytmp);
|
set_key_info(key, cfgkeytmp);
|
||||||
key->keysym = XStringToKeysym(cfg_getnstr(cfgkeytmp, "keylist", j));
|
key->keysym = XStringToKeysym(cfg_getnstr(cfgkeytmp, "keylist", j));
|
||||||
key->arg = a_strdup(cfg_getnstr(cfgkeytmp, "arglist", j));
|
key->arg = a_strdup(cfg_getnstr(cfgkeytmp, "arglist", j));
|
||||||
if(j < numkeys - 1)
|
key_list_push(&head, key);
|
||||||
{
|
|
||||||
key->next = p_new(Key, 1);
|
|
||||||
key = key->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (key)
|
|
||||||
key->next = NULL;
|
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue