diff options
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/replace/config.m4 | 2 | ||||
-rw-r--r-- | source4/lib/replace/replace.c | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index aec9f5805c..2cee65e6a6 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -48,7 +48,7 @@ AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(timegm setenv vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strnlen strlcpy strlcat innetgr initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite strndup strcasestr) +AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r) AC_HAVE_DECL(setresuid, [#include <unistd.h>]) AC_HAVE_DECL(setresgid, [#include <unistd.h>]) AC_HAVE_DECL(errno, [#include <errno.h>]) 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 |