From 73561cc75ac31e63bcab4b4ebfaf738e4ca225e6 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Mon, 28 Aug 2006 23:31:54 +0000 Subject: - pull from busybox_scratch: r15829:15850 Various fixes, cleanups and shrinkage: saves 952 Bytes: text data bss dec hex filename 1087742 15853 790632 1894227 1ce753 ../busybox/busybox.old 1086790 15853 790632 1893275 1ce39b busybox via: # scripts/bloat-o-meter ../busybox/busybox_unstripped.old busybox_unstripped function old new delta ipcrm_main 756 822 +66 getval - 61 +61 maybe_set_utc - 40 +40 udhcpc_main 2896 2912 +16 md5_hash_block 428 437 +9 opt 8 16 +8 qgravechar 106 110 +4 make_bitmap 292 295 +3 inflate_unzip 2056 2059 +3 add_partition 1412 1414 +2 __parsespent 156 158 +2 qrealloc 41 42 +1 format - 1 +1 catv_main 313 314 +1 watch_main 293 292 -1 varunset 81 80 -1 part 1 - -1 check_if_skip 837 836 -1 start_stop_daemon_main 840 837 -3 create_lost_and_found 175 172 -3 supress_non_delimited_lines 4 - -4 static.l 4 - -4 static.c 5 1 -4 bsd_sum_file 237 233 -4 eval2 338 332 -6 arithmetic_common 166 158 -8 cmpfunc 22 5 -17 cksum_main 294 275 -19 cmp_main 465 439 -26 dd_main 1535 1508 -27 rmmod_main 376 333 -43 cut_file 727 644 -83 ipcs_main 3809 3721 -88 cut_main 722 614 -108 date_main 1443 1263 -180 remove_ids 222 - -222 ------------------------------------------------------------------------------ (add/remove: 3/4 grow/shrink: 11/18 up/down: 217/-853) Total: -636 bytes --- coreutils/tail.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'coreutils/tail.c') diff --git a/coreutils/tail.c b/coreutils/tail.c index 80a66fbf5..49f1bcd6a 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c @@ -42,20 +42,25 @@ static const struct suffix_mult tail_suffixes[] = { static int status; -static void tail_xprint_header(const char *fmt, const char *filename) +static void tail_xbb_full_write(const char *buf, size_t len) { - /* If we get an output error, there is really no sense in continuing. */ - if (dprintf(STDOUT_FILENO, fmt, filename) < 0) { + /* If we get a write error, there is really no sense in continuing. */ + if (full_write(STDOUT_FILENO, buf, len) < 0) bb_perror_nomsg_and_die(); - } } -/* len should probably be size_t */ -static void tail_xbb_full_write(const char *buf, size_t len) +static void tail_xprint_header(const char *fmt, const char *filename) { - /* If we get a write error, there is really no sense in continuing. */ - if (full_write(STDOUT_FILENO, buf, len) < 0) +#if defined __GLIBC__ + if (dprintf(STDOUT_FILENO, fmt, filename) < 0) { bb_perror_nomsg_and_die(); + } +#else + int hdr_len = strlen(fmt) + strlen(filename); + char *hdr = xzalloc(hdr_len); + sprintf(hdr, filename, filename); + tail_xbb_full_write(hdr, hdr_len); +#endif } static ssize_t tail_read(int fd, char *buf, size_t count) -- cgit v1.2.3