Change some while loops to for loops in config.c

This commit is contained in:
Mikael Magnusson 2014-10-23 23:33:38 +02:00
parent d6985fd996
commit fe6453b40b

View file

@ -544,13 +544,15 @@ static void parse_mouse(xmlNodePtr node, gpointer d)
if ((n = obt_xml_find_node(node, "screenEdgeWarpMouse"))) if ((n = obt_xml_find_node(node, "screenEdgeWarpMouse")))
config_mouse_screenedgewarp = obt_xml_node_bool(n); config_mouse_screenedgewarp = obt_xml_node_bool(n);
n = obt_xml_find_node(node, "context"); for (n = obt_xml_find_node(node, "context");
while (n) { n;
n = obt_xml_find_node(n->next, "context"))
{
gchar *modcxstr; gchar *modcxstr;
ObFrameContext cx; ObFrameContext cx;
if (!obt_xml_attr_string(n, "name", &cxstr)) if (!obt_xml_attr_string(n, "name", &cxstr))
goto next_n; continue;
modcxstr = g_strdup(cxstr); /* make a copy to mutilate */ modcxstr = g_strdup(cxstr); /* make a copy to mutilate */
while (frame_next_context_from_string(modcxstr, &cx)) { while (frame_next_context_from_string(modcxstr, &cx)) {
@ -565,12 +567,15 @@ static void parse_mouse(xmlNodePtr node, gpointer d)
continue; continue;
} }
nbut = obt_xml_find_node(n->children, "mousebind"); for (nbut = obt_xml_find_node(n->children, "mousebind");
while (nbut) { nbut;
nbut = obt_xml_find_node(nbut->next, "mousebind"))
{
gchar **button, **buttons; gchar **button, **buttons;
if (!obt_xml_attr_string(nbut, "button", &buttonstr)) if (!obt_xml_attr_string(nbut, "button", &buttonstr))
goto next_nbut; continue;
if (obt_xml_attr_contains(nbut, "action", "press")) if (obt_xml_attr_contains(nbut, "action", "press"))
mact = OB_MOUSE_ACTION_PRESS; mact = OB_MOUSE_ACTION_PRESS;
else if (obt_xml_attr_contains(nbut, "action", "release")) else if (obt_xml_attr_contains(nbut, "action", "release"))
@ -582,11 +587,13 @@ static void parse_mouse(xmlNodePtr node, gpointer d)
else if (obt_xml_attr_contains(nbut, "action", "drag")) else if (obt_xml_attr_contains(nbut, "action", "drag"))
mact = OB_MOUSE_ACTION_MOTION; mact = OB_MOUSE_ACTION_MOTION;
else else
goto next_nbut; continue;
buttons = g_strsplit(buttonstr, " ", 0); buttons = g_strsplit(buttonstr, " ", 0);
nact = obt_xml_find_node(nbut->children, "action"); for (nact = obt_xml_find_node(nbut->children, "action");
while (nact) { nact;
nact = obt_xml_find_node(nact->next, "action"))
{
ObActionsAct *action; ObActionsAct *action;
/* actions_parse() creates one ref to the action, but we need /* actions_parse() creates one ref to the action, but we need
@ -598,18 +605,13 @@ static void parse_mouse(xmlNodePtr node, gpointer d)
} }
actions_act_unref(action); actions_act_unref(action);
} }
nact = obt_xml_find_node(nact->next, "action");
} }
g_strfreev(buttons); g_strfreev(buttons);
g_free(buttonstr); g_free(buttonstr);
next_nbut:
nbut = obt_xml_find_node(nbut->next, "mousebind");
} }
} }
g_free(modcxstr); g_free(modcxstr);
g_free(cxstr); g_free(cxstr);
next_n:
n = obt_xml_find_node(n->next, "context");
} }
} }
@ -718,8 +720,10 @@ static void parse_theme(xmlNodePtr node, gpointer d)
config_theme_window_list_icon_size = 96; config_theme_window_list_icon_size = 96;
} }
n = obt_xml_find_node(node, "font"); for (n = obt_xml_find_node(node, "font");
while (n) { n;
n = obt_xml_find_node(n->next, "font"))
{
xmlNodePtr fnode; xmlNodePtr fnode;
RrFont **font; RrFont **font;
gchar *name = g_strdup(RrDefaultFontFamily); gchar *name = g_strdup(RrDefaultFontFamily);
@ -742,7 +746,7 @@ static void parse_theme(xmlNodePtr node, gpointer d)
else if (obt_xml_attr_contains(n, "place","InactiveOnScreenDisplay")) else if (obt_xml_attr_contains(n, "place","InactiveOnScreenDisplay"))
font = &config_font_inactiveosd; font = &config_font_inactiveosd;
else else
goto next_font; continue;
if ((fnode = obt_xml_find_node(n->children, "name"))) { if ((fnode = obt_xml_find_node(n->children, "name"))) {
g_free(name); g_free(name);
@ -769,8 +773,6 @@ static void parse_theme(xmlNodePtr node, gpointer d)
*font = RrFontOpen(ob_rr_inst, name, size, weight, slant); *font = RrFontOpen(ob_rr_inst, name, size, weight, slant);
g_free(name); g_free(name);
next_font:
n = obt_xml_find_node(n->next, "font");
} }
} }
@ -799,12 +801,13 @@ static void parse_desktops(xmlNodePtr node, gpointer d)
g_slist_free(config_desktops_names); g_slist_free(config_desktops_names);
config_desktops_names = NULL; config_desktops_names = NULL;
nname = obt_xml_find_node(n->children, "name"); for (nname = obt_xml_find_node(n->children, "name");
while (nname) { nname;
nname = obt_xml_find_node(nname->next, "name"))
{
config_desktops_names = config_desktops_names =
g_slist_append(config_desktops_names, g_slist_append(config_desktops_names,
obt_xml_node_string(nname)); obt_xml_node_string(nname));
nname = obt_xml_find_node(nname->next, "name");
} }
} }
if ((n = obt_xml_find_node(node, "popupTime"))) if ((n = obt_xml_find_node(node, "popupTime")))
@ -954,12 +957,14 @@ static void parse_menu(xmlNodePtr node, gpointer d)
#endif #endif
} }
while ((node = obt_xml_find_node(node, "file"))) { for (node = obt_xml_find_node(node, "file");
node;
node = obt_xml_find_node(node->next, "file"))
{
gchar *c = obt_xml_node_string(node); gchar *c = obt_xml_node_string(node);
config_menu_files = g_slist_append(config_menu_files, config_menu_files = g_slist_append(config_menu_files,
obt_paths_expand_tilde(c)); obt_paths_expand_tilde(c));
g_free(c); g_free(c);
node = node->next;
} }
} }