diff options
author | kwolekr <mirrorisim@gmail.com> | 2013-01-23 02:21:26 -0500 |
---|---|---|
committer | kwolekr <mirrorisim@gmail.com> | 2013-01-23 16:28:15 -0500 |
commit | 69ba4854152415ab3e2ec11cdb6f9c9ce5af9ac8 (patch) | |
tree | c52f6fc20df7c46c3f74ed8610399e6ed82d0822 /src/util | |
parent | 035933f806d3afc45e2e558e505318489209a70b (diff) | |
download | minetest-69ba4854152415ab3e2ec11cdb6f9c9ce5af9ac8.tar.gz minetest-69ba4854152415ab3e2ec11cdb6f9c9ce5af9ac8.tar.bz2 minetest-69ba4854152415ab3e2ec11cdb6f9c9ce5af9ac8.zip |
Fix compile under MingW
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/string.cpp | 30 | ||||
-rw-r--r-- | src/util/string.h | 1 |
2 files changed, 31 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; +} diff --git a/src/util/string.h b/src/util/string.h index 58274c677..d081b365b 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -283,6 +283,7 @@ inline std::string wrap_rows(const std::string &from, u32 rowlen) std::string translatePassword(std::string playername, std::wstring password); size_t curl_write_data(char *ptr, size_t size, size_t nmemb, void *userdata); +char *mystrtok_r(char *s, const char *sep, char **lasts); #endif |