Browse Source

Ticket #3220: fix directory comparision in panelized panel.

Directory comparision expects only file names in both panels.
In panelized panel, files named can contain paths:

| boxes.c   | 43220|| 1/boxes.c   | 43220|
| boxes.h   | 1429 || 1/boxes.h   |  1429|
|           |      || boxes.c     | 43220|
|           |      || boxes.h     |  1429|

Even if boxes.c and 1/boxes.c files are the same, they are marked as
different because strings "boxes.c" and "1/boxes.c" are different.

The solution: for panelized panel, ignore path and use file name only
(like output of basename(3)) for comparision.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 2 years ago
parent
commit
a72ede698e
1 changed files with 15 additions and 2 deletions
  1. 15 2
      src/filemanager/cmd.c

+ 15 - 2
src/filemanager/cmd.c

@@ -230,7 +230,7 @@ compare_files (const vfs_path_t * vpath1, const vfs_path_t * vpath2, off_t size)
 /* --------------------------------------------------------------------------------------------- */
 /* --------------------------------------------------------------------------------------------- */
 
 
 static void
 static void
-compare_dir (WPanel * panel, WPanel * other, enum CompareMode mode)
+compare_dir (WPanel * panel, const WPanel * other, enum CompareMode mode)
 {
 {
     int i, j;
     int i, j;
 
 
@@ -243,6 +243,7 @@ compare_dir (WPanel * panel, WPanel * other, enum CompareMode mode)
     for (i = 0; i < panel->dir.len; i++)
     for (i = 0; i < panel->dir.len; i++)
     {
     {
         file_entry_t *source = &panel->dir.list[i];
         file_entry_t *source = &panel->dir.list[i];
+        const char *source_fname;
 
 
         /* Default: unmarked */
         /* Default: unmarked */
         file_mark (panel, i, 0);
         file_mark (panel, i, 0);
@@ -251,10 +252,22 @@ compare_dir (WPanel * panel, WPanel * other, enum CompareMode mode)
         if (S_ISDIR (source->st.st_mode))
         if (S_ISDIR (source->st.st_mode))
             continue;
             continue;
 
 
+        source_fname = source->fname->str;
+        if (panel->is_panelized)
+            source_fname = x_basename (source_fname);
+
         /* Search the corresponding entry from the other panel */
         /* Search the corresponding entry from the other panel */
         for (j = 0; j < other->dir.len; j++)
         for (j = 0; j < other->dir.len; j++)
-            if (g_string_equal (source->fname, other->dir.list[j].fname))
+        {
+            const char *other_fname;
+
+            other_fname = other->dir.list[j].fname->str;
+            if (other->is_panelized)
+                other_fname = x_basename (other_fname);
+
+            if (strcmp (source_fname, other_fname) == 0)
                 break;
                 break;
+        }
 
 
         if (j >= other->dir.len)
         if (j >= other->dir.len)
             /* Not found -> mark */
             /* Not found -> mark */