X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fwordsplit.c;h=2e50edc16dfd04ce132a08d79890f3b88f5bd88c;hb=1f71ba3ef3df61706d7aee1ffa981cf6fdee7c4e;hp=e79812d18a7bd352ed3bb6a045fdf98745abbd29;hpb=5b53087fa5a07ff89d34cf3bf3bc1b28809f05c2;p=libucw.git diff --git a/lib/wordsplit.c b/lib/wordsplit.c index e79812d1..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 + +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;