This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efm2.

View the commit online.

commit a65f58be4216df708026c895cdff47ed7c586079
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Tue Sep 5 14:46:43 2023 +0100

    sanitize path to be consistent
---
 src/backends/default/meta.c |  1 +
 src/efm/efm.c               | 41 +++++++++++++++++++++++++++++++++++++++--
 src/efm/efm_dnd.c           |  5 +++--
 3 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/src/backends/default/meta.c b/src/backends/default/meta.c
index e68d15b..f037050 100644
--- a/src/backends/default/meta.c
+++ b/src/backends/default/meta.c
@@ -301,6 +301,7 @@ meta_set(const char *path, const char *meta, const char *data)
    Meta *m;
 
    if (!mf) return;
+
    EINA_LIST_FOREACH(mf->list, l, m)
      {
         if (!strcmp(m->meta, meta))
diff --git a/src/efm/efm.c b/src/efm/efm.c
index e00b1e6..8600518 100644
--- a/src/efm/efm.c
+++ b/src/efm/efm.c
@@ -1605,14 +1605,51 @@ efm_detail_header_get(Evas_Object *obj)
 }
 
 ////////
+static char *
+_sanitize_dir(const char *path)
+{ // sanitize path to remove multiple / chars like //usr/bin or /usr///bin
+   const char *p, *pp;
+   char *path2, *p2;
+
+   if (!path) return NULL;
+   path2 = malloc(strlen(path) + 2);
+   for (pp = NULL, p2 = path2, p = path; *p;)
+     {
+        if ((pp) && (*p == '/') && (*pp == '/'))
+          {
+             pp = p;
+             p++;
+          }
+        else
+          {
+             *p2 = *p;
+             pp = p;
+             p2++;
+             p++;
+          }
+     }
+   if ((pp) && (*pp != '/'))
+     {
+        *p2 = '/';
+        p2++;
+     }
+   *p2 = 0;
+   return path2;
+}
+
 void
 efm_path_set(Evas_Object *obj, const char *path)
 {
+   char *path_sane;
    ENTRY;
 
-   if ((sd->path) && (path) && (!strcmp(sd->path, path))) return;
-   eina_stringshare_replace(&(sd->path), path);
+   path_sane = _sanitize_dir(path);
+   if (!path_sane) return;
+   if ((sd->path) && (!strcmp(sd->path, path_sane))) goto done;
+   eina_stringshare_replace(&(sd->path), path_sane);
    _reset(sd);
+done:
+   free(path_sane);
 }
 
 const char *
diff --git a/src/efm/efm_dnd.c b/src/efm/efm_dnd.c
index 7e2d486..bff564f 100644
--- a/src/efm/efm_dnd.c
+++ b/src/efm/efm_dnd.c
@@ -152,7 +152,7 @@ _cb_drop(void *data, Evas_Object *o EINA_UNUSED, Elm_Selection_Data *ev)
                     {
                        if ((icon->sd == sd) && (icon->drag))
                          {
-                            printf("    dropicon is %s/%s\n", icon->sd->path, icon->info.file);
+                            printf("    dropicon is %s%s\n", icon->sd->path, icon->info.file);
                             delta_x = icon->sd->dnd_x - icon->down_rel_x - icon->geom.x;
                             delta_y = icon->sd->dnd_y - icon->down_rel_y - icon->geom.y;
                             icon->drag = EINA_FALSE;
@@ -192,8 +192,9 @@ _cb_drop(void *data, Evas_Object *o EINA_UNUSED, Elm_Selection_Data *ev)
                               }
                             printf("XXX: ->     DROPICON: [%s]  %i   %i\n", icon->info.file, icon->geom.x, icon->geom.y);
                             buf = cmd_strbuf_new("meta-set");
+                            // sd->path always ends in /
                             // XXX: use strbuf for str
-                            snprintf(str, sizeof(str), "%s/%s", icon->sd->path, icon->info.file);
+                            snprintf(str, sizeof(str), "%s%s", icon->sd->path, icon->info.file);
                             cmd_strbuf_append(buf, "path", str);
                             snprintf(str, sizeof(str), "%i,%i",
                                      (int)(icon->geom.x / _scale_get(icon->sd)),

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to