From dc99cd38541fe32ade06065964f26305bc83e187 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Wed, 27 Feb 2019 19:27:25 -0500 Subject: add (empty) _strtok.h to be shared with strtok_r() --- src/string/_strtok.h | 1 + src/string/strtok.c | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 src/string/_strtok.h 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 = ¤t; /* 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, ¤t); + #include "_strtok.h" + + return current; } /*** -- cgit v1.2.1