]> mj.ucw.cz Git - libucw.git/blobdiff - lib/wordsplit.c
Initial version of SQL gathering utility gsql added.
[libucw.git] / lib / wordsplit.c
index b1b2ada3fd58e8f1c38fc88ef1dc4ab3e9cc5f2b..b07b4309c231b4df5ede157493e58cb9020d27ee 100644 (file)
@@ -1,18 +1,16 @@
 /*
  *     Sherlock Library -- Word Splitting
  *
- *     (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ *     (c) 1997 Martin Mares <mj@ucw.cz>
  */
 
-#include <stdio.h>
-
-#include "lib.h"
-#include "string.h"
+#include "lib/lib.h"
+#include "lib/chartype.h"
 
 int
 wordsplit(byte *src, byte **dst, uns max)
 {
-  int cnt = 0;
+  uns cnt = 0;
 
   for(;;)
     {
@@ -22,9 +20,21 @@ wordsplit(byte *src, byte **dst, uns max)
        break;
       if (cnt >= max)
        return -1;
-      dst[cnt++] = src;
-      while (*src && !Cspace(*src))
-       src++;
+      if (*src == '"')
+       {
+         src++;
+         dst[cnt++] = src;
+         while (*src && *src != '"')
+           src++;
+         if (*src)
+           *src++ = 0;
+       }
+      else
+       {
+         dst[cnt++] = src;
+         while (*src && !Cspace(*src))
+           src++;
+       }
     }
   return cnt;
 }