diff options
Diffstat (limited to 'nuttx/tools/mkdeps.c')
-rw-r--r-- | nuttx/tools/mkdeps.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/nuttx/tools/mkdeps.c b/nuttx/tools/mkdeps.c index a90595c98..c688b2b75 100644 --- a/nuttx/tools/mkdeps.c +++ b/nuttx/tools/mkdeps.c @@ -87,6 +87,75 @@ static char *g_topdir = NULL; * Private Functions ****************************************************************************/ + /* MinGW does not seem to provide strtok_r */ + +#ifndef HAVE_STRTOK_R +static char *strtok_r(char *str, const char *delim, char **saveptr) +{ + char *pbegin; + char *pend = NULL; + + /* Decide if we are starting a new string or continuing from + * the point we left off. + */ + + if (str) + { + pbegin = str; + } + else if (saveptr && *saveptr) + { + pbegin = *saveptr; + } + else + { + return NULL; + } + + /* Find the beginning of the next token */ + + for (; + *pbegin && strchr(delim, *pbegin) != NULL; + pbegin++); + + /* If we are at the end of the string with nothing + * but delimiters found, then return NULL. + */ + + if (!*pbegin) + { + return NULL; + } + + /* Find the end of the token */ + + for (pend = pbegin + 1; + *pend && strchr(delim, *pend) == NULL; + pend++); + + /* pend either points to the end of the string or to + * the first delimiter after the string. + */ + + if (*pend) + { + /* Turn the delimiter into a null terminator */ + + *pend++ = '\0'; + } + + /* Save the pointer where we left off and return the + * beginning of the token. + */ + + if (saveptr) + { + *saveptr = pend; + } + return pbegin; +} +#endif + static void append(char **base, char *str) { char *oldbase; |