mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-02 22:43:17 +02:00
Move strtok_r implementation verbatim to helpers.c
Corresponding to flashrom svn r1853. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
This commit is contained in:
21
helpers.c
21
helpers.c
@ -70,3 +70,24 @@ void tolower_string(char *str)
|
||||
*str = (char)tolower((unsigned char)*str);
|
||||
}
|
||||
|
||||
/* FIXME: Find a better solution for MinGW. Maybe wrap strtok_s (C11) if it becomes available */
|
||||
#ifdef __MINGW32__
|
||||
char* strtok_r(char *str, const char *delim, char **nextp)
|
||||
{
|
||||
if (str == NULL)
|
||||
str = *nextp;
|
||||
|
||||
str += strspn(str, delim); /* Skip leading delimiters */
|
||||
if (*str == '\0')
|
||||
return NULL;
|
||||
|
||||
char *ret = str;
|
||||
str += strcspn(str, delim); /* Find end of token */
|
||||
if (*str != '\0')
|
||||
*str++ = '\0';
|
||||
|
||||
*nextp = str;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user