X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fwordsplit.c;h=2e50edc16dfd04ce132a08d79890f3b88f5bd88c;hb=f1e59f17c216849d1988d874e7fd945c2cd68e5a;hp=fe657fc729387b0ce623b395f18e86f235caf442;hpb=ac9212c1d03bd23f6322bef39a4a0384b5afcc5d;p=libucw.git diff --git a/lib/wordsplit.c b/lib/wordsplit.c index fe657fc7..2e50edc1 100644 --- a/lib/wordsplit.c +++ b/lib/wordsplit.c @@ -1,16 +1,36 @@ /* - * Sherlock Library -- Word Splitting + * UCW Library -- Word Splitting * - * (c) 1997 Martin Mares, + * (c) 1997 Martin Mares + * (c) 2004 Robert Spalek + * + * This software may be freely distributed and used according to the terms + * of the GNU Lesser General Public License. */ -#include +#include "lib/lib.h" +#include "lib/chartype.h" + +#include -#include "lib.h" -#include "string.h" +int +sepsplit(char *str, uns sep, char **rec, uns max) +{ + uns cnt = 0; + while (1) + { + rec[cnt++] = str; + str = strchr(str, sep); + if (!str) + return cnt; + if (cnt >= max) + return -1; + *str++ = 0; + } +} int -wordsplit(byte *src, byte **dst, uns max) +wordsplit(char *src, char **dst, uns max) { uns cnt = 0;