From 0e76fe7560d19e696d2083ed2345b25cb77ddb14 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 9 Mar 2011 16:34:49 +0100 Subject: [PATCH] lib: Move next_token next to next_token_talloc Signed-off-by: Jeremy Allison (cherry picked from commit c932faed8a61053fcfb63bc9915baa4bfa2678d4) --- lib/util/charset/util_unistr.c | 46 ------------------------------------------ lib/util/util.c | 46 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c index b6bfb29e7dc..760be7769a8 100644 --- a/lib/util/charset/util_unistr.c +++ b/lib/util/charset/util_unistr.c @@ -61,52 +61,6 @@ _PUBLIC_ int strcasecmp_m(const char *s1, const char *s2) } /** - * Get the next token from a string, return False if none found. - * Handles double-quotes. - * - * Based on a routine by GJC@VILLAGE.COM. - * Extensively modified by Andrew.Tridgell@anu.edu.au - **/ -_PUBLIC_ bool next_token(const char **ptr,char *buff, const char *sep, size_t bufsize) -{ - const char *s; - bool quoted; - size_t len=1; - - if (!ptr) - return false; - - s = *ptr; - - /* default to simple separators */ - if (!sep) - sep = " \t\n\r"; - - /* find the first non sep char */ - while (*s && strchr_m(sep,*s)) - s++; - - /* nothing left? */ - if (!*s) - return false; - - /* copy over the token */ - for (quoted = false; len < bufsize && *s && (quoted || !strchr_m(sep,*s)); s++) { - if (*s == '\"') { - quoted = !quoted; - } else { - len++; - *buff++ = *s; - } - } - - *ptr = (*s) ? s+1 : s; - *buff = 0; - - return true; -} - -/** Case insensitive string compararison, length limited **/ _PUBLIC_ int strncasecmp_m(const char *s1, const char *s2, size_t n) diff --git a/lib/util/util.c b/lib/util/util.c index 35ad49b5323..d4a936fae9f 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -936,6 +936,52 @@ bool next_token_no_ltrim_talloc(TALLOC_CTX *ctx, return next_token_internal_talloc(ctx, ptr, pp_buff, sep, false); } +/** + * Get the next token from a string, return False if none found. + * Handles double-quotes. + * + * Based on a routine by GJC@VILLAGE.COM. + * Extensively modified by Andrew.Tridgell@anu.edu.au + **/ +_PUBLIC_ bool next_token(const char **ptr,char *buff, const char *sep, size_t bufsize) +{ + const char *s; + bool quoted; + size_t len=1; + + if (!ptr) + return false; + + s = *ptr; + + /* default to simple separators */ + if (!sep) + sep = " \t\n\r"; + + /* find the first non sep char */ + while (*s && strchr_m(sep,*s)) + s++; + + /* nothing left? */ + if (!*s) + return false; + + /* copy over the token */ + for (quoted = false; len < bufsize && *s && (quoted || !strchr_m(sep,*s)); s++) { + if (*s == '\"') { + quoted = !quoted; + } else { + len++; + *buff++ = *s; + } + } + + *ptr = (*s) ? s+1 : s; + *buff = 0; + + return true; +} + struct anonymous_shared_header { union { size_t length; -- 2.11.4.GIT