diff options
author | Andrew Tridgell <tridge@samba.org> | 2006-05-25 02:09:00 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:08:36 -0500 |
commit | 01b8c1913d75a9b74a1a4bf3e7d8a80f18db0b2d (patch) | |
tree | 10babe657e78ae06690b408b6e0f8514a9e9fbc8 /source4 | |
parent | 26875d59ba6d5d6fb9ac75f461953e0ebee6a8f3 (diff) | |
download | samba-01b8c1913d75a9b74a1a4bf3e7d8a80f18db0b2d.tar.gz samba-01b8c1913d75a9b74a1a4bf3e7d8a80f18db0b2d.tar.bz2 samba-01b8c1913d75a9b74a1a4bf3e7d8a80f18db0b2d.zip |
r15879: strtok_r() replacement, for solaris
(This used to be commit df5bd916db3cfbd6c145177fd8992261f03a5cbc)
Diffstat (limited to 'source4')
-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 |