diff src/metadata.c @ 1340:361120a66609

Use g_utf8_casefold() to compare keywords, uppercased/lowercased keywords are now matched against predefined list.
author zas_
date Sat, 28 Feb 2009 18:01:16 +0000
parents 10073464e6aa
children 79937bc55f3a
line wrap: on
line diff
--- a/src/metadata.c	Sat Feb 28 17:20:16 2009 +0000
+++ b/src/metadata.c	Sat Feb 28 18:01:16 2009 +0000
@@ -549,19 +549,36 @@
 		}
 }
 
-gboolean find_string_in_list(GList *list, const gchar *string)
+gchar *find_string_in_list_utf8nocase(GList *list, const gchar *string)
 {
+	gchar *string_casefold = g_utf8_casefold(string, -1);
+
 	while (list)
 		{
 		gchar *haystack = list->data;
+		
+		if (haystack)
+			{
+			gboolean equal;
+			gchar *haystack_casefold = g_utf8_casefold(haystack, -1);
 
-		if (haystack && string && strcmp(haystack, string) == 0) return TRUE;
+			equal = (strcmp(haystack_casefold, string_casefold) == 0);
+			g_free(haystack_casefold);
 
+			if (equal)
+				{
+				g_free(string_casefold);
+				return haystack;
+				}
+			}
+	
 		list = list->next;
 		}
+	
+	g_free(string_casefold);
+	return NULL;
+}
 
-	return FALSE;
-}
 
 #define KEYWORDS_SEPARATOR(c) ((c) == ',' || (c) == ';' || (c) == '\n' || (c) == '\r' || (c) == '\b')
 
@@ -592,7 +609,7 @@
 			gchar *keyword = g_strndup(begin, l);
 
 			/* only add if not already in the list */
-			if (find_string_in_list(list, keyword) == FALSE)
+			if (!find_string_in_list_utf8nocase(list, keyword))
 				list = g_list_append(list, keyword);
 			else
 				g_free(keyword);