]> mj.ucw.cz Git - libucw.git/blob - lib/wordsplit.c
b1b2ada3fd58e8f1c38fc88ef1dc4ab3e9cc5f2b
[libucw.git] / lib / wordsplit.c
1 /*
2  *      Sherlock Library -- Word Splitting
3  *
4  *      (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
5  */
6
7 #include <stdio.h>
8
9 #include "lib.h"
10 #include "string.h"
11
12 int
13 wordsplit(byte *src, byte **dst, uns max)
14 {
15   int cnt = 0;
16
17   for(;;)
18     {
19       while (Cspace(*src))
20         *src++ = 0;
21       if (!*src)
22         break;
23       if (cnt >= max)
24         return -1;
25       dst[cnt++] = src;
26       while (*src && !Cspace(*src))
27         src++;
28     }
29   return cnt;
30 }