diff options
author | Denys Vlasenko | 2010-06-07 14:14:26 +0200 |
---|---|---|
committer | Denys Vlasenko | 2010-06-07 14:14:26 +0200 |
commit | 729ecb87bfbbaf9250837d8b8748503c5e97bfd6 (patch) | |
tree | c269d39f4d929671e12ca2dfba90814e3b6f9976 | |
parent | 121fb9506bcade96b6fb8b1dbcbbb7699bfb1a9d (diff) | |
download | busybox-729ecb87bfbbaf9250837d8b8748503c5e97bfd6.zip busybox-729ecb87bfbbaf9250837d8b8748503c5e97bfd6.tar.gz |
bbconfig: make it independent from printf functions
function old new delta
full_write2_str - 25 +25
full_write1_str - 25 +25
clear_main 21 20 -1
telnet_main 1488 1477 -11
getty_main 1932 1918 -14
full_write22_str 25 - -25
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/3 up/down: 50/-51) Total: -1 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | TEST_config_noprintf | 16 | ||||
-rw-r--r-- | console-tools/clear.c | 6 | ||||
-rw-r--r-- | coreutils/basename.c | 12 | ||||
-rw-r--r-- | include/libbb.h | 2 | ||||
-rw-r--r-- | libbb/appletlib.c | 7 | ||||
-rw-r--r-- | libbb/xfuncs.c | 10 | ||||
-rw-r--r-- | loginutils/getty.c | 3 | ||||
-rw-r--r-- | miscutils/bbconfig.c | 2 | ||||
-rw-r--r-- | networking/telnet.c | 4 | ||||
-rwxr-xr-x | scripts/mkconfigs | 3 | ||||
-rw-r--r-- | shell/hush.c | 2 |
11 files changed, 32 insertions, 35 deletions
diff --git a/TEST_config_noprintf b/TEST_config_noprintf index f787e7a..ba003a1 100644 --- a/TEST_config_noprintf +++ b/TEST_config_noprintf @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Busybox version: 1.17.0.git -# Sun Jun 6 21:38:58 2010 +# Mon Jun 7 13:37:55 2010 # CONFIG_HAVE_DOT_CONFIG=y @@ -579,7 +579,7 @@ CONFIG_VOLUMEID=y # Miscellaneous Utilities # # CONFIG_ADJTIMEX is not set -# CONFIG_BBCONFIG is not set +CONFIG_BBCONFIG=y # CONFIG_BEEP is not set CONFIG_FEATURE_BEEP_FREQ=0 CONFIG_FEATURE_BEEP_LENGTH_MS=0 @@ -872,12 +872,6 @@ CONFIG_SV_DEFAULT_SERVICE_DIR="" # # Shells # -# CONFIG_FEATURE_SH_IS_ASH is not set -# CONFIG_FEATURE_SH_IS_HUSH is not set -CONFIG_FEATURE_SH_IS_NONE=y -# CONFIG_FEATURE_BASH_IS_ASH is not set -# CONFIG_FEATURE_BASH_IS_HUSH is not set -CONFIG_FEATURE_BASH_IS_NONE=y # CONFIG_ASH is not set # CONFIG_ASH_BASH_COMPAT is not set # CONFIG_ASH_JOB_CONTROL is not set @@ -904,6 +898,12 @@ CONFIG_FEATURE_BASH_IS_NONE=y # CONFIG_HUSH_LOCAL is not set # CONFIG_HUSH_EXPORT_N is not set # CONFIG_HUSH_RANDOM_SUPPORT is not set +# CONFIG_FEATURE_SH_IS_ASH is not set +# CONFIG_FEATURE_SH_IS_HUSH is not set +CONFIG_FEATURE_SH_IS_NONE=y +# CONFIG_FEATURE_BASH_IS_ASH is not set +# CONFIG_FEATURE_BASH_IS_HUSH is not set +CONFIG_FEATURE_BASH_IS_NONE=y # CONFIG_LASH is not set # CONFIG_MSH is not set # CONFIG_SH_MATH_SUPPORT is not set diff --git a/console-tools/clear.c b/console-tools/clear.c index b0c6d65..cac7163 100644 --- a/console-tools/clear.c +++ b/console-tools/clear.c @@ -5,16 +5,12 @@ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> * * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. - * */ - -/* no options, no getopt */ - #include "libbb.h" int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) { /* home; clear to the end of screen */ - return printf("\033[H""\033[J") != 6; + return full_write1_str("\033[H""\033[J") != 6; } diff --git a/coreutils/basename.c b/coreutils/basename.c index d1ad91b..b79d561 100644 --- a/coreutils/basename.c +++ b/coreutils/basename.c @@ -5,13 +5,8 @@ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> * * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. - * */ -/* BB_AUDIT SUSv3 compliant */ -/* http://www.opengroup.org/onlinepubs/007904975/utilities/basename.html */ - - /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) * * Changes: @@ -20,6 +15,9 @@ * 3) Save some space by using strcmp(). Calling strncmp() here was silly. */ +/* BB_AUDIT SUSv3 compliant */ +/* http://www.opengroup.org/onlinepubs/007904975/utilities/basename.html */ + //kbuild:lib-$(CONFIG_BASENAME) += basename.o //config:config BASENAME @@ -40,7 +38,7 @@ int basename_main(int argc, char **argv) size_t m, n; char *s; - if (((unsigned int)(argc-2)) >= 2) { + if ((unsigned)(argc-2) >= 2) { bb_show_usage(); } @@ -50,7 +48,7 @@ int basename_main(int argc, char **argv) m = strlen(s); if (*++argv) { n = strlen(*argv); - if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) { + if ((m > n) && (strcmp(s+m-n, *argv) == 0)) { m -= n; /*s[m] = '\0'; - redundant */ } diff --git a/include/libbb.h b/include/libbb.h index 3fffa83..22c72d9 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -674,6 +674,8 @@ extern ssize_t safe_write(int fd, const void *buf, size_t count) FAST_FUNC; extern ssize_t full_write(int fd, const void *buf, size_t count) FAST_FUNC; extern void xwrite(int fd, const void *buf, size_t count) FAST_FUNC; extern void xwrite_str(int fd, const char *str) FAST_FUNC; +extern ssize_t full_write1_str(const char *str) FAST_FUNC; +extern ssize_t full_write2_str(const char *str) FAST_FUNC; extern void xopen_xwrite_close(const char* file, const char *str) FAST_FUNC; /* Close fd, but check for failures (some types of write errors) */ diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 6267f26..f3d5301 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -98,13 +98,6 @@ static const char *unpack_usage_messages(void) #endif /* FEATURE_COMPRESS_USAGE */ -static void full_write2_str(const char *str) -{ - // This uses stdio: - //xwrite_str(STDERR_FILENO, str); - write(STDERR_FILENO, str, strlen(str)); -} - void FAST_FUNC bb_show_usage(void) { if (ENABLE_SHOW_USAGE) { diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 6200fc6..1cd8d7c 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -204,6 +204,16 @@ int FAST_FUNC bb_putchar_stderr(char ch) return write(STDERR_FILENO, &ch, 1); } +ssize_t FAST_FUNC full_write1_str(const char *str) +{ + return full_write(STDOUT_FILENO, str, strlen(str)); +} + +ssize_t FAST_FUNC full_write2_str(const char *str) +{ + return full_write(STDERR_FILENO, str, strlen(str)); +} + static int wh_helper(int value, int def_val, const char *env_name, int *err) { if (value == 0) { diff --git a/loginutils/getty.c b/loginutils/getty.c index 7fb861f..a5e8e90 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -673,8 +673,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) /* Write the modem init string and DON'T flush the buffers */ if (options.flags & F_INITSTRING) { debug("writing init string\n"); - /* todo: use xwrite_str? */ - full_write(STDOUT_FILENO, options.initstring, strlen(options.initstring)); + full_write1_str(options.initstring); } /* Optionally detect the baud rate from the modem status message */ diff --git a/miscutils/bbconfig.c b/miscutils/bbconfig.c index 689052e..0d649b4 100644 --- a/miscutils/bbconfig.c +++ b/miscutils/bbconfig.c @@ -7,6 +7,6 @@ int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) { - printf(bbconfig_config); + full_write1_str(bbconfig_config); return 0; } diff --git a/networking/telnet.c b/networking/telnet.c index ec3db0c..57997f6 100644 --- a/networking/telnet.c +++ b/networking/telnet.c @@ -418,7 +418,7 @@ static void to_echo(void) put_iac2(DONT, TELOPT_ECHO); setConMode(); - write_str(1, "\r\n"); /* sudden modec */ + full_write1_str("\r\n"); /* sudden modec */ } static void to_sga(void) @@ -637,7 +637,7 @@ int telnet_main(int argc UNUSED_PARAM, char **argv) { len = safe_read(netfd, G.buf, DATABUFSIZE); if (len <= 0) { - write_str(1, "Connection closed by foreign host\r\n"); + full_write1_str("Connection closed by foreign host\r\n"); doexit(EXIT_FAILURE); } TRACE(0, ("Read netfd (%d): %d\n", netfd, len)); diff --git a/scripts/mkconfigs b/scripts/mkconfigs index 0d1771a..ef6ae8a 100755 --- a/scripts/mkconfigs +++ b/scripts/mkconfigs @@ -42,9 +42,8 @@ echo "\ * * This file is generated automatically by scripts/mkconfigs. * Do not edit. - * */ -static const char *const bbconfig_config =" +static const char bbconfig_config[] =" sed 's/\"/\\\"/g' $config | grep "^#\? \?CONFIG_" | awk '{print "\"" $0 "\\n\"";}' diff --git a/shell/hush.c b/shell/hush.c index 4cccf31..4832e2c 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -7103,7 +7103,7 @@ int hush_main(int argc, char **argv) break; #if !BB_MMU case '<': /* "big heredoc" support */ - full_write(STDOUT_FILENO, optarg, strlen(optarg)); + full_write1_str(optarg); _exit(0); case '$': { unsigned long long empty_trap_mask; |