diff options
author | vodz <vodz@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-10-15 10:23:55 +0000 |
---|---|---|
committer | vodz <vodz@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-10-15 10:23:55 +0000 |
commit | 247a3694036baa952f6dee076b04b7a58ca7df59 (patch) | |
tree | 5fc98f67e92bb2eca75d33940a4f8698bb216f3a /coreutils/tr.c | |
parent | 1b47ba10db00a05de229d503090f5f36a1de552b (diff) | |
download | busybox-w32-247a3694036baa952f6dee076b04b7a58ca7df59.tar.gz busybox-w32-247a3694036baa952f6dee076b04b7a58ca7df59.tar.bz2 busybox-w32-247a3694036baa952f6dee076b04b7a58ca7df59.zip |
common BUFSIZ BSS buffer, small reduce code, data and bss
git-svn-id: svn://busybox.net/trunk/busybox@11867 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'coreutils/tr.c')
-rw-r--r-- | coreutils/tr.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/coreutils/tr.c b/coreutils/tr.c index 6e3f97b36..e9eca4c60 100644 --- a/coreutils/tr.c +++ b/coreutils/tr.c | |||
@@ -38,10 +38,11 @@ | |||
38 | static char com_fl, del_fl, sq_fl; | 38 | static char com_fl, del_fl, sq_fl; |
39 | static short in_index, out_index; | 39 | static short in_index, out_index; |
40 | /* these last are pointers to static buffers declared in tr_main */ | 40 | /* these last are pointers to static buffers declared in tr_main */ |
41 | static unsigned char *poutput, *pinput; | 41 | static unsigned char *poutput; |
42 | static unsigned char *pvector; | 42 | static unsigned char *pvector; |
43 | static char *pinvec, *poutvec; | 43 | static char *pinvec, *poutvec; |
44 | 44 | ||
45 | #define input bb_common_bufsiz1 | ||
45 | 46 | ||
46 | static void convert(void) | 47 | static void convert(void) |
47 | { | 48 | { |
@@ -51,14 +52,14 @@ static void convert(void) | |||
51 | 52 | ||
52 | for (;;) { | 53 | for (;;) { |
53 | if (in_index == read_chars) { | 54 | if (in_index == read_chars) { |
54 | if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) { | 55 | if ((read_chars = read(0, input, BUFSIZ)) <= 0) { |
55 | if (write(1, (char *) poutput, out_index) != out_index) | 56 | if (write(1, (char *) poutput, out_index) != out_index) |
56 | bb_error_msg(bb_msg_write_error); | 57 | bb_error_msg(bb_msg_write_error); |
57 | exit(0); | 58 | exit(0); |
58 | } | 59 | } |
59 | in_index = 0; | 60 | in_index = 0; |
60 | } | 61 | } |
61 | c = pinput[in_index++]; | 62 | c = input[in_index++]; |
62 | coded = pvector[c]; | 63 | coded = pvector[c]; |
63 | if (del_fl && pinvec[c]) | 64 | if (del_fl && pinvec[c]) |
64 | continue; | 65 | continue; |
@@ -208,14 +209,12 @@ extern int tr_main(int argc, char **argv) | |||
208 | int idx = 1; | 209 | int idx = 1; |
209 | int i; | 210 | int i; |
210 | RESERVE_CONFIG_BUFFER(output, BUFSIZ); | 211 | RESERVE_CONFIG_BUFFER(output, BUFSIZ); |
211 | RESERVE_CONFIG_BUFFER(input, BUFSIZ); | ||
212 | RESERVE_CONFIG_UBUFFER(vector, ASCII+1); | 212 | RESERVE_CONFIG_UBUFFER(vector, ASCII+1); |
213 | RESERVE_CONFIG_BUFFER(invec, ASCII+1); | 213 | RESERVE_CONFIG_BUFFER(invec, ASCII+1); |
214 | RESERVE_CONFIG_BUFFER(outvec, ASCII+1); | 214 | RESERVE_CONFIG_BUFFER(outvec, ASCII+1); |
215 | 215 | ||
216 | /* ... but make them available globally */ | 216 | /* ... but make them available globally */ |
217 | poutput = output; | 217 | poutput = output; |
218 | pinput = input; | ||
219 | pvector = vector; | 218 | pvector = vector; |
220 | pinvec = invec; | 219 | pinvec = invec; |
221 | poutvec = outvec; | 220 | poutvec = outvec; |