diff options
author | Jeremy Allison <jra@samba.org> | 2015-07-15 10:43:56 -0700 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2015-08-03 17:53:33 +0200 |
commit | 516f518aa736d1f53c2e35c421f16f5090d51796 (patch) | |
tree | 54a350e23902f9214d03ca70776c3c4cb55b5c0c | |
parent | e889ea33b03e2f88e285549793356f70930b53d8 (diff) | |
download | samba-516f518aa736d1f53c2e35c421f16f5090d51796.tar.gz |
lib: replace: Add strsep function (missing on Solaris).
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11359
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ira Cooper <ira@wakeful.net>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Jul 29 02:24:55 CEST 2015 on sn-devel-104
(cherry picked from commit f07b746ad3f3ee2fcbb65a0d452ed80f07c9e8f9)
-rw-r--r-- | lib/replace/replace.c | 20 | ||||
-rw-r--r-- | lib/replace/replace.h | 5 | ||||
-rw-r--r-- | lib/replace/wscript | 4 |
3 files changed, 27 insertions, 2 deletions
diff --git a/lib/replace/replace.c b/lib/replace/replace.c index 37edb310c59..488da0a5ec3 100644 --- a/lib/replace/replace.c +++ b/lib/replace/replace.c @@ -467,6 +467,26 @@ char *rep_strcasestr(const char *haystack, const char *needle) } #endif +#ifndef HAVE_STRSEP +char *rep_strsep(char **pps, const char *delim) +{ + char *ret = *pps; + char *p = *pps; + + if (p == NULL) { + return NULL; + } + p += strcspn(p, delim); + if (*p == '\0') { + *pps = NULL; + } else { + *p = '\0'; + *pps = p + 1; + } + return ret; +} +#endif + #ifndef HAVE_STRTOK_R /* based on GLIBC version, copyright Free Software Foundation */ char *rep_strtok_r(char *s, const char *delim, char **save_ptr) diff --git a/lib/replace/replace.h b/lib/replace/replace.h index cd0c25e2af7..57163a98afd 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -345,6 +345,11 @@ void rep_setlinebuf(FILE *); char *rep_strcasestr(const char *haystack, const char *needle); #endif +#ifndef HAVE_STRSEP +#define strsep rep_strsep +char *rep_strsep(char **pps, const char *delim); +#endif + #ifndef HAVE_STRTOK_R #define strtok_r rep_strtok_r char *rep_strtok_r(char *s, const char *delim, char **save_ptr); diff --git a/lib/replace/wscript b/lib/replace/wscript index f0040b18e02..27a8138d7e2 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -271,7 +271,7 @@ struct foo bar = { .y = 'X', .x = 1 }; conf.CHECK_FUNCS('lstat getpgrp utime utimes setuid seteuid setreuid setresuid setgid setegid') conf.CHECK_FUNCS('setregid setresgid chroot strerror vsyslog setlinebuf mktime') conf.CHECK_FUNCS('ftruncate chsize rename waitpid wait4') - conf.CHECK_FUNCS('initgroups pread pwrite strndup strcasestr') + conf.CHECK_FUNCS('initgroups pread pwrite strndup strcasestr strsep') conf.CHECK_FUNCS('strtok_r mkdtemp dup2 dprintf vdprintf isatty chown lchown') conf.CHECK_FUNCS('link readlink symlink realpath snprintf vsnprintf') conf.CHECK_FUNCS('asprintf vasprintf setenv unsetenv strnlen strtoull __strtoull') @@ -605,7 +605,7 @@ REPLACEMENT_FUNCTIONS = { 'memmove', 'strdup', 'setlinebuf', 'vsyslog', 'strnlen', 'strndup', 'waitpid', 'seteuid', 'setegid', 'chroot', 'mkstemp', 'mkdtemp', 'pread', 'pwrite', 'strcasestr', - 'strtok_r', 'strtoll', 'strtoull', 'setenv', 'unsetenv', + 'strsep', 'strtok_r', 'strtoll', 'strtoull', 'setenv', 'unsetenv', 'utime', 'utimes', 'dup2', 'chown', 'link', 'readlink', 'symlink', 'lchown', 'realpath', 'memmem', 'vdprintf', 'dprintf', 'get_current_dir_name', |