summaryrefslogtreecommitdiff
path: root/src/util/string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/string.cpp')
-rw-r--r--src/util/string.cpp30
1 files changed, 30 insertions, 0 deletions
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;
+}