From 51f31d7f70db88c43c7c0455221b545ecb8cdbff Mon Sep 17 00:00:00 2001 From: Paul Aurich Date: Tue, 6 Jan 2009 03:39:51 +0000 Subject: Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us closes #7790 committer: Gary Kramlich --- libpurple/prefs.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) (limited to 'libpurple/prefs.c') diff --git a/libpurple/prefs.c b/libpurple/prefs.c index 960ecb0191..1eca2a0eb3 100644 --- a/libpurple/prefs.c +++ b/libpurple/prefs.c @@ -250,33 +250,34 @@ prefs_start_element_handler (GMarkupParseContext *context, GString *pref_name_full; GList *tmp; - if(strcmp(element_name, "pref") && strcmp(element_name, "item")) + if(!purple_strequal(element_name, "pref") && + !purple_strequal(element_name, "item")) return; for(i = 0; attribute_names[i]; i++) { - if(!strcmp(attribute_names[i], "name")) { + if(purple_strequal(attribute_names[i], "name")) { pref_name = attribute_values[i]; - } else if(!strcmp(attribute_names[i], "type")) { - if(!strcmp(attribute_values[i], "bool")) + } else if(purple_strequal(attribute_names[i], "type")) { + if(purple_strequal(attribute_values[i], "bool")) pref_type = PURPLE_PREF_BOOLEAN; - else if(!strcmp(attribute_values[i], "int")) + else if(purple_strequal(attribute_values[i], "int")) pref_type = PURPLE_PREF_INT; - else if(!strcmp(attribute_values[i], "string")) + else if(purple_strequal(attribute_values[i], "string")) pref_type = PURPLE_PREF_STRING; - else if(!strcmp(attribute_values[i], "stringlist")) + else if(purple_strequal(attribute_values[i], "stringlist")) pref_type = PURPLE_PREF_STRING_LIST; - else if(!strcmp(attribute_values[i], "path")) + else if(purple_strequal(attribute_values[i], "path")) pref_type = PURPLE_PREF_PATH; - else if(!strcmp(attribute_values[i], "pathlist")) + else if(purple_strequal(attribute_values[i], "pathlist")) pref_type = PURPLE_PREF_PATH_LIST; else return; - } else if(!strcmp(attribute_names[i], "value")) { + } else if(purple_strequal(attribute_names[i], "value")) { pref_value = attribute_values[i]; } } - if(!strcmp(element_name, "item")) { + if(purple_strequal(element_name, "item")) { struct purple_pref *pref; pref_name_full = g_string_new(""); @@ -301,7 +302,7 @@ prefs_start_element_handler (GMarkupParseContext *context, } else { char *decoded; - if(!pref_name || !strcmp(pref_name, "/")) + if(!pref_name || purple_strequal(pref_name, "/")) return; pref_name_full = g_string_new(pref_name); @@ -352,7 +353,7 @@ prefs_end_element_handler(GMarkupParseContext *context, const gchar *element_name, gpointer user_data, GError **error) { - if(prefs_stack && !strcmp(element_name, "pref")) { + if(prefs_stack && purple_strequal(element_name, "pref")) { g_free(prefs_stack->data); prefs_stack = g_list_delete_link(prefs_stack, prefs_stack); } @@ -521,7 +522,7 @@ find_pref_parent(const char *name) char *parent_name = get_path_dirname(name); struct purple_pref *ret = &prefs; - if(strcmp(parent_name, "/")) { + if(!purple_strequal(parent_name, "/")) { ret = find_pref(parent_name); } @@ -571,7 +572,7 @@ add_pref(PurplePrefType type, const char *name) my_name = get_path_basename(name); for(sibling = parent->first_child; sibling; sibling = sibling->sibling) { - if(!strcmp(sibling->name, my_name)) { + if(purple_strequal(sibling->name, my_name)) { g_free(my_name); return NULL; } @@ -848,10 +849,7 @@ purple_prefs_set_string(const char *name, const char *value) return; } - if((value && !pref->value.string) || - (!value && pref->value.string) || - (value && pref->value.string && - strcmp(pref->value.string, value))) { + if (!purple_strequal(pref->value.string, value)) { g_free(pref->value.string); pref->value.string = g_strdup(value); do_callbacks(name, pref); @@ -908,10 +906,7 @@ purple_prefs_set_path(const char *name, const char *value) return; } - if((value && !pref->value.string) || - (!value && pref->value.string) || - (value && pref->value.string && - strcmp(pref->value.string, value))) { + if (!purple_strequal(pref->value.string, value)) { g_free(pref->value.string); pref->value.string = g_strdup(value); do_callbacks(name, pref); @@ -1105,7 +1100,7 @@ purple_prefs_rename_node(struct purple_pref *oldpref, struct purple_pref *newpre next = child->sibling; for(newchild = newpref->first_child; newchild != NULL; newchild = newchild->sibling) { - if(!strcmp(child->name, newchild->name)) + if(purple_strequal(child->name, newchild->name)) { purple_prefs_rename_node(child, newchild); break; -- cgit v1.2.1