summaryrefslogtreecommitdiff
path: root/string/strtok.c
diff options
context:
space:
mode:
Diffstat (limited to 'string/strtok.c')
-rw-r--r--string/strtok.c40
1 files changed, 4 insertions, 36 deletions
diff --git a/string/strtok.c b/string/strtok.c
index 7a4574db5c..725249f3f4 100644
--- a/string/strtok.c
+++ b/string/strtok.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -18,14 +18,6 @@
#include <string.h>
-static char *olds;
-
-#undef strtok
-
-#ifndef STRTOK
-# define STRTOK strtok
-#endif
-
/* Parse S into tokens separated by characters in DELIM.
If S is NULL, the last string strtok() was called with is
used. For example:
@@ -36,32 +28,8 @@ static char *olds;
// s = "abc\0=-def\0"
*/
char *
-STRTOK (char *s, const char *delim)
+strtok (char *s, const char *delim)
{
- char *token;
-
- if (s == NULL)
- s = olds;
-
- /* Scan leading delimiters. */
- s += strspn (s, delim);
- if (*s == '\0')
- {
- olds = s;
- return NULL;
- }
-
- /* Find the end of the token. */
- token = s;
- s = strpbrk (token, delim);
- if (s == NULL)
- /* This token finishes the string. */
- olds = __rawmemchr (token, '\0');
- else
- {
- /* Terminate the token and make OLDS point past it. */
- *s = '\0';
- olds = s + 1;
- }
- return token;
+ static char *olds;
+ return __strtok_r (s, delim, &olds);
}