X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fwordsplit.c;h=2e50edc16dfd04ce132a08d79890f3b88f5bd88c;hb=f1e59f17c216849d1988d874e7fd945c2cd68e5a;hp=6e2e792edd71b9ed62989c6cb7c7aefe4613f661;hpb=49ed04e2e93a6a5b01058638224621d5c07db01c;p=libucw.git diff --git a/lib/wordsplit.c b/lib/wordsplit.c index 6e2e792e..2e50edc1 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,8 +11,26 @@ #include "lib/lib.h" #include "lib/chartype.h" +#include + +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;