summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenis Vlasenko2007-09-27 10:20:47 +0000
committerDenis Vlasenko2007-09-27 10:20:47 +0000
commit4daad9004d8f07991516970a1cbd77756fae7041 (patch)
treef1a17e4b168ef8fdf8af92ac5ce8deba89d38db2 /coreutils
parent1acdc89e992eb3f0548ff48ba586b31c9a0ae232 (diff)
downloadbusybox-4daad9004d8f07991516970a1cbd77756fae7041.zip
busybox-4daad9004d8f07991516970a1cbd77756fae7041.tar.gz
introduce bb_putchar(). saves ~1800 on uclibc (less on glibc).
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/cal.c2
-rw-r--r--coreutils/catv.c4
-rw-r--r--coreutils/echo.c6
-rw-r--r--coreutils/fold.c2
-rw-r--r--coreutils/id.c4
-rw-r--r--coreutils/ls.c2
-rw-r--r--coreutils/od_bloaty.c2
-rw-r--r--coreutils/printf.c10
-rw-r--r--coreutils/stat.c6
-rw-r--r--coreutils/stty.c6
-rw-r--r--coreutils/tee.c3
-rw-r--r--coreutils/uname.c4
-rw-r--r--coreutils/uuencode.c4
13 files changed, 28 insertions, 27 deletions
diff --git a/coreutils/cal.c b/coreutils/cal.c
index 35a5631..3116e1e 100644
--- a/coreutils/cal.c
+++ b/coreutils/cal.c
@@ -167,7 +167,7 @@ int cal_main(int argc, char **argv)
if (!julian) {
printf("%*s%s", HEAD_SEP, "", day_headings);
}
- putchar('\n');
+ bb_putchar('\n');
for (row = 0; row < (6*7); row += 7) {
for (which_cal = 0; which_cal < 3-julian; which_cal++) {
dp = days[month + which_cal] + row;
diff --git a/coreutils/catv.c b/coreutils/catv.c
index ce92746..5d5a550 100644
--- a/coreutils/catv.c
+++ b/coreutils/catv.c
@@ -62,13 +62,13 @@ int catv_main(int argc, char **argv)
if (c < 32) {
if (c == 10) {
if (flags & CATV_OPT_e)
- putchar('$');
+ bb_putchar('$');
} else if (flags & (c==9 ? CATV_OPT_t : CATV_OPT_v)) {
printf("^%c", c+'@');
continue;
}
}
- putchar(c);
+ bb_putchar(c);
}
}
if (ENABLE_FEATURE_CLEAN_UP && fd)
diff --git a/coreutils/echo.c b/coreutils/echo.c
index 085e851..851d2ef 100644
--- a/coreutils/echo.c
+++ b/coreutils/echo.c
@@ -100,18 +100,18 @@ int bb_echo(char **argv)
c = bb_process_escape_sequence(&arg);
}
}
- putchar(c);
+ bb_putchar(c);
}
arg = *++argv;
if (!arg)
break;
- putchar(' ');
+ bb_putchar(' ');
}
newline_ret:
if (nflag) {
- putchar('\n');
+ bb_putchar('\n');
}
ret:
return fflush(stdout);
diff --git a/coreutils/fold.c b/coreutils/fold.c
index 6e422de..a75f466 100644
--- a/coreutils/fold.c
+++ b/coreutils/fold.c
@@ -115,7 +115,7 @@ int fold_main(int argc, char **argv)
/* Found a blank. Don't output the part after it. */
logical_end++;
fwrite(line_out, sizeof(char), (size_t) logical_end, stdout);
- putchar('\n');
+ bb_putchar('\n');
/* Move the remainder to the beginning of the next line.
The areas being copied here might overlap. */
memmove(line_out, line_out + logical_end, offset_out - logical_end);
diff --git a/coreutils/id.c b/coreutils/id.c
index 1cc8c4d..536e946 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -102,7 +102,7 @@ int id_main(int argc, char **argv)
/* Print full info like GNU id */
/* bb_getpwuid(0) doesn't exit on failure (returns NULL) */
status = printf_full(uid, bb_getpwuid(NULL, 0, uid), 'u');
- putchar(' ');
+ bb_putchar(' ');
status |= printf_full(gid, bb_getgrgid(NULL, 0, gid), 'g');
#if ENABLE_SELINUX
@@ -121,6 +121,6 @@ int id_main(int argc, char **argv)
}
#endif
- putchar('\n');
+ bb_putchar('\n');
fflush_stdout_and_exit(status);
}
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 4adf523..a4acc98 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -451,7 +451,7 @@ static void showdirs(struct dnode **dn, int ndirs, int first)
for (i = 0; i < ndirs; i++) {
if (all_fmt & (DISP_DIRNAME | DISP_RECURSIVE)) {
if (!first)
- puts("");
+ bb_putchar('\n');
first = 0;
printf("%s:\n", dn[i]->fullname);
}
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index 44d0f2d..1bd1b0c 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -1183,7 +1183,7 @@ dump_strings(void)
case '\r': fputs("\\r", stdout); break;
case '\t': fputs("\\t", stdout); break;
case '\v': fputs("\\v", stdout); break;
- default: putc(c, stdout);
+ default: bb_putchar(c);
}
}
putchar('\n');
diff --git a/coreutils/printf.c b/coreutils/printf.c
index d0cf5a6..d5ef32e 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -99,9 +99,9 @@ static void print_esc_string(char *str)
for (; *str; str++) {
if (*str == '\\') {
str++;
- putchar(bb_process_escape_sequence((const char **)&str));
+ bb_putchar(bb_process_escape_sequence((const char **)&str));
} else {
- putchar(*str);
+ bb_putchar(*str);
}
}
@@ -205,7 +205,7 @@ static int print_formatted(char *format, int argc, char **argv)
direc_length = 1;
field_width = precision = -1;
if (*f == '%') {
- putchar('%');
+ bb_putchar('%');
break;
}
if (*f == 'b') {
@@ -274,11 +274,11 @@ static int print_formatted(char *format, int argc, char **argv)
case '\\':
if (*++f == 'c')
exit(0);
- putchar(bb_process_escape_sequence((const char **)&f));
+ bb_putchar(bb_process_escape_sequence((const char **)&f));
f--;
break;
default:
- putchar(*f);
+ bb_putchar(*f);
}
}
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 18e8e07..a0424d9 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -321,7 +321,7 @@ static void print_it(char const *masterformat, char const *filename,
b = NULL;
/* fall through */
case '%':
- putchar('%');
+ bb_putchar('%');
break;
default:
print_func(dest, n_alloc, *p, filename, data USE_SELINUX(,scontext));
@@ -552,7 +552,7 @@ static bool do_stat(char const *filename, char const *format)
if (option_mask32 & OPT_SELINUX)
printf(" %lc\n", *scontext);
else
- putchar('\n');
+ bb_putchar('\n');
#endif
} else {
char *linkname = NULL;
@@ -586,7 +586,7 @@ static bool do_stat(char const *filename, char const *format)
(unsigned long) major(statbuf.st_rdev),
(unsigned long) minor(statbuf.st_rdev));
else
- putchar('\n');
+ bb_putchar('\n');
printf("Access: (%04lo/%10.10s) Uid: (%5lu/%8s) Gid: (%5lu/%8s)\n",
(unsigned long) (statbuf.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)),
bb_mode_string(statbuf.st_mode),
diff --git a/coreutils/stty.c b/coreutils/stty.c
index 863f28d..1f0d422 100644
--- a/coreutils/stty.c
+++ b/coreutils/stty.c
@@ -475,10 +475,10 @@ static void wrapf(const char *message, ...)
G.current_col++;
if (buf[0] != '\n') {
if (G.current_col + buflen >= max_col) {
- putchar('\n');
+ bb_putchar('\n');
G.current_col = 0;
} else
- putchar(' ');
+ bb_putchar(' ');
}
}
fputs(buf, stdout);
@@ -618,7 +618,7 @@ static void display_recoverable(const struct termios *mode,
(unsigned long) mode->c_cflag, (unsigned long) mode->c_lflag);
for (i = 0; i < NCCS; ++i)
printf(":%x", (unsigned int) mode->c_cc[i]);
- putchar('\n');
+ bb_putchar('\n');
}
static void display_speed(const struct termios *mode, int fancy)
diff --git a/coreutils/tee.c b/coreutils/tee.c
index d253028..8313258 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -22,6 +22,7 @@ int tee_main(int argc, char **argv)
char **names;
char **np;
char retval;
+//TODO: make unconditional
#if ENABLE_FEATURE_TEE_USE_BLOCK_IO
ssize_t c;
# define buf bb_common_bufsiz1
@@ -62,7 +63,7 @@ int tee_main(int argc, char **argv)
/* names[0] will be filled later */
#if ENABLE_FEATURE_TEE_USE_BLOCK_IO
- while ((c = safe_read(STDIN_FILENO, buf, BUFSIZ)) > 0) {
+ while ((c = safe_read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
fp = files;
do
fwrite(buf, 1, c, *fp++);
diff --git a/coreutils/uname.c b/coreutils/uname.c
index e4724c8..e70b1f9 100644
--- a/coreutils/uname.c
+++ b/coreutils/uname.c
@@ -91,12 +91,12 @@ int uname_main(int argc, char **argv)
if (toprint & 1) {
printf(((char *)(&uname_info)) + *delta);
if (toprint > 1) {
- putchar(' ');
+ bb_putchar(' ');
}
}
++delta;
} while (toprint >>= 1);
- putchar('\n');
+ bb_putchar('\n');
fflush_stdout_and_exit(EXIT_SUCCESS);
}
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c
index 56d6882..17def8d 100644
--- a/coreutils/uuencode.c
+++ b/coreutils/uuencode.c
@@ -48,9 +48,9 @@ int uuencode_main(int argc, char **argv)
bb_perror_msg_and_die(bb_msg_read_error);
/* Encode the buffer we just read in */
bb_uuencode(dst_buf, src_buf, size, tbl);
- putchar('\n');
+ bb_putchar('\n');
if (tbl == bb_uuenc_tbl_std) {
- putchar(tbl[size]);
+ bb_putchar(tbl[size]);
}
fflush(stdout);
xwrite(STDOUT_FILENO, dst_buf, 4 * ((size + 2) / 3));