diff options
author | aldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-08-28 23:31:54 +0000 |
---|---|---|
committer | aldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-08-28 23:31:54 +0000 |
commit | d52f45a484fc7fc049ab40db9adc6ead7ea9b122 (patch) | |
tree | 2a57564b8917a983365c765d4daa83032d9f0a17 /coreutils/sum.c | |
parent | 2803d256e9decd450b955c2846bf945db72bb79e (diff) | |
download | busybox-w32-d52f45a484fc7fc049ab40db9adc6ead7ea9b122.tar.gz busybox-w32-d52f45a484fc7fc049ab40db9adc6ead7ea9b122.tar.bz2 busybox-w32-d52f45a484fc7fc049ab40db9adc6ead7ea9b122.zip |
- 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
git-svn-id: svn://busybox.net/trunk/busybox@16009 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'coreutils/sum.c')
-rw-r--r-- | coreutils/sum.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/coreutils/sum.c b/coreutils/sum.c index 2edd92036..d6a76dbbc 100644 --- a/coreutils/sum.c +++ b/coreutils/sum.c | |||
@@ -13,12 +13,6 @@ | |||
13 | * Licensed under the GPL v2, see the file LICENSE in this tarball. | 13 | * Licensed under the GPL v2, see the file LICENSE in this tarball. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <stdio.h> | ||
17 | #include <sys/types.h> | ||
18 | #include <sys/stat.h> | ||
19 | #include <fcntl.h> | ||
20 | #include <unistd.h> | ||
21 | |||
22 | #include "busybox.h" | 16 | #include "busybox.h" |
23 | 17 | ||
24 | /* 1 if any of the files read were the standard input */ | 18 | /* 1 if any of the files read were the standard input */ |
@@ -38,14 +32,15 @@ static int bsd_sum_file(const char *file, int print_name) | |||
38 | int checksum = 0; /* The checksum mod 2^16. */ | 32 | int checksum = 0; /* The checksum mod 2^16. */ |
39 | uintmax_t total_bytes = 0; /* The number of bytes. */ | 33 | uintmax_t total_bytes = 0; /* The number of bytes. */ |
40 | int ch; /* Each character read. */ | 34 | int ch; /* Each character read. */ |
35 | int ret = 0; | ||
41 | 36 | ||
42 | if (IS_STDIN(file)) { | 37 | if (IS_STDIN(file)) { |
43 | fp = stdin; | 38 | fp = stdin; |
44 | have_read_stdin = 1; | 39 | have_read_stdin++; |
45 | } else { | 40 | } else { |
46 | fp = bb_wfopen(file, "r"); | 41 | fp = bb_wfopen(file, "r"); |
47 | if (fp == NULL) | 42 | if (fp == NULL) |
48 | return 0; | 43 | goto out; |
49 | } | 44 | } |
50 | 45 | ||
51 | while ((ch = getc(fp)) != EOF) { | 46 | while ((ch = getc(fp)) != EOF) { |
@@ -58,21 +53,21 @@ static int bsd_sum_file(const char *file, int print_name) | |||
58 | if (ferror(fp)) { | 53 | if (ferror(fp)) { |
59 | bb_perror_msg(file); | 54 | bb_perror_msg(file); |
60 | bb_fclose_nonstdin(fp); | 55 | bb_fclose_nonstdin(fp); |
61 | return 0; | 56 | goto out; |
62 | } | 57 | } |
63 | 58 | ||
64 | if (bb_fclose_nonstdin(fp) == EOF) { | 59 | if (bb_fclose_nonstdin(fp) == EOF) { |
65 | bb_perror_msg(file); | 60 | bb_perror_msg(file); |
66 | return 0; | 61 | goto out; |
67 | } | 62 | } |
68 | 63 | ret++; | |
69 | printf("%05d %5ju ", checksum, (total_bytes+1023)/1024); | 64 | printf("%05d %5ju ", checksum, (total_bytes+1023)/1024); |
70 | if (print_name > 1) | 65 | if (print_name > 1) |
71 | puts(file); | 66 | puts(file); |
72 | else | 67 | else |
73 | printf("\n"); | 68 | printf("\n"); |
74 | 69 | out: | |
75 | return 1; | 70 | return ret; |
76 | } | 71 | } |
77 | 72 | ||
78 | /* Calculate and print the checksum and the size in 512-byte blocks | 73 | /* Calculate and print the checksum and the size in 512-byte blocks |