aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-11-02 14:19:51 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-11-02 14:19:51 +0100
commit8131eea3dce5fba0dfb78e6083d1730423fad20b (patch)
treec098d7ba6ef9f4745425a29a330480e6088d6d9a /shell
parent0d8ea64af618dc83c3291b3b598636ed3d0854e4 (diff)
downloadbusybox-w32-8131eea3dce5fba0dfb78e6083d1730423fad20b.tar.gz
busybox-w32-8131eea3dce5fba0dfb78e6083d1730423fad20b.tar.bz2
busybox-w32-8131eea3dce5fba0dfb78e6083d1730423fad20b.zip
*: introduce and use ffulsh_all()
function old new delta buffer_fill_and_print 179 196 +17 fflush_all - 9 +9 spawn 87 92 +5 rtcwake_main 455 453 -2 ... alarm_intr 93 84 -9 readcmd 1072 1062 -10 bb_ask 345 333 -12 more_main 845 832 -13 flush_stdout_stderr 42 23 -19 xfflush_stdout 27 - -27 flush_stderr 30 - -30 ------------------------------------------------------------------------------ (add/remove: 1/2 grow/shrink: 2/50 up/down: 31/-397) Total: -366 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c17
-rw-r--r--shell/hush.c14
2 files changed, 11 insertions, 20 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 481b84138..6b985ad7c 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -389,16 +389,7 @@ static void
389flush_stdout_stderr(void) 389flush_stdout_stderr(void)
390{ 390{
391 INT_OFF; 391 INT_OFF;
392 fflush(stdout); 392 fflush_all();
393 fflush(stderr);
394 INT_ON;
395}
396
397static void
398flush_stderr(void)
399{
400 INT_OFF;
401 fflush(stderr);
402 INT_ON; 393 INT_ON;
403} 394}
404 395
@@ -451,7 +442,7 @@ static void
451out2str(const char *p) 442out2str(const char *p)
452{ 443{
453 outstr(p, stderr); 444 outstr(p, stderr);
454 flush_stderr(); 445 flush_stdout_stderr();
455} 446}
456 447
457 448
@@ -8184,7 +8175,7 @@ evaltree(union node *n, int flags)
8184 default: 8175 default:
8185#if DEBUG 8176#if DEBUG
8186 out1fmt("Node type = %d\n", n->type); 8177 out1fmt("Node type = %d\n", n->type);
8187 fflush(stdout); 8178 fflush_all();
8188 break; 8179 break;
8189#endif 8180#endif
8190 case NNOT: 8181 case NNOT:
@@ -9101,7 +9092,7 @@ evalcommand(union node *cmd, int flags)
9101 for (;;) { 9092 for (;;) {
9102 find_command(argv[0], &cmdentry, cmd_flag, path); 9093 find_command(argv[0], &cmdentry, cmd_flag, path);
9103 if (cmdentry.cmdtype == CMDUNKNOWN) { 9094 if (cmdentry.cmdtype == CMDUNKNOWN) {
9104 flush_stderr(); 9095 flush_stdout_stderr();
9105 status = 127; 9096 status = 127;
9106 goto bail; 9097 goto bail;
9107 } 9098 }
diff --git a/shell/hush.c b/shell/hush.c
index 1187cbe8f..891d87be7 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -1206,7 +1206,7 @@ static void hush_exit(int exitcode)
1206 } 1206 }
1207 1207
1208#if ENABLE_HUSH_JOB 1208#if ENABLE_HUSH_JOB
1209 fflush(NULL); /* flush all streams */ 1209 fflush_all();
1210 sigexit(- (exitcode & 0xff)); 1210 sigexit(- (exitcode & 0xff));
1211#else 1211#else
1212 exit(exitcode); 1212 exit(exitcode);
@@ -1679,7 +1679,7 @@ static void get_user_input(struct in_str *i)
1679 do { 1679 do {
1680 G.flag_SIGINT = 0; 1680 G.flag_SIGINT = 0;
1681 fputs(prompt_str, stdout); 1681 fputs(prompt_str, stdout);
1682 fflush(stdout); 1682 fflush_all();
1683 G.user_input_buf[0] = r = fgetc(i->file); 1683 G.user_input_buf[0] = r = fgetc(i->file);
1684 /*G.user_input_buf[1] = '\0'; - already is and never changed */ 1684 /*G.user_input_buf[1] = '\0'; - already is and never changed */
1685//do we need check_and_run_traps(0)? (maybe only if stdin) 1685//do we need check_and_run_traps(0)? (maybe only if stdin)
@@ -3220,7 +3220,7 @@ static void exec_function(char ***to_free,
3220 G.global_argc = n; 3220 G.global_argc = n;
3221 /* On MMU, funcp->body is always non-NULL */ 3221 /* On MMU, funcp->body is always non-NULL */
3222 n = run_list(funcp->body); 3222 n = run_list(funcp->body);
3223 fflush(NULL); 3223 fflush_all();
3224 _exit(n); 3224 _exit(n);
3225# else 3225# else
3226 re_execute_shell(to_free, 3226 re_execute_shell(to_free,
@@ -3307,7 +3307,7 @@ static void exec_builtin(char ***to_free,
3307{ 3307{
3308#if BB_MMU 3308#if BB_MMU
3309 int rcode = x->function(argv); 3309 int rcode = x->function(argv);
3310 fflush(NULL); 3310 fflush_all();
3311 _exit(rcode); 3311 _exit(rcode);
3312#else 3312#else
3313 /* On NOMMU, we must never block! 3313 /* On NOMMU, we must never block!
@@ -3933,7 +3933,7 @@ static NOINLINE int run_pipe(struct pipe *pi)
3933 debug_printf_exec(": builtin '%s' '%s'...\n", 3933 debug_printf_exec(": builtin '%s' '%s'...\n",
3934 x->cmd, argv_expanded[1]); 3934 x->cmd, argv_expanded[1]);
3935 rcode = x->function(argv_expanded) & 0xff; 3935 rcode = x->function(argv_expanded) & 0xff;
3936 fflush(NULL); 3936 fflush_all();
3937 } 3937 }
3938#if ENABLE_HUSH_FUNCTIONS 3938#if ENABLE_HUSH_FUNCTIONS
3939 else { 3939 else {
@@ -7136,7 +7136,7 @@ static int FAST_FUNC builtin_export(char **argv)
7136 putchar('\n'); 7136 putchar('\n');
7137#endif 7137#endif
7138 } 7138 }
7139 /*fflush(stdout); - done after each builtin anyway */ 7139 /*fflush_all(); - done after each builtin anyway */
7140 } 7140 }
7141 return EXIT_SUCCESS; 7141 return EXIT_SUCCESS;
7142 } 7142 }
@@ -7181,7 +7181,7 @@ static int FAST_FUNC builtin_trap(char **argv)
7181 printf(" %s\n", get_signame(i)); 7181 printf(" %s\n", get_signame(i));
7182 } 7182 }
7183 } 7183 }
7184 /*fflush(stdout); - done after each builtin anyway */ 7184 /*fflush_all(); - done after each builtin anyway */
7185 return EXIT_SUCCESS; 7185 return EXIT_SUCCESS;
7186 } 7186 }
7187 7187