diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-09-27 10:20:47 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-09-27 10:20:47 +0000 |
commit | 4daad9004d8f07991516970a1cbd77756fae7041 (patch) | |
tree | f1a17e4b168ef8fdf8af92ac5ce8deba89d38db2 /libbb | |
parent | 1acdc89e992eb3f0548ff48ba586b31c9a0ae232 (diff) | |
download | busybox-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 'libbb')
-rw-r--r-- | libbb/bb_askpass.c | 2 | ||||
-rw-r--r-- | libbb/lineedit.c | 16 | ||||
-rw-r--r-- | libbb/xfuncs.c | 8 |
3 files changed, 17 insertions, 9 deletions
diff --git a/libbb/bb_askpass.c b/libbb/bb_askpass.c index 5ad234921..435314ea0 100644 --- a/libbb/bb_askpass.c +++ b/libbb/bb_askpass.c | |||
@@ -69,7 +69,7 @@ char *bb_askpass(int timeout, const char * prompt) | |||
69 | } | 69 | } |
70 | 70 | ||
71 | tcsetattr(STDIN_FILENO, TCSANOW, &old); | 71 | tcsetattr(STDIN_FILENO, TCSANOW, &old); |
72 | putchar('\n'); | 72 | bb_putchar('\n'); |
73 | fflush(stdout); | 73 | fflush(stdout); |
74 | return ret; | 74 | return ret; |
75 | } | 75 | } |
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index a66398a95..2db85d0d4 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -111,15 +111,15 @@ static void cmdedit_set_out_char(int next_char) | |||
111 | #endif | 111 | #endif |
112 | { | 112 | { |
113 | if (initial_settings.c_lflag & ECHO) | 113 | if (initial_settings.c_lflag & ECHO) |
114 | putchar(c); | 114 | bb_putchar(c); |
115 | } | 115 | } |
116 | if (++cmdedit_x >= cmdedit_termw) { | 116 | if (++cmdedit_x >= cmdedit_termw) { |
117 | /* terminal is scrolled down */ | 117 | /* terminal is scrolled down */ |
118 | cmdedit_y++; | 118 | cmdedit_y++; |
119 | cmdedit_x = 0; | 119 | cmdedit_x = 0; |
120 | /* destroy "(auto)margin" */ | 120 | /* destroy "(auto)margin" */ |
121 | putchar(next_char); | 121 | bb_putchar(next_char); |
122 | putchar('\b'); | 122 | bb_putchar('\b'); |
123 | } | 123 | } |
124 | // Huh? What if command_ps[cursor] == '\0' (we are at the end already?) | 124 | // Huh? What if command_ps[cursor] == '\0' (we are at the end already?) |
125 | cursor++; | 125 | cursor++; |
@@ -137,7 +137,7 @@ static void goto_new_line(void) | |||
137 | { | 137 | { |
138 | input_end(); | 138 | input_end(); |
139 | if (cmdedit_x) | 139 | if (cmdedit_x) |
140 | putchar('\n'); | 140 | bb_putchar('\n'); |
141 | } | 141 | } |
142 | 142 | ||
143 | 143 | ||
@@ -149,7 +149,7 @@ static void out1str(const char *s) | |||
149 | 149 | ||
150 | static void beep(void) | 150 | static void beep(void) |
151 | { | 151 | { |
152 | putchar('\007'); | 152 | bb_putchar('\007'); |
153 | } | 153 | } |
154 | 154 | ||
155 | /* Move back one character */ | 155 | /* Move back one character */ |
@@ -197,7 +197,7 @@ static void redraw(int y, int back_cursor) | |||
197 | { | 197 | { |
198 | if (y > 0) /* up to start y */ | 198 | if (y > 0) /* up to start y */ |
199 | printf("\033[%dA", y); | 199 | printf("\033[%dA", y); |
200 | putchar('\r'); | 200 | bb_putchar('\r'); |
201 | put_prompt(); | 201 | put_prompt(); |
202 | input_end(); /* rewrite */ | 202 | input_end(); /* rewrite */ |
203 | printf("\033[J"); /* erase after cursor */ | 203 | printf("\033[J"); /* erase after cursor */ |
@@ -1585,8 +1585,8 @@ int read_line_input(const char* prompt, char* command, int maxsize, line_input_t | |||
1585 | beep(); | 1585 | beep(); |
1586 | else { | 1586 | else { |
1587 | *(command + cursor) = c; | 1587 | *(command + cursor) = c; |
1588 | putchar(c); | 1588 | bb_putchar(c); |
1589 | putchar('\b'); | 1589 | bb_putchar('\b'); |
1590 | } | 1590 | } |
1591 | break; | 1591 | break; |
1592 | #endif /* FEATURE_COMMAND_EDITING_VI */ | 1592 | #endif /* FEATURE_COMMAND_EDITING_VI */ |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 2215bb8df..eb1633be2 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -456,6 +456,14 @@ off_t fdlength(int fd) | |||
456 | return pos + 1; | 456 | return pos + 1; |
457 | } | 457 | } |
458 | 458 | ||
459 | int bb_putchar(int ch) | ||
460 | { | ||
461 | /* time.c needs putc(ch, stdout), not putchar(ch). | ||
462 | * it does "stdout = stderr;", but then glibc's putchar() | ||
463 | * doesn't work as expected. bad glibc, bad */ | ||
464 | return putc(ch, stdout); | ||
465 | } | ||
466 | |||
459 | // Die with an error message if we can't malloc() enough space and do an | 467 | // Die with an error message if we can't malloc() enough space and do an |
460 | // sprintf() into that space. | 468 | // sprintf() into that space. |
461 | char *xasprintf(const char *format, ...) | 469 | char *xasprintf(const char *format, ...) |