/*
* Sherlock Library -- Word Splitting
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
+ *
+ * This software may be freely distributed and used according to the terms
+ * of the GNU Lesser General Public License.
*/
-#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(;;)
{
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;
}