lib: Move next_token next to next_token_talloc
authorVolker Lendecke <vl@samba.org>
Wed, 9 Mar 2011 15:34:49 +0000 (16:34 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 13 Apr 2011 21:13:25 +0000 (14:13 -0700)
Signed-off-by: Jeremy Allison <jra@samba.org>
lib/util/charset/util_unistr.c
lib/util/util.c

index 6737256a95713c5b162318a10cfe559b0312f942..ddb15f88f9351e97b7f21a2dbe6d0e8e791829d8 100644 (file)
 #include "includes.h"
 #include "system/locale.h"
 
-/**
- * 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;
-}
-
-
 /**
  String replace.
  NOTE: oldc and newc must be 7 bit characters
index 35ad49b5323870ab309c2506b321a12f31a34937..d4a936fae9fe1b2eaab3d51f8da5dab26b22e412 100644 (file)
@@ -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;