X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fwordsplit.c;h=d13f21087792fe8774a56be483dafdc678635924;hb=1e346d26a03735f09bba33ddbaba4cc9b268d381;hp=eea9476230166816e39b152ec79d8925df7593d7;hpb=b65c2563a8a425593f91dfcb82ede8cf53fec6cd;p=libucw.git diff --git a/lib/wordsplit.c b/lib/wordsplit.c index eea94762..d13f2108 100644 --- a/lib/wordsplit.c +++ b/lib/wordsplit.c @@ -1,18 +1,38 @@ /* - * 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(byte *str, byte sep, byte **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) { - int cnt = 0; + uns cnt = 0; for(;;) {