From 69ba4854152415ab3e2ec11cdb6f9c9ce5af9ac8 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Wed, 23 Jan 2013 02:21:26 -0500 Subject: Fix compile under MingW --- src/util/string.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/util/string.cpp') diff --git a/src/util/string.cpp b/src/util/string.cpp index 215ac299d..481e74dad 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -47,3 +47,33 @@ size_t curl_write_data(char *ptr, size_t size, size_t nmemb, void *userdata) { stream->write(ptr, count); return count; } + +char *mystrtok_r(char *s, const char *sep, char **lasts) { + char *t; + int delim_reached; + + if (!s) + s = *lasts; + + while (*s && strchr(sep, *s)) + s++; + + if (!*s) + return NULL; + + delim_reached = 0; + t = s; + while (*t) { + if (strchr(sep, *t)) { + *t = '\0'; + delim_reached = 1; + } else if (delim_reached) { + *lasts = t; + return s; + } + t++; + } + + *lasts = t; + return s; +} -- cgit v1.2.3