X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fwordsplit.c;h=6e2e792edd71b9ed62989c6cb7c7aefe4613f661;hb=8e980d3d2841276a15dea2dfe4f7cd2b62e5a7dc;hp=b1b2ada3fd58e8f1c38fc88ef1dc4ab3e9cc5f2b;hpb=03846211ba84582b133a985200502a39462dfe66;p=libucw.git diff --git a/lib/wordsplit.c b/lib/wordsplit.c index b1b2ada3..6e2e792e 100644 --- a/lib/wordsplit.c +++ b/lib/wordsplit.c @@ -1,18 +1,19 @@ /* * Sherlock Library -- Word Splitting * - * (c) 1997 Martin Mares, + * (c) 1997 Martin Mares + * + * This software may be freely distributed and used according to the terms + * of the GNU Lesser General Public License. */ -#include - -#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 +23,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; }