aboutsummaryrefslogtreecommitdiff
path: root/ic-reals-6.3/base/strsep.c
diff options
context:
space:
mode:
Diffstat (limited to 'ic-reals-6.3/base/strsep.c')
-rw-r--r--ic-reals-6.3/base/strsep.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/ic-reals-6.3/base/strsep.c b/ic-reals-6.3/base/strsep.c
new file mode 100644
index 0000000..1191f33
--- /dev/null
+++ b/ic-reals-6.3/base/strsep.c
@@ -0,0 +1,25 @@
+/*
+ * Some UNIX distributions don't come with strsep.
+ */
+#include <stdio.h>
+#include <string.h>
+
+char *
+strsep(char **str_p, char *delim)
+{
+ char *start, *end;
+
+ start = *str_p;
+ if (start == NULL)
+ return NULL;
+
+ end = strpbrk(start, delim);
+ if (end) {
+ *end++ = '\0';
+ *str_p = end;
+ }
+ else
+ *str_p = NULL;
+
+ return start;
+}