From 4d8d2943da06f65f953549e10a59a59300f90959 Mon Sep 17 00:00:00 2001 From: Robert Spalek Date: Sat, 21 Aug 2004 16:29:06 +0000 Subject: [PATCH] added sepsplit() in wordsplit.c --- lib/lib.h | 1 + lib/wordsplit.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/lib.h b/lib/lib.h index 2a106e7f..de5b4b8c 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -128,6 +128,7 @@ int fls(u32); /* wordsplit.c */ +int sepsplit(byte *str, byte sep, byte **rec, uns max); int wordsplit(byte *, byte **, uns); /* pat(i)match.c: Matching of shell patterns */ diff --git a/lib/wordsplit.c b/lib/wordsplit.c index 6e2e792e..1a488f2e 100644 --- a/lib/wordsplit.c +++ b/lib/wordsplit.c @@ -2,6 +2,7 @@ * Sherlock 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) { -- 2.39.2