mirror of
https://github.com/irssi/irssi.git
synced 2025-01-03 14:56:47 -05:00
config_node_nth() and config_node_index() don't count comments in config
anymore. fixes problems having comments in channels and servers block. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2971 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
ca4328e3ab
commit
b05cfc62e0
@ -276,9 +276,14 @@ CONFIG_NODE *config_node_nth(CONFIG_NODE *node, int index)
|
|||||||
g_return_val_if_fail(node != NULL, NULL);
|
g_return_val_if_fail(node != NULL, NULL);
|
||||||
g_return_val_if_fail(is_node_list(node), NULL);
|
g_return_val_if_fail(is_node_list(node), NULL);
|
||||||
|
|
||||||
for (tmp = node->value; tmp != NULL; tmp = tmp->next, index--) {
|
for (tmp = node->value; tmp != NULL; tmp = tmp->next) {
|
||||||
if (index == 0)
|
CONFIG_NODE *node = tmp->data;
|
||||||
return tmp->data;
|
|
||||||
|
if (node->type != NODE_TYPE_COMMENT) {
|
||||||
|
if (index == 0)
|
||||||
|
return node;
|
||||||
|
index--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -288,6 +293,8 @@ CONFIG_NODE *config_node_nth(CONFIG_NODE *node, int index)
|
|||||||
int config_node_index(CONFIG_NODE *parent, const char *key)
|
int config_node_index(CONFIG_NODE *parent, const char *key)
|
||||||
{
|
{
|
||||||
CONFIG_NODE *node;
|
CONFIG_NODE *node;
|
||||||
|
GSList *tmp;
|
||||||
|
int index;
|
||||||
|
|
||||||
g_return_val_if_fail(parent != NULL, -1);
|
g_return_val_if_fail(parent != NULL, -1);
|
||||||
g_return_val_if_fail(key != NULL, -1);
|
g_return_val_if_fail(key != NULL, -1);
|
||||||
@ -296,7 +303,18 @@ int config_node_index(CONFIG_NODE *parent, const char *key)
|
|||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return g_slist_index(parent->value, node);
|
index = 0;
|
||||||
|
for (tmp = parent->value; tmp != NULL; tmp = tmp->next) {
|
||||||
|
CONFIG_NODE *tmpnode = tmp->data;
|
||||||
|
|
||||||
|
if (tmpnode == node)
|
||||||
|
return index;
|
||||||
|
|
||||||
|
if (tmpnode->type != NODE_TYPE_COMMENT)
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the first non-comment node in list */
|
/* Returns the first non-comment node in list */
|
||||||
|
Loading…
Reference in New Issue
Block a user