diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-06-27 15:28:55 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-06-27 15:28:55 -0400 |
commit | 9e592d1decf1b16128a716220de68322b51d6315 (patch) | |
tree | 064af78114c528fe06441067d9648e1dc5191c42 /src/common/compat.c | |
parent | 4d81f5211b3c714edae6370bccc6873033c0092d (diff) | |
download | tor-9e592d1decf1b16128a716220de68322b51d6315.tar.gz tor-9e592d1decf1b16128a716220de68322b51d6315.zip |
Move tor_strtok_r to libtor-string
Diffstat (limited to 'src/common/compat.c')
-rw-r--r-- | src/common/compat.c | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index 033ffa6aee..367ea26c27 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -177,56 +177,6 @@ tor_memmem(const void *_haystack, size_t hlen, #endif /* defined(HAVE_MEMMEM) && (!defined(__GNUC__) || __GNUC__ >= 2) */ } -/** Helper for tor_strtok_r_impl: Advances cp past all characters in - * <b>sep</b>, and returns its new value. */ -static char * -strtok_helper(char *cp, const char *sep) -{ - if (sep[1]) { - while (*cp && strchr(sep, *cp)) - ++cp; - } else { - while (*cp && *cp == *sep) - ++cp; - } - return cp; -} - -/** Implementation of strtok_r for platforms whose coders haven't figured out - * how to write one. Hey, retrograde libc developers! You can use this code - * here for free! */ -char * -tor_strtok_r_impl(char *str, const char *sep, char **lasts) -{ - char *cp, *start; - tor_assert(*sep); - if (str) { - str = strtok_helper(str, sep); - if (!*str) - return NULL; - start = cp = *lasts = str; - } else if (!*lasts || !**lasts) { - return NULL; - } else { - start = cp = *lasts; - } - - if (sep[1]) { - while (*cp && !strchr(sep, *cp)) - ++cp; - } else { - cp = strchr(cp, *sep); - } - - if (!cp || !*cp) { - *lasts = NULL; - } else { - *cp++ = '\0'; - *lasts = strtok_helper(cp, sep); - } - return start; -} - /** Represents a lockfile on which we hold the lock. */ struct tor_lockfile_t { /** Name of the file */ |