# HG changeset patch # User mow # Date 1249166277 0 # Node ID 2ec2f682712727c6100681b751877e743edb4edf # Parent 6c5b582767626ae52051e1124d006f925746e58c Fix a small problem with casefull keywords In @1636 I miss one check for keyword case. Now it should be all fixed. diff -r 6c5b58276762 -r 2ec2f6827127 src/metadata.c --- a/src/metadata.c Sat Aug 01 22:37:37 2009 +0000 +++ b/src/metadata.c Sat Aug 01 22:37:57 2009 +0000 @@ -661,6 +661,9 @@ } } +/** + * \see find_string_in_list + */ gchar *find_string_in_list_utf8nocase(GList *list, const gchar *string) { gchar *string_casefold = g_utf8_casefold(string, -1); @@ -668,7 +671,7 @@ while (list) { gchar *haystack = list->data; - + if (haystack) { gboolean equal; @@ -683,14 +686,53 @@ return haystack; } } - + list = list->next; } - + g_free(string_casefold); return NULL; } +/** + * \see find_string_in_list + */ +gchar *find_string_in_list_utf8case(GList *list, const gchar *string) +{ + while (list) + { + gchar *haystack = list->data; + + if (haystack && strcmp(haystack, string) == 0) + return haystack; + + list = list->next; + } // while (list) + + return NULL; +} // gchar *find_string_in_list_utf... + +/** + * \brief Find a existent string in a list. + * + * This is a switch between find_string_in_list_utf8case and + * find_string_in_list_utf8nocase to search with or without case for the + * existence of a string. + * + * \param list The list to search in + * \param string The string to search for + * \return The string or NULL + * + * \see find_string_in_list_utf8case + * \see find_string_in_list_utf8nocase + */ +gchar *find_string_in_list(GList *list, const gchar *string) +{ + if (options->metadata.keywords_case_sensitive) + return find_string_in_list_utf8case(list, string); + else + return find_string_in_list_utf8nocase(list, string); +} #define KEYWORDS_SEPARATOR(c) ((c) == ',' || (c) == ';' || (c) == '\n' || (c) == '\r' || (c) == '\b') @@ -721,7 +763,7 @@ gchar *keyword = g_strndup(begin, l); /* only add if not already in the list */ - if (!find_string_in_list_utf8nocase(list, keyword)) + if (!find_string_in_list(list, keyword)) list = g_list_append(list, keyword); else g_free(keyword); @@ -1170,7 +1212,7 @@ if (keyword_get_is_keyword(keyword_tree, &iter)) { gchar *name = keyword_get_name(keyword_tree, &iter); - if (!find_string_in_list_utf8nocase(*kw_list, name)) + if (!find_string_in_list(*kw_list, name)) { *kw_list = g_list_append(*kw_list, name); } @@ -1192,7 +1234,7 @@ if (!keyword_get_is_keyword(keyword_tree, iter)) return; name = keyword_get_name(keyword_tree, iter); - found = find_string_in_list_utf8nocase(*kw_list, name); + found = find_string_in_list(*kw_list, name); if (found) { diff -r 6c5b58276762 -r 2ec2f6827127 src/metadata.h --- a/src/metadata.h Sat Aug 01 22:37:37 2009 +0000 +++ b/src/metadata.h Sat Aug 01 22:37:57 2009 +0000 @@ -39,7 +39,6 @@ gboolean metadata_append_list(FileData *fd, const gchar *key, const GList *values); GList *string_to_keywords_list(const gchar *text); -gchar *find_string_in_list_utf8nocase(GList *list, const gchar *string); gboolean meta_data_get_keyword_mark(FileData *fd, gint n, gpointer data); gboolean meta_data_set_keyword_mark(FileData *fd, gint n, gboolean value, gpointer data);