summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-09-27 10:20:47 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-09-27 10:20:47 +0000
commit4daad9004d8f07991516970a1cbd77756fae7041 (patch)
treef1a17e4b168ef8fdf8af92ac5ce8deba89d38db2 /coreutils
parent1acdc89e992eb3f0548ff48ba586b31c9a0ae232 (diff)
downloadbusybox-w32-4daad9004d8f07991516970a1cbd77756fae7041.tar.gz
busybox-w32-4daad9004d8f07991516970a1cbd77756fae7041.tar.bz2
busybox-w32-4daad9004d8f07991516970a1cbd77756fae7041.zip
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 35a563145..3116e1ebe 100644
--- a/coreutils/cal.c
+++ b/coreutils/cal.c
@@ -167,7 +167,7 @@ int cal_main(int argc, char **argv)
167 if (!julian) { 167 if (!julian) {
168 printf("%*s%s", HEAD_SEP, "", day_headings); 168 printf("%*s%s", HEAD_SEP, "", day_headings);
169 } 169 }
170 putchar('\n'); 170 bb_putchar('\n');
171 for (row = 0; row < (6*7); row += 7) { 171 for (row = 0; row < (6*7); row += 7) {
172 for (which_cal = 0; which_cal < 3-julian; which_cal++) { 172 for (which_cal = 0; which_cal < 3-julian; which_cal++) {
173 dp = days[month + which_cal] + row; 173 dp = days[month + which_cal] + row;
diff --git a/coreutils/catv.c b/coreutils/catv.c
index ce927465b..5d5a5500f 100644
--- a/coreutils/catv.c
+++ b/coreutils/catv.c
@@ -62,13 +62,13 @@ int catv_main(int argc, char **argv)
62 if (c < 32) { 62 if (c < 32) {
63 if (c == 10) { 63 if (c == 10) {
64 if (flags & CATV_OPT_e) 64 if (flags & CATV_OPT_e)
65 putchar('$'); 65 bb_putchar('$');
66 } else if (flags & (c==9 ? CATV_OPT_t : CATV_OPT_v)) { 66 } else if (flags & (c==9 ? CATV_OPT_t : CATV_OPT_v)) {
67 printf("^%c", c+'@'); 67 printf("^%c", c+'@');
68 continue; 68 continue;
69 } 69 }
70 } 70 }
71 putchar(c); 71 bb_putchar(c);
72 } 72 }
73 } 73 }
74 if (ENABLE_FEATURE_CLEAN_UP && fd) 74 if (ENABLE_FEATURE_CLEAN_UP && fd)
diff --git a/coreutils/echo.c b/coreutils/echo.c
index 085e8516c..851d2efb2 100644
--- a/coreutils/echo.c
+++ b/coreutils/echo.c
@@ -100,18 +100,18 @@ int bb_echo(char **argv)
100 c = bb_process_escape_sequence(&arg); 100 c = bb_process_escape_sequence(&arg);
101 } 101 }
102 } 102 }
103 putchar(c); 103 bb_putchar(c);
104 } 104 }
105 105
106 arg = *++argv; 106 arg = *++argv;
107 if (!arg) 107 if (!arg)
108 break; 108 break;
109 putchar(' '); 109 bb_putchar(' ');
110 } 110 }
111 111
112 newline_ret: 112 newline_ret:
113 if (nflag) { 113 if (nflag) {
114 putchar('\n'); 114 bb_putchar('\n');
115 } 115 }
116 ret: 116 ret:
117 return fflush(stdout); 117 return fflush(stdout);
diff --git a/coreutils/fold.c b/coreutils/fold.c
index 6e422de59..a75f4666e 100644
--- a/coreutils/fold.c
+++ b/coreutils/fold.c
@@ -115,7 +115,7 @@ int fold_main(int argc, char **argv)
115 /* Found a blank. Don't output the part after it. */ 115 /* Found a blank. Don't output the part after it. */
116 logical_end++; 116 logical_end++;
117 fwrite(line_out, sizeof(char), (size_t) logical_end, stdout); 117 fwrite(line_out, sizeof(char), (size_t) logical_end, stdout);
118 putchar('\n'); 118 bb_putchar('\n');
119 /* Move the remainder to the beginning of the next line. 119 /* Move the remainder to the beginning of the next line.
120 The areas being copied here might overlap. */ 120 The areas being copied here might overlap. */
121 memmove(line_out, line_out + logical_end, offset_out - logical_end); 121 memmove(line_out, line_out + logical_end, offset_out - logical_end);
diff --git a/coreutils/id.c b/coreutils/id.c
index 1cc8c4d1d..536e946c0 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -102,7 +102,7 @@ int id_main(int argc, char **argv)
102 /* Print full info like GNU id */ 102 /* Print full info like GNU id */
103 /* bb_getpwuid(0) doesn't exit on failure (returns NULL) */ 103 /* bb_getpwuid(0) doesn't exit on failure (returns NULL) */
104 status = printf_full(uid, bb_getpwuid(NULL, 0, uid), 'u'); 104 status = printf_full(uid, bb_getpwuid(NULL, 0, uid), 'u');
105 putchar(' '); 105 bb_putchar(' ');
106 status |= printf_full(gid, bb_getgrgid(NULL, 0, gid), 'g'); 106 status |= printf_full(gid, bb_getgrgid(NULL, 0, gid), 'g');
107 107
108#if ENABLE_SELINUX 108#if ENABLE_SELINUX
@@ -121,6 +121,6 @@ int id_main(int argc, char **argv)
121 } 121 }
122#endif 122#endif
123 123
124 putchar('\n'); 124 bb_putchar('\n');
125 fflush_stdout_and_exit(status); 125 fflush_stdout_and_exit(status);
126} 126}
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 4adf523d3..a4acc98ad 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -451,7 +451,7 @@ static void showdirs(struct dnode **dn, int ndirs, int first)
451 for (i = 0; i < ndirs; i++) { 451 for (i = 0; i < ndirs; i++) {
452 if (all_fmt & (DISP_DIRNAME | DISP_RECURSIVE)) { 452 if (all_fmt & (DISP_DIRNAME | DISP_RECURSIVE)) {
453 if (!first) 453 if (!first)
454 puts(""); 454 bb_putchar('\n');
455 first = 0; 455 first = 0;
456 printf("%s:\n", dn[i]->fullname); 456 printf("%s:\n", dn[i]->fullname);
457 } 457 }
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index 44d0f2db0..1bd1b0c84 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -1183,7 +1183,7 @@ dump_strings(void)
1183 case '\r': fputs("\\r", stdout); break; 1183 case '\r': fputs("\\r", stdout); break;
1184 case '\t': fputs("\\t", stdout); break; 1184 case '\t': fputs("\\t", stdout); break;
1185 case '\v': fputs("\\v", stdout); break; 1185 case '\v': fputs("\\v", stdout); break;
1186 default: putc(c, stdout); 1186 default: bb_putchar(c);
1187 } 1187 }
1188 } 1188 }
1189 putchar('\n'); 1189 putchar('\n');
diff --git a/coreutils/printf.c b/coreutils/printf.c
index d0cf5a671..d5ef32e8c 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -99,9 +99,9 @@ static void print_esc_string(char *str)
99 for (; *str; str++) { 99 for (; *str; str++) {
100 if (*str == '\\') { 100 if (*str == '\\') {
101 str++; 101 str++;
102 putchar(bb_process_escape_sequence((const char **)&str)); 102 bb_putchar(bb_process_escape_sequence((const char **)&str));
103 } else { 103 } else {
104 putchar(*str); 104 bb_putchar(*str);
105 } 105 }
106 106
107 } 107 }
@@ -205,7 +205,7 @@ static int print_formatted(char *format, int argc, char **argv)
205 direc_length = 1; 205 direc_length = 1;
206 field_width = precision = -1; 206 field_width = precision = -1;
207 if (*f == '%') { 207 if (*f == '%') {
208 putchar('%'); 208 bb_putchar('%');
209 break; 209 break;
210 } 210 }
211 if (*f == 'b') { 211 if (*f == 'b') {
@@ -274,11 +274,11 @@ static int print_formatted(char *format, int argc, char **argv)
274 case '\\': 274 case '\\':
275 if (*++f == 'c') 275 if (*++f == 'c')
276 exit(0); 276 exit(0);
277 putchar(bb_process_escape_sequence((const char **)&f)); 277 bb_putchar(bb_process_escape_sequence((const char **)&f));
278 f--; 278 f--;
279 break; 279 break;
280 default: 280 default:
281 putchar(*f); 281 bb_putchar(*f);
282 } 282 }
283 } 283 }
284 284
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 18e8e076c..a0424d936 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -321,7 +321,7 @@ static void print_it(char const *masterformat, char const *filename,
321 b = NULL; 321 b = NULL;
322 /* fall through */ 322 /* fall through */
323 case '%': 323 case '%':
324 putchar('%'); 324 bb_putchar('%');
325 break; 325 break;
326 default: 326 default:
327 print_func(dest, n_alloc, *p, filename, data USE_SELINUX(,scontext)); 327 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)
552 if (option_mask32 & OPT_SELINUX) 552 if (option_mask32 & OPT_SELINUX)
553 printf(" %lc\n", *scontext); 553 printf(" %lc\n", *scontext);
554 else 554 else
555 putchar('\n'); 555 bb_putchar('\n');
556#endif 556#endif
557 } else { 557 } else {
558 char *linkname = NULL; 558 char *linkname = NULL;
@@ -586,7 +586,7 @@ static bool do_stat(char const *filename, char const *format)
586 (unsigned long) major(statbuf.st_rdev), 586 (unsigned long) major(statbuf.st_rdev),
587 (unsigned long) minor(statbuf.st_rdev)); 587 (unsigned long) minor(statbuf.st_rdev));
588 else 588 else
589 putchar('\n'); 589 bb_putchar('\n');
590 printf("Access: (%04lo/%10.10s) Uid: (%5lu/%8s) Gid: (%5lu/%8s)\n", 590 printf("Access: (%04lo/%10.10s) Uid: (%5lu/%8s) Gid: (%5lu/%8s)\n",
591 (unsigned long) (statbuf.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)), 591 (unsigned long) (statbuf.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)),
592 bb_mode_string(statbuf.st_mode), 592 bb_mode_string(statbuf.st_mode),
diff --git a/coreutils/stty.c b/coreutils/stty.c
index 863f28d92..1f0d4227e 100644
--- a/coreutils/stty.c
+++ b/coreutils/stty.c
@@ -475,10 +475,10 @@ static void wrapf(const char *message, ...)
475 G.current_col++; 475 G.current_col++;
476 if (buf[0] != '\n') { 476 if (buf[0] != '\n') {
477 if (G.current_col + buflen >= max_col) { 477 if (G.current_col + buflen >= max_col) {
478 putchar('\n'); 478 bb_putchar('\n');
479 G.current_col = 0; 479 G.current_col = 0;
480 } else 480 } else
481 putchar(' '); 481 bb_putchar(' ');
482 } 482 }
483 } 483 }
484 fputs(buf, stdout); 484 fputs(buf, stdout);
@@ -618,7 +618,7 @@ static void display_recoverable(const struct termios *mode,
618 (unsigned long) mode->c_cflag, (unsigned long) mode->c_lflag); 618 (unsigned long) mode->c_cflag, (unsigned long) mode->c_lflag);
619 for (i = 0; i < NCCS; ++i) 619 for (i = 0; i < NCCS; ++i)
620 printf(":%x", (unsigned int) mode->c_cc[i]); 620 printf(":%x", (unsigned int) mode->c_cc[i]);
621 putchar('\n'); 621 bb_putchar('\n');
622} 622}
623 623
624static void display_speed(const struct termios *mode, int fancy) 624static void display_speed(const struct termios *mode, int fancy)
diff --git a/coreutils/tee.c b/coreutils/tee.c
index d253028cc..831325812 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -22,6 +22,7 @@ int tee_main(int argc, char **argv)
22 char **names; 22 char **names;
23 char **np; 23 char **np;
24 char retval; 24 char retval;
25//TODO: make unconditional
25#if ENABLE_FEATURE_TEE_USE_BLOCK_IO 26#if ENABLE_FEATURE_TEE_USE_BLOCK_IO
26 ssize_t c; 27 ssize_t c;
27# define buf bb_common_bufsiz1 28# define buf bb_common_bufsiz1
@@ -62,7 +63,7 @@ int tee_main(int argc, char **argv)
62 /* names[0] will be filled later */ 63 /* names[0] will be filled later */
63 64
64#if ENABLE_FEATURE_TEE_USE_BLOCK_IO 65#if ENABLE_FEATURE_TEE_USE_BLOCK_IO
65 while ((c = safe_read(STDIN_FILENO, buf, BUFSIZ)) > 0) { 66 while ((c = safe_read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
66 fp = files; 67 fp = files;
67 do 68 do
68 fwrite(buf, 1, c, *fp++); 69 fwrite(buf, 1, c, *fp++);
diff --git a/coreutils/uname.c b/coreutils/uname.c
index e4724c8f1..e70b1f9b6 100644
--- a/coreutils/uname.c
+++ b/coreutils/uname.c
@@ -91,12 +91,12 @@ int uname_main(int argc, char **argv)
91 if (toprint & 1) { 91 if (toprint & 1) {
92 printf(((char *)(&uname_info)) + *delta); 92 printf(((char *)(&uname_info)) + *delta);
93 if (toprint > 1) { 93 if (toprint > 1) {
94 putchar(' '); 94 bb_putchar(' ');
95 } 95 }
96 } 96 }
97 ++delta; 97 ++delta;
98 } while (toprint >>= 1); 98 } while (toprint >>= 1);
99 putchar('\n'); 99 bb_putchar('\n');
100 100
101 fflush_stdout_and_exit(EXIT_SUCCESS); 101 fflush_stdout_and_exit(EXIT_SUCCESS);
102} 102}
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c
index 56d68820e..17def8d9a 100644
--- a/coreutils/uuencode.c
+++ b/coreutils/uuencode.c
@@ -48,9 +48,9 @@ int uuencode_main(int argc, char **argv)
48 bb_perror_msg_and_die(bb_msg_read_error); 48 bb_perror_msg_and_die(bb_msg_read_error);
49 /* Encode the buffer we just read in */ 49 /* Encode the buffer we just read in */
50 bb_uuencode(dst_buf, src_buf, size, tbl); 50 bb_uuencode(dst_buf, src_buf, size, tbl);
51 putchar('\n'); 51 bb_putchar('\n');
52 if (tbl == bb_uuenc_tbl_std) { 52 if (tbl == bb_uuenc_tbl_std) {
53 putchar(tbl[size]); 53 bb_putchar(tbl[size]);
54 } 54 }
55 fflush(stdout); 55 fflush(stdout);
56 xwrite(STDOUT_FILENO, dst_buf, 4 * ((size + 2) / 3)); 56 xwrite(STDOUT_FILENO, dst_buf, 4 * ((size + 2) / 3));