Mercurial > geeqie
changeset 1715:f1e316c4cc4d
Fix a small problem with casefull keywords
In @1636 I miss one check for keyword case. Now it should be all fixed.
author | mow |
---|---|
date | Sat, 01 Aug 2009 22:37:57 +0000 |
parents | 21647c5b2420 |
children | cb905f42ac0b |
files | src/metadata.c src/metadata.h |
diffstat | 2 files changed, 48 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/metadata.c Sat Aug 01 22:37:37 2009 +0000 +++ b/src/metadata.c Sat Aug 01 22:37:57 2009 +0000 @@ -659,6 +659,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); @@ -666,7 +669,7 @@ while (list) { gchar *haystack = list->data; - + if (haystack) { gboolean equal; @@ -681,14 +684,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') @@ -719,7 +761,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); @@ -1168,7 +1210,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); } @@ -1190,7 +1232,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) {
--- 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);