Hi list, here's a suggested patch for config.h.in and util.c to add a local implementation of strtok_r for systems that don't have it (e.g. mingw32 plus libgw32c).
Cheers Juergen
diff -rub ccache-3.1.7.orig/ccache.h ccache-3.1.7/ccache.h --- ccache-3.1.7.orig/ccache.h Sun Jan 8 14:40:55 2012 +++ ccache-3.1.7/ccache.h Thu Apr 12 06:21:36 2012 @@ -97,7 +97,9 @@ /* ------------------------------------------------------------------------- */ /* util.c */ - +#ifndef HAVE_STRTOK_R +char* strtok_r(char *src, const char* delim, char** last); +#endif void cc_log(const char *format, ...) ATTR_FORMAT(printf, 1, 2); void cc_log_argv(const char *prefix, char **argv); void fatal(const char *format, ...) ATTR_FORMAT(printf, 1, 2); diff -rub ccache-3.1.7.orig/config.h.in ccache-3.1.7/config.h.in --- ccache-3.1.7.orig/config.h.in Sun Jan 8 14:40:55 2012 +++ ccache-3.1.7/config.h.in Thu Apr 12 06:22:17 2012 @@ -64,6 +64,9 @@ /* Define to 1 if you have a C99 compliant `snprintf' function. */ #undef HAVE_SNPRINTF +/* Define to 1 if you have a C99 compliant `strtok_r' function. */ +#undef HAVE_STRTOK_R + /* Define to 1 if you have the <stdarg.h> header file. */ #undef HAVE_STDARG_H diff -rub ccache-3.1.7.orig/util.c ccache-3.1.7/util.c --- ccache-3.1.7.orig/util.c Sun Jan 8 14:40:55 2012 +++ ccache-3.1.7/util.c Thu Apr 12 06:20:23 2012 @@ -33,6 +33,53 @@ #include <sys/locking.h> #endif +#ifdef _WIN32 +char * strtok_r(char *s, const char *delim, char **last) +{ + char *spanp, *tok; + int c, sc; + + if (s == NULL && (s = *last) == NULL) + return (NULL); + + /* + * Skip (span) leading delimiters (s += strspn(s, delim), sort of). + */ +cont: + c = *s++; + for (spanp = (char *)delim; (sc = *spanp++) != 0;) { + if (c == sc) + goto cont; + } + + if (c == 0) { /* no non-delimiter characters */ + *last = NULL; + return (NULL); + } + tok = s - 1; + + /* + * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). + * Note that delim must have one NUL; we stop if we see that, too. + */ + for (;;) { + c = *s++; + spanp = (char *)delim; + do { + if ((sc = *spanp++) == c) { + if (c == 0) + s = NULL; + else + s[-1] = '\0'; + *last = s; + return (tok); + } + } while (sc != 0); + } + /* NOTREACHED */ +} +#endif + static FILE *logfile; static bool
_______________________________________________ ccache mailing list ccache@lists.samba.org https://lists.samba.org/mailman/listinfo/ccache