]> mj.ucw.cz Git - libucw.git/blobdiff - lib/wordsplit.c
fixes
[libucw.git] / lib / wordsplit.c
index 6e2e792edd71b9ed62989c6cb7c7aefe4613f661..d13f21087792fe8774a56be483dafdc678635924 100644 (file)
@@ -1,7 +1,8 @@
 /*
 /*
- *     Sherlock Library -- Word Splitting
+ *     UCW Library -- Word Splitting
  *
  *     (c) 1997 Martin Mares <mj@ucw.cz>
  *
  *     (c) 1997 Martin Mares <mj@ucw.cz>
+ *     (c) 2004 Robert Spalek <robert@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
 #include "lib/lib.h"
 #include "lib/chartype.h"
 
 #include "lib/lib.h"
 #include "lib/chartype.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
 wordsplit(byte *src, byte **dst, uns max)
 {