summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/strlib.c33
-rw-r--r--src/common/strlib.h5
2 files changed, 38 insertions, 0 deletions
diff --git a/src/common/strlib.c b/src/common/strlib.c
index 361c693c1..bd2b928c0 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -136,3 +136,36 @@ char *trim(char *str, const char *delim)
strcpy(str,buf);
return str;
}
+
+#ifdef _WIN32
+char *athena_strtok_r (char *s, const char *delim, char **save_ptr)
+{
+ char *token;
+
+ if (s == NULL)
+ s = *save_ptr;
+
+ /* Scan leading delimiters. */
+ s += strspn (s, delim);
+ if (*s == '\0')
+ {
+ *save_ptr = s;
+ return NULL;
+ }
+
+ /* Find the end of the token. */
+ token = s;
+ s = strpbrk (token, delim);
+ if (s == NULL)
+ /* This token finishes the string. */
+ /* *save_ptr = __rawmemchr (token, '\0'); */
+ *save_ptr = token + strlen (token);
+ else
+ {
+ /* Terminate the token and make *SAVE_PTR point past it. */
+ *s = '\0';
+ *save_ptr = s + 1;
+ }
+ return token;
+}
+#endif
diff --git a/src/common/strlib.h b/src/common/strlib.h
index f4ee7074b..038eea1c6 100644
--- a/src/common/strlib.h
+++ b/src/common/strlib.h
@@ -11,6 +11,11 @@ char* jstrescape (char* pt);
char* jstrescapecpy (char* pt,char* spt);
int jmemescapecpy (char* pt,char* spt, int size);
+#if !defined(HAVE_mit_thread) && !defined(HAVE_STRTOK_R)
+#define strtok_r(s,delim,save_ptr) athena_strtok_r(s,delim,save_ptr)
+char *athena_strtok_r (char *s, const char *delim, char **save_ptr);
+#endif
+
// custom functions
int remove_control_chars(unsigned char *);
char *trim(char *str, const char *delim);