X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fwordsplit.c;h=d13f21087792fe8774a56be483dafdc678635924;hb=d047dae8f369ac5cbc3dedf8907b2c05694bb892;hp=6e2e792edd71b9ed62989c6cb7c7aefe4613f661;hpb=49ed04e2e93a6a5b01058638224621d5c07db01c;p=libucw.git diff --git a/lib/wordsplit.c b/lib/wordsplit.c index 6e2e792e..d13f2108 100644 --- a/lib/wordsplit.c +++ b/lib/wordsplit.c @@ -1,7 +1,8 @@ /* - * Sherlock Library -- Word Splitting + * UCW Library -- Word Splitting * * (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. @@ -10,6 +11,24 @@ #include "lib/lib.h" #include "lib/chartype.h" +#include + +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) {