Revision: 1815
          http://geeqie.svn.sourceforge.net/geeqie/?rev=1815&view=rev
Author:   mow
Date:     2009-08-01 22:37:57 +0000 (Sat, 01 Aug 2009)

Log Message:
-----------
Fix a small problem with casefull keywords

In @1636 I miss one check for keyword case. Now it should be all fixed.

Modified Paths:
--------------
    trunk/src/metadata.c
    trunk/src/metadata.h

Modified: trunk/src/metadata.c
===================================================================
--- trunk/src/metadata.c        2009-08-01 22:37:37 UTC (rev 1814)
+++ trunk/src/metadata.c        2009-08-01 22:37:57 UTC (rev 1815)
@@ -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,15 +684,54 @@
                                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')
 
 GList *string_to_keywords_list(const gchar *text)
@@ -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)
                {

Modified: trunk/src/metadata.h
===================================================================
--- trunk/src/metadata.h        2009-08-01 22:37:37 UTC (rev 1814)
+++ trunk/src/metadata.h        2009-08-01 22:37:57 UTC (rev 1815)
@@ -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);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn

Reply via email to