*: hopefully all setup_common_bufsiz() are in place
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/coreutils/catv.c b/coreutils/catv.c
index 801d245..0e71368 100644
--- a/coreutils/catv.c
+++ b/coreutils/catv.c
@@ -49,6 +49,9 @@
/* Read from stdin if there's nothing else to do. */
if (!argv[0])
*--argv = (char*)"-";
+
+#define read_buf bb_common_bufsiz1
+ setup_common_bufsiz();
do {
fd = open_or_warn_stdin(*argv);
if (fd < 0) {
@@ -58,7 +61,6 @@
for (;;) {
int i, res;
-#define read_buf bb_common_bufsiz1
res = read(fd, read_buf, COMMON_BUFSIZE);
if (res < 0)
retval = EXIT_FAILURE;
diff --git a/coreutils/cksum.c b/coreutils/cksum.c
index d8351e7..8a8a39f 100644
--- a/coreutils/cksum.c
+++ b/coreutils/cksum.c
@@ -33,6 +33,7 @@
argv++;
#endif
+ setup_common_bufsiz();
do {
int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input);
@@ -43,9 +44,8 @@
crc = 0;
length = 0;
-#define read_buf bb_common_bufsiz1
-#define sizeof_read_buf COMMON_BUFSIZE
- while ((bytes_read = safe_read(fd, read_buf, sizeof_read_buf)) > 0) {
+#define read_buf bb_common_bufsiz1
+ while ((bytes_read = safe_read(fd, read_buf, COMMON_BUFSIZE)) > 0) {
length += bytes_read;
crc = crc32_block_endian1(crc, read_buf, bytes_read, crc32_table);
}
diff --git a/coreutils/date.c b/coreutils/date.c
index 59b4b8f..ff3214d 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -368,8 +368,8 @@
}
#endif
-#define date_buf bb_common_bufsiz1
-#define sizeof_date_buf COMMON_BUFSIZE
+#define date_buf bb_common_bufsiz1
+ setup_common_bufsiz();
if (*fmt_dt2str == '\0') {
/* With no format string, just print a blank line */
date_buf[0] = '\0';
@@ -379,7 +379,7 @@
fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S";
}
/* Generate output string */
- strftime(date_buf, sizeof_date_buf, fmt_dt2str, &tm_time);
+ strftime(date_buf, COMMON_BUFSIZE, fmt_dt2str, &tm_time);
}
puts(date_buf);
diff --git a/coreutils/split.c b/coreutils/split.c
index b2da74e..e67c3de 100644
--- a/coreutils/split.c
+++ b/coreutils/split.c
@@ -79,6 +79,8 @@
ssize_t bytes_read, to_write;
char *src;
+ setup_common_bufsiz();
+
opt_complementary = "?2:a+"; /* max 2 args; -a N */
opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len);
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 78df9c9..ddcfcf2 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -158,10 +158,9 @@
/* coreutils 6.3 compat: */
/*static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;*/
-#define buf bb_common_bufsiz1
-#define sizeof_buf COMMON_BUFSIZE
-
- strcpy(strftime_YYYYMMDDHHMMSS(buf, sizeof_buf, &t), ".000000000");
+#define buf bb_common_bufsiz1
+ setup_common_bufsiz();
+ strcpy(strftime_YYYYMMDDHHMMSS(buf, COMMON_BUFSIZE, &t), ".000000000");
return buf;
#undef buf
}
diff --git a/coreutils/sum.c b/coreutils/sum.c
index cc66772..ec9ed2a 100644
--- a/coreutils/sum.c
+++ b/coreutils/sum.c
@@ -31,12 +31,14 @@
/* Return 1 if successful. */
static unsigned sum_file(const char *file, unsigned type)
{
-#define buf bb_common_bufsiz1
unsigned long long total_bytes = 0;
int fd, r;
/* The sum of all the input bytes, modulo (UINT_MAX + 1). */
unsigned s = 0;
+#define buf bb_common_bufsiz1
+ setup_common_bufsiz();
+
fd = open_or_warn_stdin(file);
if (fd == -1)
return 0;
diff --git a/coreutils/tee.c b/coreutils/tee.c
index a0e177c..a68e944 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -37,8 +37,8 @@
//TODO: make unconditional
#if ENABLE_FEATURE_TEE_USE_BLOCK_IO
ssize_t c;
-# define buf bb_common_bufsiz1
-# define sizeof_buf COMMON_BUFSIZE
+# define buf bb_common_bufsiz1
+ setup_common_bufsiz();
#else
int c;
#endif
@@ -81,7 +81,7 @@
/* names[0] will be filled later */
#if ENABLE_FEATURE_TEE_USE_BLOCK_IO
- while ((c = safe_read(STDIN_FILENO, buf, sizeof_buf)) > 0) {
+ while ((c = safe_read(STDIN_FILENO, buf, COMMON_BUFSIZE)) > 0) {
fp = files;
do
fwrite(buf, 1, c, *fp);