jpeg pushed a commit to branch master.

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

commit c086d505a9f0a311ed6e477117ec0e72502ad5e6
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 b515a68..8139cad 100644
--- a/src/lib/eina/eina_file_win32.c
+++ b/src/lib/eina/eina_file_win32.c
@@ -395,6 +395,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
  */
@@ -529,28 +539,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 38525bd..5fa4a68 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