From 63b80e79f69beec9a375f53d5cd8f20f55fb4746 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Wed, 14 Apr 2010 06:59:56 +0200 Subject: win32: add strsep() --- include/mingw.h | 2 +- win32/mingw.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/mingw.h b/include/mingw.h index 40c11aabf..7fff1ad38 100644 --- a/include/mingw.h +++ b/include/mingw.h @@ -140,7 +140,7 @@ IMPL(unsetenv,void,,const char *env UNUSED_PARAM); /* * string.h */ -IMPL(strsep,char *,NULL,char **stringp UNUSED_PARAM, const char *delim UNUSED_PARAM); +char *strsep(char **stringp, const char *delim); /* * sys/ioctl.h diff --git a/win32/mingw.c b/win32/mingw.c index eccd37cc3..937e9422c 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -348,3 +348,21 @@ int link(const char *oldpath, const char *newpath) } return 0; } + +char *strsep(char **stringp, const char *delim) +{ + char *s, *old_stringp; + if (!*stringp) + return NULL; + old_stringp = s = *stringp; + while (*s) { + if (strchr(delim, *s)) { + *s = '\0'; + *stringp = s+1; + return old_stringp; + } + s++; + } + *stringp = NULL; + return old_stringp; +} -- cgit v1.2.3-55-g6feb