On Thu, Apr 15, 2010 at 10:01:34PM +0200, Nguy�n Thái Ng�c Duy wrote: > +char *strsep(char **stringp, const char *delim)
strsep() is a non-standard function that other platforms need in addition to Windows. Attached is an alternate patch, part of a series improving portability that I haven't submitted here yet, that adds it to platform.c >>> Dan -- http://www.MoveAnnouncer.com The web change of address service Let webmasters know that your web site has moved
diff --git a/include/platform.h b/include/platform.h index f87add5..0dadf42 100644 --- a/include/platform.h +++ b/include/platform.h @@ -16,6 +16,7 @@ #define HAVE_SETBIT 1 #define HAVE_STRCASESTR 1 #define HAVE_STRCHRNUL 1 +#define HAVE_STRSEP 1 #define HAVE_STRSIGNAL 1 #define HAVE_VASPRINTF 1 @@ -168,10 +169,10 @@ #if defined(__BIG_ENDIAN__) && __BIG_ENDIAN__ # define BB_BIG_ENDIAN 1 # define BB_LITTLE_ENDIAN 0 -#elif __BYTE_ORDER == __BIG_ENDIAN +#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN # define BB_BIG_ENDIAN 1 # define BB_LITTLE_ENDIAN 0 -#elif __BYTE_ORDER == __LITTLE_ENDIAN +#elif (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || defined(__386__) # define BB_BIG_ENDIAN 0 # define BB_LITTLE_ENDIAN 1 #else @@ -353,6 +354,7 @@ typedef unsigned smalluint; # undef HAVE_SETBIT # undef HAVE_STRCASESTR # undef HAVE_STRCHRNUL +# undef HAVE_STRSEP # undef HAVE_STRSIGNAL # undef HAVE_VASPRINTF #endif @@ -391,6 +393,10 @@ extern char *strcasestr(const char *s, const char *pattern) FAST_FUNC; extern char *strchrnul(const char *s, int c) FAST_FUNC; #endif +#ifndef HAVE_STRSEP +extern char *strsep(char **stringp, const char *delim) FAST_FUNC; +#endif + #ifndef HAVE_STRSIGNAL /* Not exactly the same: instead of "Stopped" it shows "STOP" etc */ # define strsignal(sig) get_signame(sig) diff --git a/libbb/platform.c b/libbb/platform.c index 17ad3f7..7a8b176 100644 --- a/libbb/platform.c +++ b/libbb/platform.c @@ -107,3 +107,30 @@ char* FAST_FUNC strcasestr(const char *s, const char *pattern) return 0; } #endif + +#ifndef HAVE_STRSEP +/* Copyright (C) 2004 Free Software Foundation, Inc. */ +char* FAST_FUNC strsep(char **stringp, const char *delim) +{ + char *start = *stringp; + char *ptr; + + if (!start) + return NULL; + + if (!*delim) + ptr = start + strlen(start); + else { + ptr = strpbrk(start, delim); + if (!ptr) { + *stringp = NULL; + return start; + } + } + + *ptr = '\0'; + *stringp = ptr + 1; + + return start; +} +#endif
_______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox