diff options
| author | Ron Yorston <rmy@pobox.com> | 2016-05-16 09:33:03 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2016-05-16 09:33:03 +0100 |
| commit | 35d2f5bccb0f3dde600702ebcdb5424d4d50be4a (patch) | |
| tree | 6e0ff0341c69839e268459a199682628bae734ed /coreutils | |
| parent | 248a2600a2f4b442101ad568d1994b908bb28d4b (diff) | |
| parent | f2559e5c2b7bd2c5fa0dd8e88d0a931da92a23af (diff) | |
| download | busybox-w32-35d2f5bccb0f3dde600702ebcdb5424d4d50be4a.tar.gz busybox-w32-35d2f5bccb0f3dde600702ebcdb5424d4d50be4a.tar.bz2 busybox-w32-35d2f5bccb0f3dde600702ebcdb5424d4d50be4a.zip | |
Merge branch 'busybox' into merge
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/catv.c | 5 | ||||
| -rw-r--r-- | coreutils/cksum.c | 4 | ||||
| -rw-r--r-- | coreutils/date.c | 4 | ||||
| -rw-r--r-- | coreutils/dd.c | 4 | ||||
| -rw-r--r-- | coreutils/du.c | 5 | ||||
| -rw-r--r-- | coreutils/expr.c | 5 | ||||
| -rw-r--r-- | coreutils/ls.c | 4 | ||||
| -rw-r--r-- | coreutils/od_bloaty.c | 4 | ||||
| -rw-r--r-- | coreutils/split.c | 3 | ||||
| -rw-r--r-- | coreutils/stat.c | 5 | ||||
| -rw-r--r-- | coreutils/stty.c | 9 | ||||
| -rw-r--r-- | coreutils/sum.c | 7 | ||||
| -rw-r--r-- | coreutils/tail.c | 5 | ||||
| -rw-r--r-- | coreutils/tee.c | 4 |
14 files changed, 47 insertions, 21 deletions
diff --git a/coreutils/catv.c b/coreutils/catv.c index 6bb73ba63..0e71368a5 100644 --- a/coreutils/catv.c +++ b/coreutils/catv.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | //usage: "\n -v Don't use ^x or M-x escapes" | 19 | //usage: "\n -v Don't use ^x or M-x escapes" |
| 20 | 20 | ||
| 21 | #include "libbb.h" | 21 | #include "libbb.h" |
| 22 | #include "common_bufsiz.h" | ||
| 22 | 23 | ||
| 23 | #define CATV_OPT_e (1<<0) | 24 | #define CATV_OPT_e (1<<0) |
| 24 | #define CATV_OPT_t (1<<1) | 25 | #define CATV_OPT_t (1<<1) |
| @@ -48,6 +49,9 @@ int catv_main(int argc UNUSED_PARAM, char **argv) | |||
| 48 | /* Read from stdin if there's nothing else to do. */ | 49 | /* Read from stdin if there's nothing else to do. */ |
| 49 | if (!argv[0]) | 50 | if (!argv[0]) |
| 50 | *--argv = (char*)"-"; | 51 | *--argv = (char*)"-"; |
| 52 | |||
| 53 | #define read_buf bb_common_bufsiz1 | ||
| 54 | setup_common_bufsiz(); | ||
| 51 | do { | 55 | do { |
| 52 | fd = open_or_warn_stdin(*argv); | 56 | fd = open_or_warn_stdin(*argv); |
| 53 | if (fd < 0) { | 57 | if (fd < 0) { |
| @@ -57,7 +61,6 @@ int catv_main(int argc UNUSED_PARAM, char **argv) | |||
| 57 | for (;;) { | 61 | for (;;) { |
| 58 | int i, res; | 62 | int i, res; |
| 59 | 63 | ||
| 60 | #define read_buf bb_common_bufsiz1 | ||
| 61 | res = read(fd, read_buf, COMMON_BUFSIZE); | 64 | res = read(fd, read_buf, COMMON_BUFSIZE); |
| 62 | if (res < 0) | 65 | if (res < 0) |
| 63 | retval = EXIT_FAILURE; | 66 | retval = EXIT_FAILURE; |
diff --git a/coreutils/cksum.c b/coreutils/cksum.c index ac0b0c319..8a8a39f68 100644 --- a/coreutils/cksum.c +++ b/coreutils/cksum.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | //usage: "Calculate the CRC32 checksums of FILES" | 13 | //usage: "Calculate the CRC32 checksums of FILES" |
| 14 | 14 | ||
| 15 | #include "libbb.h" | 15 | #include "libbb.h" |
| 16 | #include "common_bufsiz.h" | ||
| 16 | 17 | ||
| 17 | /* This is a NOEXEC applet. Be very careful! */ | 18 | /* This is a NOEXEC applet. Be very careful! */ |
| 18 | 19 | ||
| @@ -32,6 +33,7 @@ int cksum_main(int argc UNUSED_PARAM, char **argv) | |||
| 32 | argv++; | 33 | argv++; |
| 33 | #endif | 34 | #endif |
| 34 | 35 | ||
| 36 | setup_common_bufsiz(); | ||
| 35 | do { | 37 | do { |
| 36 | int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input); | 38 | int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input); |
| 37 | 39 | ||
| @@ -43,7 +45,7 @@ int cksum_main(int argc UNUSED_PARAM, char **argv) | |||
| 43 | length = 0; | 45 | length = 0; |
| 44 | 46 | ||
| 45 | #define read_buf bb_common_bufsiz1 | 47 | #define read_buf bb_common_bufsiz1 |
| 46 | while ((bytes_read = safe_read(fd, read_buf, sizeof(read_buf))) > 0) { | 48 | while ((bytes_read = safe_read(fd, read_buf, COMMON_BUFSIZE)) > 0) { |
| 47 | length += bytes_read; | 49 | length += bytes_read; |
| 48 | crc = crc32_block_endian1(crc, read_buf, bytes_read, crc32_table); | 50 | crc = crc32_block_endian1(crc, read_buf, bytes_read, crc32_table); |
| 49 | } | 51 | } |
diff --git a/coreutils/date.c b/coreutils/date.c index 7965775fe..ff3214d85 100644 --- a/coreutils/date.c +++ b/coreutils/date.c | |||
| @@ -138,6 +138,7 @@ | |||
| 138 | //usage: "Wed Apr 12 18:52:41 MDT 2000\n" | 138 | //usage: "Wed Apr 12 18:52:41 MDT 2000\n" |
| 139 | 139 | ||
| 140 | #include "libbb.h" | 140 | #include "libbb.h" |
| 141 | #include "common_bufsiz.h" | ||
| 141 | #if ENABLE_FEATURE_DATE_NANO | 142 | #if ENABLE_FEATURE_DATE_NANO |
| 142 | # include <sys/syscall.h> | 143 | # include <sys/syscall.h> |
| 143 | #endif | 144 | #endif |
| @@ -368,6 +369,7 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
| 368 | #endif | 369 | #endif |
| 369 | 370 | ||
| 370 | #define date_buf bb_common_bufsiz1 | 371 | #define date_buf bb_common_bufsiz1 |
| 372 | setup_common_bufsiz(); | ||
| 371 | if (*fmt_dt2str == '\0') { | 373 | if (*fmt_dt2str == '\0') { |
| 372 | /* With no format string, just print a blank line */ | 374 | /* With no format string, just print a blank line */ |
| 373 | date_buf[0] = '\0'; | 375 | date_buf[0] = '\0'; |
| @@ -377,7 +379,7 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
| 377 | fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S"; | 379 | fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S"; |
| 378 | } | 380 | } |
| 379 | /* Generate output string */ | 381 | /* Generate output string */ |
| 380 | strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time); | 382 | strftime(date_buf, COMMON_BUFSIZE, fmt_dt2str, &tm_time); |
| 381 | } | 383 | } |
| 382 | puts(date_buf); | 384 | puts(date_buf); |
| 383 | 385 | ||
diff --git a/coreutils/dd.c b/coreutils/dd.c index 7bd3e2084..00139773e 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c | |||
| @@ -91,6 +91,7 @@ | |||
| 91 | //usage: "4+0 records out\n" | 91 | //usage: "4+0 records out\n" |
| 92 | 92 | ||
| 93 | #include "libbb.h" | 93 | #include "libbb.h" |
| 94 | #include "common_bufsiz.h" | ||
| 94 | 95 | ||
| 95 | /* This is a NOEXEC applet. Be very careful! */ | 96 | /* This is a NOEXEC applet. Be very careful! */ |
| 96 | 97 | ||
| @@ -108,8 +109,9 @@ struct globals { | |||
| 108 | #endif | 109 | #endif |
| 109 | int flags; | 110 | int flags; |
| 110 | } FIX_ALIASING; | 111 | } FIX_ALIASING; |
| 111 | #define G (*(struct globals*)&bb_common_bufsiz1) | 112 | #define G (*(struct globals*)bb_common_bufsiz1) |
| 112 | #define INIT_G() do { \ | 113 | #define INIT_G() do { \ |
| 114 | setup_common_bufsiz(); \ | ||
| 113 | /* we have to zero it out because of NOEXEC */ \ | 115 | /* we have to zero it out because of NOEXEC */ \ |
| 114 | memset(&G, 0, sizeof(G)); \ | 116 | memset(&G, 0, sizeof(G)); \ |
| 115 | } while (0) | 117 | } while (0) |
diff --git a/coreutils/du.c b/coreutils/du.c index 1889c16bb..1240bcbbc 100644 --- a/coreutils/du.c +++ b/coreutils/du.c | |||
| @@ -58,6 +58,7 @@ | |||
| 58 | //usage: "2417 .\n" | 58 | //usage: "2417 .\n" |
| 59 | 59 | ||
| 60 | #include "libbb.h" | 60 | #include "libbb.h" |
| 61 | #include "common_bufsiz.h" | ||
| 61 | 62 | ||
| 62 | enum { | 63 | enum { |
| 63 | OPT_a_files_too = (1 << 0), | 64 | OPT_a_files_too = (1 << 0), |
| @@ -85,8 +86,8 @@ struct globals { | |||
| 85 | int du_depth; | 86 | int du_depth; |
| 86 | dev_t dir_dev; | 87 | dev_t dir_dev; |
| 87 | } FIX_ALIASING; | 88 | } FIX_ALIASING; |
| 88 | #define G (*(struct globals*)&bb_common_bufsiz1) | 89 | #define G (*(struct globals*)bb_common_bufsiz1) |
| 89 | #define INIT_G() do { } while (0) | 90 | #define INIT_G() do { setup_common_bufsiz(); } while (0) |
| 90 | 91 | ||
| 91 | 92 | ||
| 92 | static void print(unsigned long long size, const char *filename) | 93 | static void print(unsigned long long size, const char *filename) |
diff --git a/coreutils/expr.c b/coreutils/expr.c index c986f9327..ce6b2d189 100644 --- a/coreutils/expr.c +++ b/coreutils/expr.c | |||
| @@ -61,6 +61,7 @@ | |||
| 61 | //usage: "of characters matched or 0." | 61 | //usage: "of characters matched or 0." |
| 62 | 62 | ||
| 63 | #include "libbb.h" | 63 | #include "libbb.h" |
| 64 | #include "common_bufsiz.h" | ||
| 64 | #include "xregex.h" | 65 | #include "xregex.h" |
| 65 | 66 | ||
| 66 | #if ENABLE_EXPR_MATH_SUPPORT_64 | 67 | #if ENABLE_EXPR_MATH_SUPPORT_64 |
| @@ -99,8 +100,8 @@ typedef struct valinfo VALUE; | |||
| 99 | struct globals { | 100 | struct globals { |
| 100 | char **args; | 101 | char **args; |
| 101 | } FIX_ALIASING; | 102 | } FIX_ALIASING; |
| 102 | #define G (*(struct globals*)&bb_common_bufsiz1) | 103 | #define G (*(struct globals*)bb_common_bufsiz1) |
| 103 | #define INIT_G() do { } while (0) | 104 | #define INIT_G() do { setup_common_bufsiz(); } while (0) |
| 104 | 105 | ||
| 105 | /* forward declarations */ | 106 | /* forward declarations */ |
| 106 | static VALUE *eval(void); | 107 | static VALUE *eval(void); |
diff --git a/coreutils/ls.c b/coreutils/ls.c index 20bd61860..344b4e61e 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
| @@ -93,6 +93,7 @@ | |||
| 93 | //usage: ) | 93 | //usage: ) |
| 94 | 94 | ||
| 95 | #include "libbb.h" | 95 | #include "libbb.h" |
| 96 | #include "common_bufsiz.h" | ||
| 96 | #include "unicode.h" | 97 | #include "unicode.h" |
| 97 | 98 | ||
| 98 | 99 | ||
| @@ -365,8 +366,9 @@ struct globals { | |||
| 365 | time_t current_time_t; | 366 | time_t current_time_t; |
| 366 | #endif | 367 | #endif |
| 367 | } FIX_ALIASING; | 368 | } FIX_ALIASING; |
| 368 | #define G (*(struct globals*)&bb_common_bufsiz1) | 369 | #define G (*(struct globals*)bb_common_bufsiz1) |
| 369 | #define INIT_G() do { \ | 370 | #define INIT_G() do { \ |
| 371 | setup_common_bufsiz(); \ | ||
| 370 | /* we have to zero it out because of NOEXEC */ \ | 372 | /* we have to zero it out because of NOEXEC */ \ |
| 371 | memset(&G, 0, sizeof(G)); \ | 373 | memset(&G, 0, sizeof(G)); \ |
| 372 | IF_FEATURE_AUTOWIDTH(G_terminal_width = TERMINAL_WIDTH;) \ | 374 | IF_FEATURE_AUTOWIDTH(G_terminal_width = TERMINAL_WIDTH;) \ |
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c index 3e0423a3d..a5b3e99f7 100644 --- a/coreutils/od_bloaty.c +++ b/coreutils/od_bloaty.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | /* #include "libbb.h" - done in od.c */ | 22 | /* #include "libbb.h" - done in od.c */ |
| 23 | #include "common_bufsiz.h" | ||
| 23 | #define assert(a) ((void)0) | 24 | #define assert(a) ((void)0) |
| 24 | 25 | ||
| 25 | 26 | ||
| @@ -221,8 +222,9 @@ struct globals { | |||
| 221 | #if !ENABLE_LONG_OPTS | 222 | #if !ENABLE_LONG_OPTS |
| 222 | enum { G_pseudo_offset = 0 }; | 223 | enum { G_pseudo_offset = 0 }; |
| 223 | #endif | 224 | #endif |
| 224 | #define G (*(struct globals*)&bb_common_bufsiz1) | 225 | #define G (*(struct globals*)bb_common_bufsiz1) |
| 225 | #define INIT_G() do { \ | 226 | #define INIT_G() do { \ |
| 227 | setup_common_bufsiz(); \ | ||
| 226 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | 228 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ |
| 227 | G.bytes_per_block = 32; \ | 229 | G.bytes_per_block = 32; \ |
| 228 | } while (0) | 230 | } while (0) |
diff --git a/coreutils/split.c b/coreutils/split.c index 1e1673efb..e67c3de66 100644 --- a/coreutils/split.c +++ b/coreutils/split.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | //usage: "$ cat TODO | split -a 2 -l 2 TODO_\n" | 22 | //usage: "$ cat TODO | split -a 2 -l 2 TODO_\n" |
| 23 | 23 | ||
| 24 | #include "libbb.h" | 24 | #include "libbb.h" |
| 25 | #include "common_bufsiz.h" | ||
| 25 | 26 | ||
| 26 | #if ENABLE_FEATURE_SPLIT_FANCY | 27 | #if ENABLE_FEATURE_SPLIT_FANCY |
| 27 | static const struct suffix_mult split_suffixes[] = { | 28 | static const struct suffix_mult split_suffixes[] = { |
| @@ -78,6 +79,8 @@ int split_main(int argc UNUSED_PARAM, char **argv) | |||
| 78 | ssize_t bytes_read, to_write; | 79 | ssize_t bytes_read, to_write; |
| 79 | char *src; | 80 | char *src; |
| 80 | 81 | ||
| 82 | setup_common_bufsiz(); | ||
| 83 | |||
| 81 | opt_complementary = "?2:a+"; /* max 2 args; -a N */ | 84 | opt_complementary = "?2:a+"; /* max 2 args; -a N */ |
| 82 | opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len); | 85 | opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len); |
| 83 | 86 | ||
diff --git a/coreutils/stat.c b/coreutils/stat.c index be2723d13..f608045d7 100644 --- a/coreutils/stat.c +++ b/coreutils/stat.c | |||
| @@ -102,6 +102,7 @@ | |||
| 102 | //usage: ) | 102 | //usage: ) |
| 103 | 103 | ||
| 104 | #include "libbb.h" | 104 | #include "libbb.h" |
| 105 | #include "common_bufsiz.h" | ||
| 105 | 106 | ||
| 106 | enum { | 107 | enum { |
| 107 | OPT_TERSE = (1 << 0), | 108 | OPT_TERSE = (1 << 0), |
| @@ -157,8 +158,8 @@ static const char *human_time(time_t t) | |||
| 157 | 158 | ||
| 158 | /*static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;*/ | 159 | /*static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;*/ |
| 159 | #define buf bb_common_bufsiz1 | 160 | #define buf bb_common_bufsiz1 |
| 160 | 161 | setup_common_bufsiz(); | |
| 161 | strcpy(strftime_YYYYMMDDHHMMSS(buf, sizeof(buf), &t), ".000000000"); | 162 | strcpy(strftime_YYYYMMDDHHMMSS(buf, COMMON_BUFSIZE, &t), ".000000000"); |
| 162 | return buf; | 163 | return buf; |
| 163 | #undef buf | 164 | #undef buf |
| 164 | } | 165 | } |
diff --git a/coreutils/stty.c b/coreutils/stty.c index b63b0b91a..52967ea8f 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | //usage: "\n [SETTING] See manpage" | 32 | //usage: "\n [SETTING] See manpage" |
| 33 | 33 | ||
| 34 | #include "libbb.h" | 34 | #include "libbb.h" |
| 35 | #include "common_bufsiz.h" | ||
| 35 | 36 | ||
| 36 | #ifndef _POSIX_VDISABLE | 37 | #ifndef _POSIX_VDISABLE |
| 37 | # define _POSIX_VDISABLE ((unsigned char) 0) | 38 | # define _POSIX_VDISABLE ((unsigned char) 0) |
| @@ -317,7 +318,7 @@ enum { | |||
| 317 | #define MI_ENTRY(N,T,F,B,M) N "\0" | 318 | #define MI_ENTRY(N,T,F,B,M) N "\0" |
| 318 | 319 | ||
| 319 | /* Mode names given on command line */ | 320 | /* Mode names given on command line */ |
| 320 | static const char mode_name[] = | 321 | static const char mode_name[] ALIGN1 = |
| 321 | MI_ENTRY("evenp", combination, REV | OMIT, 0, 0 ) | 322 | MI_ENTRY("evenp", combination, REV | OMIT, 0, 0 ) |
| 322 | MI_ENTRY("parity", combination, REV | OMIT, 0, 0 ) | 323 | MI_ENTRY("parity", combination, REV | OMIT, 0, 0 ) |
| 323 | MI_ENTRY("oddp", combination, REV | OMIT, 0, 0 ) | 324 | MI_ENTRY("oddp", combination, REV | OMIT, 0, 0 ) |
| @@ -680,7 +681,7 @@ enum { | |||
| 680 | #define CI_ENTRY(n,s,o) n "\0" | 681 | #define CI_ENTRY(n,s,o) n "\0" |
| 681 | 682 | ||
| 682 | /* Name given on command line */ | 683 | /* Name given on command line */ |
| 683 | static const char control_name[] = | 684 | static const char control_name[] ALIGN1 = |
| 684 | CI_ENTRY("intr", CINTR, VINTR ) | 685 | CI_ENTRY("intr", CINTR, VINTR ) |
| 685 | CI_ENTRY("quit", CQUIT, VQUIT ) | 686 | CI_ENTRY("quit", CQUIT, VQUIT ) |
| 686 | CI_ENTRY("erase", CERASE, VERASE ) | 687 | CI_ENTRY("erase", CERASE, VERASE ) |
| @@ -722,7 +723,7 @@ static const char control_name[] = | |||
| 722 | #undef CI_ENTRY | 723 | #undef CI_ENTRY |
| 723 | #define CI_ENTRY(n,s,o) { s, o }, | 724 | #define CI_ENTRY(n,s,o) { s, o }, |
| 724 | 725 | ||
| 725 | static const struct control_info control_info[] = { | 726 | static const struct control_info control_info[] ALIGN2 = { |
| 726 | /* This should be verbatim cut-n-paste copy of the above CI_ENTRYs */ | 727 | /* This should be verbatim cut-n-paste copy of the above CI_ENTRYs */ |
| 727 | CI_ENTRY("intr", CINTR, VINTR ) | 728 | CI_ENTRY("intr", CINTR, VINTR ) |
| 728 | CI_ENTRY("quit", CQUIT, VQUIT ) | 729 | CI_ENTRY("quit", CQUIT, VQUIT ) |
| @@ -775,7 +776,7 @@ struct globals { | |||
| 775 | unsigned current_col; | 776 | unsigned current_col; |
| 776 | char buf[10]; | 777 | char buf[10]; |
| 777 | } FIX_ALIASING; | 778 | } FIX_ALIASING; |
| 778 | #define G (*(struct globals*)&bb_common_bufsiz1) | 779 | #define G (*(struct globals*)bb_common_bufsiz1) |
| 779 | #define INIT_G() do { \ | 780 | #define INIT_G() do { \ |
| 780 | G.device_name = bb_msg_standard_input; \ | 781 | G.device_name = bb_msg_standard_input; \ |
| 781 | G.max_col = 80; \ | 782 | G.max_col = 80; \ |
diff --git a/coreutils/sum.c b/coreutils/sum.c index deb068e10..ec9ed2a11 100644 --- a/coreutils/sum.c +++ b/coreutils/sum.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | //usage: "\n -s Use System V sum algorithm (512byte blocks)" | 21 | //usage: "\n -s Use System V sum algorithm (512byte blocks)" |
| 22 | 22 | ||
| 23 | #include "libbb.h" | 23 | #include "libbb.h" |
| 24 | #include "common_bufsiz.h" | ||
| 24 | 25 | ||
| 25 | enum { SUM_BSD, PRINT_NAME, SUM_SYSV }; | 26 | enum { SUM_BSD, PRINT_NAME, SUM_SYSV }; |
| 26 | 27 | ||
| @@ -30,18 +31,20 @@ enum { SUM_BSD, PRINT_NAME, SUM_SYSV }; | |||
| 30 | /* Return 1 if successful. */ | 31 | /* Return 1 if successful. */ |
| 31 | static unsigned sum_file(const char *file, unsigned type) | 32 | static unsigned sum_file(const char *file, unsigned type) |
| 32 | { | 33 | { |
| 33 | #define buf bb_common_bufsiz1 | ||
| 34 | unsigned long long total_bytes = 0; | 34 | unsigned long long total_bytes = 0; |
| 35 | int fd, r; | 35 | int fd, r; |
| 36 | /* The sum of all the input bytes, modulo (UINT_MAX + 1). */ | 36 | /* The sum of all the input bytes, modulo (UINT_MAX + 1). */ |
| 37 | unsigned s = 0; | 37 | unsigned s = 0; |
| 38 | 38 | ||
| 39 | #define buf bb_common_bufsiz1 | ||
| 40 | setup_common_bufsiz(); | ||
| 41 | |||
| 39 | fd = open_or_warn_stdin(file); | 42 | fd = open_or_warn_stdin(file); |
| 40 | if (fd == -1) | 43 | if (fd == -1) |
| 41 | return 0; | 44 | return 0; |
| 42 | 45 | ||
| 43 | while (1) { | 46 | while (1) { |
| 44 | size_t bytes_read = safe_read(fd, buf, BUFSIZ); | 47 | size_t bytes_read = safe_read(fd, buf, COMMON_BUFSIZE); |
| 45 | 48 | ||
| 46 | if ((ssize_t)bytes_read <= 0) { | 49 | if ((ssize_t)bytes_read <= 0) { |
| 47 | r = (fd && close(fd) != 0); | 50 | r = (fd && close(fd) != 0); |
diff --git a/coreutils/tail.c b/coreutils/tail.c index e352ab627..39f87679e 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c | |||
| @@ -49,13 +49,14 @@ | |||
| 49 | //usage: "nameserver 10.0.0.1\n" | 49 | //usage: "nameserver 10.0.0.1\n" |
| 50 | 50 | ||
| 51 | #include "libbb.h" | 51 | #include "libbb.h" |
| 52 | #include "common_bufsiz.h" | ||
| 52 | 53 | ||
| 53 | struct globals { | 54 | struct globals { |
| 54 | bool from_top; | 55 | bool from_top; |
| 55 | bool exitcode; | 56 | bool exitcode; |
| 56 | } FIX_ALIASING; | 57 | } FIX_ALIASING; |
| 57 | #define G (*(struct globals*)&bb_common_bufsiz1) | 58 | #define G (*(struct globals*)bb_common_bufsiz1) |
| 58 | #define INIT_G() do { } while (0) | 59 | #define INIT_G() do { setup_common_bufsiz(); } while (0) |
| 59 | 60 | ||
| 60 | static void tail_xprint_header(const char *fmt, const char *filename) | 61 | static void tail_xprint_header(const char *fmt, const char *filename) |
| 61 | { | 62 | { |
diff --git a/coreutils/tee.c b/coreutils/tee.c index 48cc0508f..a68e9446f 100644 --- a/coreutils/tee.c +++ b/coreutils/tee.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | //usage: "Hello\n" | 23 | //usage: "Hello\n" |
| 24 | 24 | ||
| 25 | #include "libbb.h" | 25 | #include "libbb.h" |
| 26 | #include "common_bufsiz.h" | ||
| 26 | 27 | ||
| 27 | int tee_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 28 | int tee_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 28 | int tee_main(int argc, char **argv) | 29 | int tee_main(int argc, char **argv) |
| @@ -37,6 +38,7 @@ int tee_main(int argc, char **argv) | |||
| 37 | #if ENABLE_FEATURE_TEE_USE_BLOCK_IO | 38 | #if ENABLE_FEATURE_TEE_USE_BLOCK_IO |
| 38 | ssize_t c; | 39 | ssize_t c; |
| 39 | # define buf bb_common_bufsiz1 | 40 | # define buf bb_common_bufsiz1 |
| 41 | setup_common_bufsiz(); | ||
| 40 | #else | 42 | #else |
| 41 | int c; | 43 | int c; |
| 42 | #endif | 44 | #endif |
| @@ -79,7 +81,7 @@ int tee_main(int argc, char **argv) | |||
| 79 | /* names[0] will be filled later */ | 81 | /* names[0] will be filled later */ |
| 80 | 82 | ||
| 81 | #if ENABLE_FEATURE_TEE_USE_BLOCK_IO | 83 | #if ENABLE_FEATURE_TEE_USE_BLOCK_IO |
| 82 | while ((c = safe_read(STDIN_FILENO, buf, sizeof(buf))) > 0) { | 84 | while ((c = safe_read(STDIN_FILENO, buf, COMMON_BUFSIZE)) > 0) { |
| 83 | fp = files; | 85 | fp = files; |
| 84 | do | 86 | do |
| 85 | fwrite(buf, 1, c, *fp); | 87 | fwrite(buf, 1, c, *fp); |
