Compare paths using utf8_collate_key() since paths are utf8-encoded.
authorLaurent Monin <geeqie@norz.org>
Thu, 5 Jun 2008 09:24:42 +0000 (09:24 +0000)
committerLaurent Monin <geeqie@norz.org>
Thu, 5 Jun 2008 09:24:42 +0000 (09:24 +0000)
It fixes bug 1959854.

src/collect.c
src/dupe.c
src/main.c
src/main.h
src/search.c

index 62af952..a37a9bc 100644 (file)
@@ -148,7 +148,7 @@ static gint collection_list_sort_cb(gconstpointer a, gconstpointer b)
                        return 0;
                        break;
                case SORT_PATH:
-                       return CASE_SORT(cia->fd->path, cib->fd->path); /* FIXME: utf8_collate */
+                       return utf8_compare(cia->fd->path, cib->fd->path, options->file_sort.case_sensitive);
                        break;
 #ifdef HAVE_STRVERSCMP
                case SORT_NUMBER:
index 85c266e..4694e96 100644 (file)
@@ -1128,7 +1128,7 @@ static gint dupe_match(DupeItem *a, DupeItem *b, DupeMatchType mask, gdouble *ra
 
        if (mask & DUPE_MATCH_PATH)
                {
-               if (strcmp(a->fd->path, b->fd->path) != 0) return FALSE;
+               if (utf8_compare(a->fd->path, b->fd->path, TRUE) != 0) return FALSE;
                }
        if (mask & DUPE_MATCH_NAME)
                {
index cfc561c..034383c 100644 (file)
@@ -65,6 +65,38 @@ gchar *utf8_validate_or_convert(const gchar *text)
        return g_strdup(text);
 }
 
+gint utf8_compare(const gchar *s1, const gchar *s2, gboolean case_sensitive)
+{
+       gchar *s1_key, *s2_key;
+       gchar *s1_t, *s2_t;
+       gint ret;
+
+       g_assert(g_utf8_validate(s1, -1, NULL));
+       g_assert(g_utf8_validate(s2, -1, NULL));
+
+       if (!case_sensitive)
+               {
+               s1_t = g_utf8_casefold(s1, -1); 
+               s2_t = g_utf8_casefold(s2, -1);
+               }
+
+       s1_key = g_utf8_collate_key(s1_t, -1);
+       s2_key = g_utf8_collate_key(s2_t, -1);
+
+       ret = strcmp(s1_key, s2_key);
+
+       g_free(s1_key);
+       g_free(s2_key);
+
+       if (!case_sensitive)
+               {
+               g_free(s1_t);
+               g_free(s2_t);
+               }
+
+       return ret;
+}
+
 /* Borrowed from gtkfilesystemunix.c */
 gchar *expand_tilde(const gchar *filename)
 {
index c784bc2..560ad8f 100644 (file)
 
 gdouble get_zoom_increment(void);
 gchar *utf8_validate_or_convert(const gchar *text);
+gint utf8_compare(const gchar *s1, const gchar *s2, gboolean case_sensitive);
 gchar *expand_tilde(const gchar *filename);
 
 void keyboard_scroll_calc(gint *x, gint *y, GdkEventKey *event);
index 304fc45..7f9ec62 100644 (file)
@@ -2253,7 +2253,7 @@ static gint search_result_sort_cb(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIt
                        return sort_matchdata_dimensions(fda, fdb);
                        break;
                case SEARCH_COLUMN_PATH:
-                       return CASE_SORT(fda->fd->path, fdb->fd->path); /* FIXME: utf8_collate */
+                       return utf8_compare(fda->fd->path, fdb->fd->path, options->file_sort.case_sensitive);
                        break;
                default:
                        break;