From 4546c75d685475d8b9f215b588364e1d1bbd0b79 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 29 Apr 2020 19:21:29 +0200 Subject: MUCH work in libc Also cleaned up some syscalls etc --- src/userspace/libc/string/strsep.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/userspace/libc/string/strsep.c (limited to 'src/userspace/libc/string/strsep.c') diff --git a/src/userspace/libc/string/strsep.c b/src/userspace/libc/string/strsep.c new file mode 100644 index 0000000..badbf0f --- /dev/null +++ b/src/userspace/libc/string/strsep.c @@ -0,0 +1,25 @@ +#include + +char *strsep(char **stringp, 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); + } +} \ No newline at end of file -- cgit v1.2.3