summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-27 19:27:25 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-27 19:27:25 -0500
commitdc99cd38541fe32ade06065964f26305bc83e187 (patch)
tree6a84d2fa78e6ad059b93c1c8d26bb6198b099cdb
parentf08b1ae89f4fa107826db7359216f56f43b7fa08 (diff)
add (empty) _strtok.h to be shared with strtok_r()
-rw-r--r--src/string/_strtok.h1
-rw-r--r--src/string/strtok.c8
2 files changed, 6 insertions, 3 deletions
diff --git a/src/string/_strtok.h b/src/string/_strtok.h
new file mode 100644
index 00000000..09c0ba96
--- /dev/null
+++ b/src/string/_strtok.h
@@ -0,0 +1 @@
+
diff --git a/src/string/strtok.c b/src/string/strtok.c
index 9a7137cf..ed44e9f2 100644
--- a/src/string/strtok.c
+++ b/src/string/strtok.c
@@ -4,8 +4,8 @@
/** split string into tokens **/
char * strtok(char * restrict s1, const char * restrict s2)
{
- extern char * strtok_r(char *restr, const char *restrict, char **);
- static char *current;
+ static char *current = 0;
+ static char **state = &current;
/* TODO */
ASSERT_NONNULL(s2);
@@ -15,7 +15,9 @@ char * strtok(char * restrict s1, const char * restrict s2)
RETURN(NONNULL, a pointer to the first character of the next token);
*/
- return strtok_r (s1, s2, &current);
+ #include "_strtok.h"
+
+ return current;
}
/***