diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2020-09-14 15:37:44 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-09-14 16:11:36 +0200 |
commit | 74d78a1e4a47c322d348823b2836614b531cda8b (patch) | |
tree | 4645877ae846414c0fc69b0149b2e37787cee2d5 /lib | |
parent | 67f77f924295bb68786a47e81b8e059328896c98 (diff) | |
download | barebox-74d78a1e4a47c322d348823b2836614b531cda8b.tar.gz barebox-74d78a1e4a47c322d348823b2836614b531cda8b.tar.xz |
lib: string: retire deprecated strtok() in favor of reentrant strsep()
With the recent changes to ARCH=sandbox, there are no remaining
in-tree users for strtok() anymore. Out-of-tree users are better
served by using the reentrant strsep(), which has existed in-tree
for as long.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/string.c | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/lib/string.c b/lib/string.c index 50f8e2f87c..733b567300 100644 --- a/lib/string.c +++ b/lib/string.c @@ -13,6 +13,9 @@ * * Fri Jun 25 1999, Ingo Oeser <ioe@informatik.tu-chemnitz.de> * - Added strsep() which will replace strtok() soon (because strsep() is * reentrant and should be faster). Use only strsep() in new code, please. + * * Mon Sep 14 2020, Ahmad Fatoum <a.fatoum@pengutronix.de> + * - Kissed strtok() goodbye + * */ #include <linux/types.h> @@ -20,8 +23,6 @@ #include <linux/ctype.h> #include <malloc.h> -char * ___strtok; - #ifndef __HAVE_ARCH_STRNICMP /** * strnicmp - Case insensitive, length-limited string comparison @@ -396,36 +397,6 @@ char * strpbrk(const char * cs,const char * ct) #endif EXPORT_SYMBOL(strpbrk); -#ifndef __HAVE_ARCH_STRTOK -/** - * strtok - Split a string into tokens - * @s: The string to be searched - * @ct: The characters to search for - * - * WARNING: strtok is deprecated, use strsep instead. - */ -char * strtok(char * s, const char * ct) -{ - char *sbegin, *send; - - sbegin = s ? s : ___strtok; - if (!sbegin) { - return NULL; - } - sbegin += strspn(sbegin,ct); - if (*sbegin == '\0') { - ___strtok = NULL; - return( NULL ); - } - send = strpbrk( sbegin, ct); - if (send && *send != '\0') - *send++ = '\0'; - ___strtok = send; - return (sbegin); -} -#endif -EXPORT_SYMBOL(strtok); - #ifndef __HAVE_ARCH_STRSEP /** * strsep - Split a string into tokens |