From e9a1e8ea77f030243fdba0f4f4f91aba57691a83 Mon Sep 17 00:00:00 2001
From: chris <chris@indefini.org>
Date: Thu, 20 Jun 2013 18:07:53 +0900
Subject: [PATCH 3/3] Evil: added strsep function. Evas: fix problem with
 dllimport

---
 ChangeLog                            |  4 ++++
 NEWS                                 |  1 +
 src/lib/evas/Evas_Eo.h               | 16 +++++++++++++
 src/lib/evas/canvas/evas_callbacks.c | 16 +++++++++++++
 src/lib/evil/evil_string.c           | 45 ++++++++++++++++++++++++++++++++++++
 src/lib/evil/evil_string.h           | 26 ++++++++++++++++++---
 6 files changed, 105 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 255a5fb..ab6beb2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-06-20  Christophe Sadoine
+
+	* Evil: Added strsep function.
+
 2013-06-19  Christophe Sadoine
 
 	* Evil: Added evil_rename function, a wrapper around rename().
diff --git a/NEWS b/NEWS
index 894396d..5639d5a 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ Additions:
     * Evil:
      - Add mkdtemp.
      - Add evil_rename() a wrapper for rename().
+     - Add strsep().
     * eina:
      - Add DOCTYPE children parsing in eina_simple_xml
      - Add eina_barrier thread API
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h
index 9a2fa92..6ea3298 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -1,5 +1,21 @@
 #include <Eo.h>
 
+#ifdef _WIN32
+# ifdef EAPI
+#  undef EAPI
+# endif
+# ifdef EFL_EVAS_BUILD
+#  ifdef DLL_EXPORT
+#   define EAPI __declspec(dllexport)
+#  else
+#   define EAPI
+#  endif /* ! DLL_EXPORT */
+# else
+#  define EAPI
+# endif /* ! EFL_EVAS_BUILD */
+#else
+#endif /* ! _WIN32 */
+
 EAPI extern const Eo_Event_Description _EVAS_OBJECT_EVENT_MOUSE_IN;
 EAPI extern const Eo_Event_Description _EVAS_OBJECT_EVENT_MOUSE_OUT;
 EAPI extern const Eo_Event_Description _EVAS_OBJECT_EVENT_MOUSE_DOWN;
diff --git a/src/lib/evas/canvas/evas_callbacks.c b/src/lib/evas/canvas/evas_callbacks.c
index b85cc39..feb107b 100644
--- a/src/lib/evas/canvas/evas_callbacks.c
+++ b/src/lib/evas/canvas/evas_callbacks.c
@@ -1,6 +1,22 @@
 #include "evas_common.h"
 #include "evas_private.h"
 
+#ifdef _WIN32
+# ifdef EAPI
+#  undef EAPI
+# endif
+# ifdef EFL_EVAS_BUILD
+#  ifdef DLL_EXPORT
+#   define EAPI __declspec(dllexport)
+#  else
+#   define EAPI
+#  endif /* ! DLL_EXPORT */
+# else
+#  define EAPI
+# endif /* ! EFL_EVAS_BUILD */
+#else
+#endif /* ! _WIN32 */
+
 int _evas_event_counter = 0;
 
 EVAS_MEMPOOL(_mp_pc);
diff --git a/src/lib/evil/evil_string.c b/src/lib/evil/evil_string.c
index 491a880..c6d017a 100644
--- a/src/lib/evil/evil_string.c
+++ b/src/lib/evil/evil_string.c
@@ -127,3 +127,48 @@ char *strcasestr(const char *haystack, const char *needle)
 
    return NULL;
 }
+
+char *
+strsep (char **stringp, const char *delim)
+{
+  char *begin, *end;
+
+  begin = *stringp;
+  if (begin == NULL)
+    return NULL;
+
+  /* A frequent case is when the delimiter string contains only one
+     character.  Here we don't need to call the expensive `strpbrk'
+     function and instead work using `strchr'.  */
+  if (delim[0] == '\0' || delim[1] == '\0')
+    {
+      char ch = delim[0];
+
+      if (ch == '\0')
+        end = NULL;
+      else
+        {
+          if (*begin == ch)
+            end = begin;
+          else if (*begin == '\0')
+            end = NULL;
+          else
+            end = strchr (begin + 1, ch);
+        }
+    }
+  else
+    /* Find the end of the token.  */
+    end = strpbrk (begin, delim);
+
+  if (end)
+    {
+      /* Terminate the token and set *STRINGP past NUL character.  */
+      *end++ = '\0';
+      *stringp = end;
+    }
+  else
+    /* No more delimiters; this is the last token.  */
+    *stringp = NULL;
+
+  return begin;
+}
diff --git a/src/lib/evil/evil_string.h b/src/lib/evil/evil_string.h
index 45c9de3..14f49b1 100644
--- a/src/lib/evil/evil_string.h
+++ b/src/lib/evil/evil_string.h
@@ -144,10 +144,30 @@ EAPI int strcasecmp(const char *s1, const char *s2);
  */
 EAPI char *strcasestr(const char *haystack, const char *needle);
 
-
 /**
- * @}
- */
+ * @brief Implements the strsep function which is used to separate strings.
+ *
+ * @param stringp The pointer to the string to search in.
+ * @param delim The delimiter that contains characters used to find the next token.
+ * @return a pointer to the next token or NULL;
+ *
+ * The strsep() function locates, in the string referenced by *stringp, the
+ * first occurrence of any character in the string delim (or the terminating
+ * `\0' character) and replaces it with a `\0'.  The location of the next
+ * character after the delimiter character (or NULL, if the end of the
+ * string was reached) is stored in *stringp.  The original value of
+ * stringp is returned.
+ *
+ * An ``empty'' field (i.e., a character in the string delim occurs as the
+ * first character of *stringp) can be detected by comparing the location
+ * referenced by the returned pointer to `\0'.
 
+ * If *stringp is initially NULL, strsep() returns NULL.
+ *
+ * This function is from LibGW32C.
+ * @since 1.8
+ *
+ */
+EAPI char *strsep(char **stringp, const char *delim);
 
 #endif /* __EVIL_STRING_H__ */
-- 
1.8.1.msysgit.1

