diff libpurple/prefs.c @ 25385:a6e3cb32cdd2

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 <grim@reaperworld.com>
author Paul Aurich <paul@darkrain42.org>
date Tue, 06 Jan 2009 03:39:51 +0000
parents 8b55fcc6adde
children 68265bcc8814
line wrap: on
line diff
--- a/libpurple/prefs.c	Fri Jan 02 22:52:17 2009 +0000
+++ b/libpurple/prefs.c	Tue Jan 06 03:39:51 2009 +0000
@@ -250,33 +250,34 @@
 	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 @@
 	} 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 @@
 						  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 @@
 	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 @@
 	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 @@
 			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 @@
 			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 @@
 		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;