jpeg pushed a commit to branch efl-1.13.

http://git.enlightenment.org/core/efl.git/commit/?id=e55a3f1af84f9abd1b2ea89ef4ade90378bf9278

commit e55a3f1af84f9abd1b2ea89ef4ade90378bf9278
Author: Vincent Torri <vincent.to...@gmail.com>
Date:   Wed Apr 29 07:52:31 2015 +0200

    Eina: fix eina_file_split on Windows and update unit test
    
    @fix
    
    Signed-off-by: Jean-Philippe Andre <jp.an...@samsung.com>
---
 src/lib/eina/eina_file_win32.c  | 41 ++++++++++++++++++++---------------------
 src/tests/eina/eina_test_file.c |  4 ++--
 2 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/src/lib/eina/eina_file_win32.c b/src/lib/eina/eina_file_win32.c
index 01d0c9f..c912ce3 100644
--- a/src/lib/eina/eina_file_win32.c
+++ b/src/lib/eina/eina_file_win32.c
@@ -387,6 +387,16 @@ _eina_file_map_close(Eina_File_Map *map)
    free(map);
 }
 
+static char *
+_eina_file_sep_find(char *s)
+{
+   for (; *s != '\0'; ++s)
+     if ((*s == '\\') || (*s == '/'))
+       return s;
+
+   return NULL;
+}
+
 /**
  * @endcond
  */
@@ -521,28 +531,17 @@ eina_file_split(char *path)
    if (!ea)
       return NULL;
 
-   current = path;
-   while (*current)
+   for (current = _eina_file_sep_find(path);
+        current;
+        path = current + 1, current = _eina_file_sep_find(path))
      {
-        if ((*current == '\\') || (*current == '/'))
-          {
-             if (((*current == '\\') && (current[1] == '\\')) ||
-                 ((*current == '/') && (current[1] == '/')))
-               {
-                  *current = '\0';
-                  goto next_char;
-               }
-
-             length = current - path;
-             if (length <= 0)
-               goto next_char;
-
-             eina_array_push(ea, path);
-             *current = '\0';
-             path = current + 1;
-          }
-     next_char:
-        current++;
+        length = current - path;
+
+        if (length <= 0)
+           continue;
+
+        eina_array_push(ea, path);
+        *current = '\0';
      }
 
    if (*path != '\0')
diff --git a/src/tests/eina/eina_test_file.c b/src/tests/eina/eina_test_file.c
index 8dc123a..c9ac36f 100644
--- a/src/tests/eina/eina_test_file.c
+++ b/src/tests/eina/eina_test_file.c
@@ -101,7 +101,7 @@ START_TEST(eina_file_split_simple)
 #endif
 
 #ifdef _WIN32
-   ea = eina_file_split(strdup("\\this\\is\\a\\small\\test"));
+   ea = eina_file_split(strdup("\\this/is\\a/small/test"));
 #else
    ea = eina_file_split(strdup("/this/is/a/small/test"));
 #endif
@@ -119,7 +119,7 @@ START_TEST(eina_file_split_simple)
 #ifdef _WIN32
    ea =
       eina_file_split(strdup(
-                         "this\\\\is\\\\\\a \\more\\complex\\\\\\case\\\\\\"));
+                         "this\\/\\is\\//\\\\a 
\\more/\\complex///case\\\\\\"));
 #else
    ea = eina_file_split(strdup("this//is///a /more/complex///case///"));
 #endif

-- 


Reply via email to