Author: stefanct Date: Sat Nov 1 23:56:06 2014 New Revision: 1853 URL: http://flashrom.org/trac/flashrom/changeset/1853
Log: Move strtok_r implementation verbatim to helpers.c.
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at Acked-by: Stefan Tauner stefan.tauner@alumni.tuwien.ac.at
Modified: trunk/flash.h trunk/helpers.c trunk/print.c
Modified: trunk/flash.h ============================================================================== --- trunk/flash.h Sun Oct 19 09:54:27 2014 (r1852) +++ trunk/flash.h Sat Nov 1 23:56:06 2014 (r1853) @@ -255,6 +255,9 @@ int min(int a, int b); char *strcat_realloc(char *dest, const char *src); void tolower_string(char *str); +#ifdef __MINGW32__ +char* strtok_r(char *str, const char *delim, char **nextp); +#endif
/* flashrom.c */ extern const char flashrom_version[];
Modified: trunk/helpers.c ============================================================================== --- trunk/helpers.c Sun Oct 19 09:54:27 2014 (r1852) +++ trunk/helpers.c Sat Nov 1 23:56:06 2014 (r1853) @@ -70,3 +70,24 @@ *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 +
Modified: trunk/print.c ============================================================================== --- trunk/print.c Sun Oct 19 09:54:27 2014 (r1852) +++ trunk/print.c Sat Nov 1 23:56:06 2014 (r1853) @@ -26,27 +26,6 @@ #include "flash.h" #include "programmer.h"
-/* FIXME: Find a better solution for MinGW. Maybe wrap strtok_s (C11) below if it becomes available */ -#ifdef __MINGW32__ -static 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 - static const char *test_state_to_text(enum test_state test_state) { switch (test_state) {