diff options
| author | Dan Fandrich <dan@coneharvesters.com> | 2010-06-18 22:36:45 -0700 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-06-19 20:03:18 +0200 |
| commit | 0635ddd8f7bbd8ed40ef4e5e01ff116ee959fa34 (patch) | |
| tree | e1e9d33dc63415885cb0273a663af5e1fb6db578 | |
| parent | fdd7b566ecdc174907f38d9389b28ba842d2b4bf (diff) | |
| download | busybox-w32-0635ddd8f7bbd8ed40ef4e5e01ff116ee959fa34.tar.gz busybox-w32-0635ddd8f7bbd8ed40ef4e5e01ff116ee959fa34.tar.bz2 busybox-w32-0635ddd8f7bbd8ed40ef4e5e01ff116ee959fa34.zip | |
Added code for nonstandard function strsep()
Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | include/platform.h | 6 | ||||
| -rw-r--r-- | libbb/platform.c | 27 |
2 files changed, 33 insertions, 0 deletions
diff --git a/include/platform.h b/include/platform.h index 4bd7a3d2e..0dadf42bd 100644 --- a/include/platform.h +++ b/include/platform.h | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #define HAVE_SETBIT 1 | 16 | #define HAVE_SETBIT 1 |
| 17 | #define HAVE_STRCASESTR 1 | 17 | #define HAVE_STRCASESTR 1 |
| 18 | #define HAVE_STRCHRNUL 1 | 18 | #define HAVE_STRCHRNUL 1 |
| 19 | #define HAVE_STRSEP 1 | ||
| 19 | #define HAVE_STRSIGNAL 1 | 20 | #define HAVE_STRSIGNAL 1 |
| 20 | #define HAVE_VASPRINTF 1 | 21 | #define HAVE_VASPRINTF 1 |
| 21 | 22 | ||
| @@ -353,6 +354,7 @@ typedef unsigned smalluint; | |||
| 353 | # undef HAVE_SETBIT | 354 | # undef HAVE_SETBIT |
| 354 | # undef HAVE_STRCASESTR | 355 | # undef HAVE_STRCASESTR |
| 355 | # undef HAVE_STRCHRNUL | 356 | # undef HAVE_STRCHRNUL |
| 357 | # undef HAVE_STRSEP | ||
| 356 | # undef HAVE_STRSIGNAL | 358 | # undef HAVE_STRSIGNAL |
| 357 | # undef HAVE_VASPRINTF | 359 | # undef HAVE_VASPRINTF |
| 358 | #endif | 360 | #endif |
| @@ -391,6 +393,10 @@ extern char *strcasestr(const char *s, const char *pattern) FAST_FUNC; | |||
| 391 | extern char *strchrnul(const char *s, int c) FAST_FUNC; | 393 | extern char *strchrnul(const char *s, int c) FAST_FUNC; |
| 392 | #endif | 394 | #endif |
| 393 | 395 | ||
| 396 | #ifndef HAVE_STRSEP | ||
| 397 | extern char *strsep(char **stringp, const char *delim) FAST_FUNC; | ||
| 398 | #endif | ||
| 399 | |||
| 394 | #ifndef HAVE_STRSIGNAL | 400 | #ifndef HAVE_STRSIGNAL |
| 395 | /* Not exactly the same: instead of "Stopped" it shows "STOP" etc */ | 401 | /* Not exactly the same: instead of "Stopped" it shows "STOP" etc */ |
| 396 | # define strsignal(sig) get_signame(sig) | 402 | # define strsignal(sig) get_signame(sig) |
diff --git a/libbb/platform.c b/libbb/platform.c index 17ad3f75a..7a8b17657 100644 --- a/libbb/platform.c +++ b/libbb/platform.c | |||
| @@ -107,3 +107,30 @@ char* FAST_FUNC strcasestr(const char *s, const char *pattern) | |||
| 107 | return 0; | 107 | return 0; |
| 108 | } | 108 | } |
| 109 | #endif | 109 | #endif |
| 110 | |||
| 111 | #ifndef HAVE_STRSEP | ||
| 112 | /* Copyright (C) 2004 Free Software Foundation, Inc. */ | ||
| 113 | char* FAST_FUNC strsep(char **stringp, const char *delim) | ||
| 114 | { | ||
| 115 | char *start = *stringp; | ||
| 116 | char *ptr; | ||
| 117 | |||
| 118 | if (!start) | ||
| 119 | return NULL; | ||
| 120 | |||
| 121 | if (!*delim) | ||
| 122 | ptr = start + strlen(start); | ||
| 123 | else { | ||
| 124 | ptr = strpbrk(start, delim); | ||
| 125 | if (!ptr) { | ||
| 126 | *stringp = NULL; | ||
| 127 | return start; | ||
| 128 | } | ||
| 129 | } | ||
| 130 | |||
| 131 | *ptr = '\0'; | ||
| 132 | *stringp = ptr + 1; | ||
| 133 | |||
| 134 | return start; | ||
| 135 | } | ||
| 136 | #endif | ||
