summaryrefslogtreecommitdiff
path: root/source4/lib/replace/replace.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/replace/replace.c')
-rw-r--r--source4/lib/replace/replace.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c
index f72394cb0f..38a3d517df 100644
--- a/source4/lib/replace/replace.c
+++ b/source4/lib/replace/replace.c
@@ -549,3 +549,30 @@ char *strcasestr(const char *haystack, const char *needle)
return NULL;
}
#endif
+
+#ifndef HAVE_STRTOK_R
+/* based on GLIBC version, copyright Free Software Foundation */
+char *strtok_r(char *s, const char *delim, char **save_ptr)
+{
+ char *token;
+
+ if (s == NULL) s = *save_ptr;
+
+ s += strspn(s, delim);
+ if (*s == '\0') {
+ *save_ptr = s;
+ return NULL;
+ }
+
+ token = s;
+ s = strpbrk(token, delim);
+ if (s == NULL) {
+ *save_ptr = token + strlen(token);
+ } else {
+ *s = '\0';
+ *save_ptr = s + 1;
+ }
+
+ return token;
+}
+#endif