mirror of
https://github.com/irssi/irssi.git
synced 2026-08-10 20:33:46 +02:00
Factor out some redundant code and remove hashtable_get_keys
This commit is contained in:
parent
2e8744319d
commit
0060f682c2
5 changed files with 26 additions and 48 deletions
|
|
@ -39,21 +39,10 @@
|
|||
Returns -1 if unknown option was given. */
|
||||
int cmd_options_get_level(const char *cmd, GHashTable *optlist)
|
||||
{
|
||||
GSList *list, *tmp, *next;
|
||||
GList *list;
|
||||
int level, retlevel;
|
||||
|
||||
/* get all the options, then remove the known ones. there should
|
||||
be only one left - the server tag. */
|
||||
list = hashtable_get_keys(optlist);
|
||||
if (cmd != NULL) {
|
||||
for (tmp = list; tmp != NULL; tmp = next) {
|
||||
char *option = tmp->data;
|
||||
next = tmp->next;
|
||||
|
||||
if (command_have_option(cmd, option))
|
||||
list = g_slist_remove(list, option);
|
||||
}
|
||||
}
|
||||
list = optlist_remove_known(cmd, optlist);
|
||||
|
||||
retlevel = 0;
|
||||
while (list != NULL) {
|
||||
|
|
@ -68,7 +57,7 @@ int cmd_options_get_level(const char *cmd, GHashTable *optlist)
|
|||
}
|
||||
|
||||
retlevel |= level;
|
||||
list = g_slist_remove(list, list->data);
|
||||
list = g_list_remove(list, list->data);
|
||||
}
|
||||
|
||||
return retlevel;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue