diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-02 18:49:22 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-02 18:49:22 +0100 |
commit | c066472b0cfba62260ccb86d567a11c8b3d395e3 (patch) | |
tree | 7e7827ab2a317eebeb1add39179790c62bc34e4f | |
parent | 1ee5afdce28d5a11987071f710c1d2fd493618cc (diff) | |
download | busybox-w32-c066472b0cfba62260ccb86d567a11c8b3d395e3.tar.gz busybox-w32-c066472b0cfba62260ccb86d567a11c8b3d395e3.tar.bz2 busybox-w32-c066472b0cfba62260ccb86d567a11c8b3d395e3.zip |
*: do not assign to stdout/stderr, it's not portable.
Based on patch by Aaron Carroll <xaaronc@gmail.com>
function old new delta
time_main 1062 1052 -10
cpio_main 563 549 -14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/cpio.c | 5 | ||||
-rw-r--r-- | libbb/xfuncs_printf.c | 5 | ||||
-rw-r--r-- | miscutils/time.c | 4 |
3 files changed, 3 insertions, 11 deletions
diff --git a/archival/cpio.c b/archival/cpio.c index 41aeef171..f139f3130 100644 --- a/archival/cpio.c +++ b/archival/cpio.c | |||
@@ -354,10 +354,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
354 | if (*cpio_fmt != 'n') /* we _require_ "-H newc" */ | 354 | if (*cpio_fmt != 'n') /* we _require_ "-H newc" */ |
355 | bb_show_usage(); | 355 | bb_show_usage(); |
356 | if (opt & CPIO_OPT_FILE) { | 356 | if (opt & CPIO_OPT_FILE) { |
357 | fclose(stdout); | 357 | xmove_fd(xopen3(cpio_filename, O_WRONLY | O_CREAT | O_TRUNC, 0666), STDOUT_FILENO); |
358 | stdout = fopen_for_write(cpio_filename); | ||
359 | /* Paranoia: I don't trust libc that much */ | ||
360 | xdup2(fileno(stdout), STDOUT_FILENO); | ||
361 | } | 358 | } |
362 | dump: | 359 | dump: |
363 | return cpio_o(); | 360 | return cpio_o(); |
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index d36284131..7207ec58a 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -263,10 +263,7 @@ int FAST_FUNC fflush_all(void) | |||
263 | 263 | ||
264 | int FAST_FUNC bb_putchar(int ch) | 264 | int FAST_FUNC bb_putchar(int ch) |
265 | { | 265 | { |
266 | /* time.c needs putc(ch, stdout), not putchar(ch). | 266 | return putchar(ch); |
267 | * it does "stdout = stderr;", but then glibc's putchar() | ||
268 | * doesn't work as expected. bad glibc, bad */ | ||
269 | return putc(ch, stdout); | ||
270 | } | 267 | } |
271 | 268 | ||
272 | /* Die with an error message if we can't copy an entire FILE* to stdout, | 269 | /* Die with an error message if we can't copy an entire FILE* to stdout, |
diff --git a/miscutils/time.c b/miscutils/time.c index 42c812a42..342173609 100644 --- a/miscutils/time.c +++ b/miscutils/time.c | |||
@@ -414,9 +414,7 @@ int time_main(int argc UNUSED_PARAM, char **argv) | |||
414 | run_command(argv, &res); | 414 | run_command(argv, &res); |
415 | 415 | ||
416 | /* Cheat. printf's are shorter :) */ | 416 | /* Cheat. printf's are shorter :) */ |
417 | /* (but see bb_putchar() body for additional wrinkle!) */ | 417 | xdup2(STDERR_FILENO, STDOUT_FILENO); |
418 | xdup2(2, 1); /* just in case libc does something silly :( */ | ||
419 | stdout = stderr; | ||
420 | summarize(output_format, argv, &res); | 418 | summarize(output_format, argv, &res); |
421 | 419 | ||
422 | if (WIFSTOPPED(res.waitstatus)) | 420 | if (WIFSTOPPED(res.waitstatus)) |