diff options
| author | "Vladimir N. Oleynik" <dzo@simtreas.ru> | 2005-10-15 10:23:55 +0000 |
|---|---|---|
| committer | "Vladimir N. Oleynik" <dzo@simtreas.ru> | 2005-10-15 10:23:55 +0000 |
| commit | 6f347ef9dc540aaea025c0575e586817cd85cc8e (patch) | |
| tree | 5fc98f67e92bb2eca75d33940a4f8698bb216f3a /coreutils | |
| parent | 84e7511607600c2c7b9e7c4087897d44cc4668c4 (diff) | |
| download | busybox-w32-6f347ef9dc540aaea025c0575e586817cd85cc8e.tar.gz busybox-w32-6f347ef9dc540aaea025c0575e586817cd85cc8e.tar.bz2 busybox-w32-6f347ef9dc540aaea025c0575e586817cd85cc8e.zip | |
common BUFSIZ BSS buffer, small reduce code, data and bss
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/dos2unix.c | 3 | ||||
| -rw-r--r-- | coreutils/tee.c | 6 | ||||
| -rw-r--r-- | coreutils/tr.c | 9 |
3 files changed, 7 insertions, 11 deletions
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c index 0c419aca7..0464df76f 100644 --- a/coreutils/dos2unix.c +++ b/coreutils/dos2unix.c | |||
| @@ -44,12 +44,13 @@ | |||
| 44 | * to pick a random letter to add to out temporary file. */ | 44 | * to pick a random letter to add to out temporary file. */ |
| 45 | typedef unsigned long int bb_uint64_t; | 45 | typedef unsigned long int bb_uint64_t; |
| 46 | 46 | ||
| 47 | #define tempFn bb_common_bufsiz1 | ||
| 48 | |||
| 47 | /* if fn is NULL then input is stdin and output is stdout */ | 49 | /* if fn is NULL then input is stdin and output is stdout */ |
| 48 | static int convert(char *fn, int ConvType) | 50 | static int convert(char *fn, int ConvType) |
| 49 | { | 51 | { |
| 50 | int c, fd; | 52 | int c, fd; |
| 51 | struct timeval tv; | 53 | struct timeval tv; |
| 52 | RESERVE_CONFIG_BUFFER(tempFn, BUFSIZ); | ||
| 53 | static bb_uint64_t value=0; | 54 | static bb_uint64_t value=0; |
| 54 | FILE *in, *out; | 55 | FILE *in, *out; |
| 55 | 56 | ||
diff --git a/coreutils/tee.c b/coreutils/tee.c index ba2e10f90..1160fc9dd 100644 --- a/coreutils/tee.c +++ b/coreutils/tee.c | |||
| @@ -39,7 +39,7 @@ int tee_main(int argc, char **argv) | |||
| 39 | int retval = EXIT_SUCCESS; | 39 | int retval = EXIT_SUCCESS; |
| 40 | #ifdef CONFIG_FEATURE_TEE_USE_BLOCK_IO | 40 | #ifdef CONFIG_FEATURE_TEE_USE_BLOCK_IO |
| 41 | ssize_t c; | 41 | ssize_t c; |
| 42 | RESERVE_CONFIG_BUFFER(buf, BUFSIZ); | 42 | # define buf bb_common_bufsiz1 |
| 43 | #else | 43 | #else |
| 44 | int c; | 44 | int c; |
| 45 | #endif | 45 | #endif |
| @@ -88,10 +88,6 @@ int tee_main(int argc, char **argv) | |||
| 88 | retval = EXIT_FAILURE; | 88 | retval = EXIT_FAILURE; |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | #ifdef CONFIG_FEATURE_CLEAN_UP | ||
| 92 | RELEASE_CONFIG_BUFFER(buf); | ||
| 93 | #endif | ||
| 94 | |||
| 95 | #else | 91 | #else |
| 96 | setvbuf(stdout, NULL, _IONBF, 0); | 92 | setvbuf(stdout, NULL, _IONBF, 0); |
| 97 | while ((c = getchar()) != EOF) { | 93 | while ((c = getchar()) != EOF) { |
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; |
