On Wed, 17 Jul 2013 09:37:38 +0200 Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net wrote:
Am 10.07.2013 21:17 schrieb Stefan Tauner:
- Use the reentrant tokenizer version strtok_r to break up vendor and model names in print.c
- Add implementation of strtok_r for mingw (posix only)
- Free allocated temporary memory again.
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at
print.c | 49 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-)
diff --git a/print.c b/print.c index 6ca2a57..b163cbf 100644 --- a/print.c +++ b/print.c @@ -25,6 +25,26 @@ #include "flash.h" #include "programmer.h"
+#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
OK. In the future, we may want to make strtok_r a wrapper around strtok_s (which is in C11). It might take some time for the C library on various platforms to catch up on this, though.
I have added a fixme there.
Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Thanks for fixing this!
I broke it too... ;)
Thanks, r1700