[hackers] [scc] [libc] Add strtok.c || Roberto E. Vargas Caballero
commit 0bb819c2423f68687ac0a6376ce6f1a6967a5a51
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Feb 21 10:09:20 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Feb 21 10:09:20 2017 +0100
[libc] Add strtok.c
diff --git a/libc/src/Makefile b/libc/src/Makefile
index f591fb3..47225a2 100644
--- a/libc/src/Makefile
+++ b/libc/src/Makefile
_AT_@ -3,7 +3,7 @@
LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \
strrchr.o strcat.o strncpy.o strncat.o strcoll.o \
- strxfrm.o \
+ strxfrm.o strtok.o \
memset.o memcpy.o memmove.o memcmp.o memchr.o \
isalnum.o isalpha.o isascii.o isblank.o iscntrl.o isdigit.o \
isgraph.o islower.o isprint.o ispunct.o isspace.o isupper.o \
diff --git a/libc/src/strtok.c b/libc/src/strtok.c
new file mode 100644
index 0000000..33c99d1
--- /dev/null
+++ b/libc/src/strtok.c
_AT_@ -0,0 +1,26 @@
+/* See LICENSE file for copyright and license details. */
+
+#include <string.h>
+
+char *
+strtok(const char *s, const char *delim)
+{
+ static char *line;
+
+ if (s)
+ line = s;
+ if (!s && !line)
+ return NULL;
+
+ s = line + strspn(line, delim);
+ if (*s == '\0')
+ return line = NULL;
+
+ line = s + strcspn(s, delim);
+ if (*line != '\0')
+ *line++ = '\0';
+ else
+ line = NULL;
+
+ return s;
+}
Received on Tue Feb 21 2017 - 10:12:54 CET
This archive was generated by hypermail 2.3.0
: Tue Feb 21 2017 - 10:24:24 CET