diff options
| author | Dan Fandrich <dan@coneharvesters.com> | 2011-02-12 22:26:57 -0800 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-13 18:37:12 +0100 |
| commit | dc50676cce35cdba3ecba3870c3f752408d6db70 (patch) | |
| tree | a8c7861c43f656b1013a0e57672446d63ffdb263 | |
| parent | 4ed3c52ce9b3ce5604c4fa075fda374f8cd01eea (diff) | |
| download | busybox-w32-dc50676cce35cdba3ecba3870c3f752408d6db70.tar.gz busybox-w32-dc50676cce35cdba3ecba3870c3f752408d6db70.tar.bz2 busybox-w32-dc50676cce35cdba3ecba3870c3f752408d6db70.zip | |
Move stpcpy replacement function into libbb
Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | include/platform.h | 8 | ||||
| -rw-r--r-- | libbb/platform.c | 11 | ||||
| -rw-r--r-- | runit/runsv.c | 24 |
3 files changed, 26 insertions, 17 deletions
diff --git a/include/platform.h b/include/platform.h index 00ebe563b..e390e58e2 100644 --- a/include/platform.h +++ b/include/platform.h | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #define HAVE_PTSNAME_R 1 | 18 | #define HAVE_PTSNAME_R 1 |
| 19 | #define HAVE_SETBIT 1 | 19 | #define HAVE_SETBIT 1 |
| 20 | #define HAVE_SIGHANDLER_T 1 | 20 | #define HAVE_SIGHANDLER_T 1 |
| 21 | #define HAVE_STPCPY 1 | ||
| 21 | #define HAVE_STRCASESTR 1 | 22 | #define HAVE_STRCASESTR 1 |
| 22 | #define HAVE_STRCHRNUL 1 | 23 | #define HAVE_STRCHRNUL 1 |
| 23 | #define HAVE_STRSEP 1 | 24 | #define HAVE_STRSEP 1 |
| @@ -356,6 +357,8 @@ typedef unsigned smalluint; | |||
| 356 | # define ADJ_TICK MOD_CLKB | 357 | # define ADJ_TICK MOD_CLKB |
| 357 | # endif | 358 | # endif |
| 358 | 359 | ||
| 360 | # undef HAVE_STPCPY | ||
| 361 | |||
| 359 | #else | 362 | #else |
| 360 | 363 | ||
| 361 | # define bb_setpgrp() setpgrp() | 364 | # define bb_setpgrp() setpgrp() |
| @@ -376,6 +379,7 @@ typedef unsigned smalluint; | |||
| 376 | # undef HAVE_MEMRCHR | 379 | # undef HAVE_MEMRCHR |
| 377 | # undef HAVE_MKDTEMP | 380 | # undef HAVE_MKDTEMP |
| 378 | # undef HAVE_SETBIT | 381 | # undef HAVE_SETBIT |
| 382 | # undef HAVE_STPCPY | ||
| 379 | # undef HAVE_STRCASESTR | 383 | # undef HAVE_STRCASESTR |
| 380 | # undef HAVE_STRCHRNUL | 384 | # undef HAVE_STRCHRNUL |
| 381 | # undef HAVE_STRSEP | 385 | # undef HAVE_STRSEP |
| @@ -413,6 +417,10 @@ extern char *mkdtemp(char *template) FAST_FUNC; | |||
| 413 | typedef void (*sighandler_t)(int); | 417 | typedef void (*sighandler_t)(int); |
| 414 | #endif | 418 | #endif |
| 415 | 419 | ||
| 420 | #ifndef HAVE_STPCPY | ||
| 421 | extern char *stpcpy(char *p, const char *to_add) FAST_FUNC; | ||
| 422 | #endif | ||
| 423 | |||
| 416 | #ifndef HAVE_STRCASESTR | 424 | #ifndef HAVE_STRCASESTR |
| 417 | extern char *strcasestr(const char *s, const char *pattern) FAST_FUNC; | 425 | extern char *strcasestr(const char *s, const char *pattern) FAST_FUNC; |
| 418 | #endif | 426 | #endif |
diff --git a/libbb/platform.c b/libbb/platform.c index ccde2bf02..fe7ce1567 100644 --- a/libbb/platform.c +++ b/libbb/platform.c | |||
| @@ -134,3 +134,14 @@ char* FAST_FUNC strsep(char **stringp, const char *delim) | |||
| 134 | return start; | 134 | return start; |
| 135 | } | 135 | } |
| 136 | #endif | 136 | #endif |
| 137 | |||
| 138 | #ifndef HAVE_STPCPY | ||
| 139 | char* FAST_FUNC stpcpy(char *p, const char *to_add) | ||
| 140 | { | ||
| 141 | while ((*p = *to_add) != '\0') { | ||
| 142 | p++; | ||
| 143 | to_add++; | ||
| 144 | } | ||
| 145 | return p; | ||
| 146 | } | ||
| 147 | #endif | ||
diff --git a/runit/runsv.c b/runit/runsv.c index ebb031837..e76572daa 100644 --- a/runit/runsv.c +++ b/runit/runsv.c | |||
| @@ -139,16 +139,6 @@ static void s_term(int sig_no UNUSED_PARAM) | |||
| 139 | write(selfpipe.wr, "", 1); /* XXX */ | 139 | write(selfpipe.wr, "", 1); /* XXX */ |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | /* libbb candidate */ | ||
| 143 | static char *bb_stpcpy(char *p, const char *to_add) | ||
| 144 | { | ||
| 145 | while ((*p = *to_add) != '\0') { | ||
| 146 | p++; | ||
| 147 | to_add++; | ||
| 148 | } | ||
| 149 | return p; | ||
| 150 | } | ||
| 151 | |||
| 152 | static int open_trunc_or_warn(const char *name) | 142 | static int open_trunc_or_warn(const char *name) |
| 153 | { | 143 | { |
| 154 | /* Why O_NDELAY? */ | 144 | /* Why O_NDELAY? */ |
| @@ -192,26 +182,26 @@ static void update_status(struct svdir *s) | |||
| 192 | char *p = stat_buf; | 182 | char *p = stat_buf; |
| 193 | switch (s->state) { | 183 | switch (s->state) { |
| 194 | case S_DOWN: | 184 | case S_DOWN: |
| 195 | p = bb_stpcpy(p, "down"); | 185 | p = stpcpy(p, "down"); |
| 196 | break; | 186 | break; |
| 197 | case S_RUN: | 187 | case S_RUN: |
| 198 | p = bb_stpcpy(p, "run"); | 188 | p = stpcpy(p, "run"); |
| 199 | break; | 189 | break; |
| 200 | case S_FINISH: | 190 | case S_FINISH: |
| 201 | p = bb_stpcpy(p, "finish"); | 191 | p = stpcpy(p, "finish"); |
| 202 | break; | 192 | break; |
| 203 | } | 193 | } |
| 204 | if (s->ctrl & C_PAUSE) | 194 | if (s->ctrl & C_PAUSE) |
| 205 | p = bb_stpcpy(p, ", paused"); | 195 | p = stpcpy(p, ", paused"); |
| 206 | if (s->ctrl & C_TERM) | 196 | if (s->ctrl & C_TERM) |
| 207 | p = bb_stpcpy(p, ", got TERM"); | 197 | p = stpcpy(p, ", got TERM"); |
| 208 | if (s->state != S_DOWN) | 198 | if (s->state != S_DOWN) |
| 209 | switch (s->sd_want) { | 199 | switch (s->sd_want) { |
| 210 | case W_DOWN: | 200 | case W_DOWN: |
| 211 | p = bb_stpcpy(p, ", want down"); | 201 | p = stpcpy(p, ", want down"); |
| 212 | break; | 202 | break; |
| 213 | case W_EXIT: | 203 | case W_EXIT: |
| 214 | p = bb_stpcpy(p, ", want exit"); | 204 | p = stpcpy(p, ", want exit"); |
| 215 | break; | 205 | break; |
| 216 | } | 206 | } |
| 217 | *p++ = '\n'; | 207 | *p++ = '\n'; |
