remove echo_main -> bb_echo indirection

This commit is contained in:
Denis Vlasenko 2007-11-24 02:23:51 +00:00
parent c3c6659f12
commit fe5e23bf75
4 changed files with 11 additions and 15 deletions

View File

@ -25,9 +25,13 @@
#include "libbb.h" #include "libbb.h"
/* This is a NOFORK applet. Be very careful! */
/* argc is unused, but removing it precludes compiler from /* argc is unused, but removing it precludes compiler from
* using call -> jump optimization */ * using call -> jump optimization */
int bb_echo(int argc, char **argv)
int echo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int echo_main(int argc, char **argv)
{ {
const char *arg; const char *arg;
#if !ENABLE_FEATURE_FANCY_ECHO #if !ENABLE_FEATURE_FANCY_ECHO
@ -38,7 +42,7 @@ int bb_echo(int argc, char **argv)
/* We must check that stdout is not closed. /* We must check that stdout is not closed.
* The reason for this is highly non-obvious. * The reason for this is highly non-obvious.
* bb_echo is used from shell. Shell must correctly handle "echo foo" * echo_main is used from shell. Shell must correctly handle "echo foo"
* if stdout is closed. With stdio, output gets shoveled into * if stdout is closed. With stdio, output gets shoveled into
* stdout buffer, and even fflush cannot clear it out. It seems that * stdout buffer, and even fflush cannot clear it out. It seems that
* even if libc receives EBADF on write attempts, it feels determined * even if libc receives EBADF on write attempts, it feels determined
@ -135,14 +139,6 @@ int bb_echo(int argc, char **argv)
return fflush(stdout); return fflush(stdout);
} }
/* This is a NOFORK applet. Be very careful! */
int echo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int echo_main(int argc, char **argv)
{
return bb_echo(argc, argv);
}
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -185,7 +181,7 @@ int echo_main(int argc, char **argv)
#ifdef VERSION_WITH_WRITEV #ifdef VERSION_WITH_WRITEV
/* We can't use stdio. /* We can't use stdio.
* The reason for this is highly non-obvious. * The reason for this is highly non-obvious.
* bb_echo is used from shell. Shell must correctly handle "echo foo" * echo_main is used from shell. Shell must correctly handle "echo foo"
* if stdout is closed. With stdio, output gets shoveled into * if stdout is closed. With stdio, output gets shoveled into
* stdout buffer, and even fflush cannot clear it out. It seems that * stdout buffer, and even fflush cannot clear it out. It seems that
* even if libc receives EBADF on write attempts, it feels determined * even if libc receives EBADF on write attempts, it feels determined
@ -195,7 +191,7 @@ int echo_main(int argc, char **argv)
* Using writev instead, with 'direct' conversion of argv vector. * Using writev instead, with 'direct' conversion of argv vector.
*/ */
int bb_echo(int argc, char **argv) int echo_main(int argc, char **argv)
{ {
struct iovec io[argc]; struct iovec io[argc];
struct iovec *cur_io = io; struct iovec *cur_io = io;

View File

@ -728,7 +728,7 @@ extern void bb_verror_msg(const char *s, va_list p, const char *strerr);
/* applets which are useful from another applets */ /* applets which are useful from another applets */
int bb_cat(char** argv); int bb_cat(char** argv);
int bb_echo(int argc, char** argv); int echo_main(int argc, char** argv) MAIN_EXTERNALLY_VISIBLE;
int test_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int test_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int kill_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int kill_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
#if ENABLE_ROUTE #if ENABLE_ROUTE

View File

@ -11003,7 +11003,7 @@ exitcmd(int argc, char **argv)
static int static int
echocmd(int argc, char **argv) echocmd(int argc, char **argv)
{ {
return bb_echo(argc, argv); return echo_main(argc, argv);
} }
#endif #endif

View File

@ -853,7 +853,7 @@ static int builtin_echo(char **argv)
argc++; argc++;
argv++; argv++;
} }
return bb_echo(argc, argv - argc); return echo_main(argc, argv - argc);
} }
/* built-in 'eval' handler */ /* built-in 'eval' handler */