Move the lib/ stuff around a bit
[fio.git] / lib / strsep.c
diff --git a/lib/strsep.c b/lib/strsep.c
new file mode 100644 (file)
index 0000000..f8e55b5
--- /dev/null
@@ -0,0 +1,26 @@
+#include <stdio.h>
+
+char *strsep(char **stringp, const char *delim)
+{
+        char *s;
+        const char *spanp;
+        int c, sc;
+        char *tok;
+
+        if ((s = *stringp) == NULL)
+                return (NULL);
+        for (tok = s;;) {
+                c = *s++;
+                spanp = delim;
+                do {
+                        if ((sc = *spanp++) == c) {
+                                if (c == 0)
+                                        s = NULL;
+                                else
+                                        s[-1] = 0;
+                                *stringp = s;
+                                return (tok);
+                        }
+                } while (sc != 0);
+        }
+}