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>
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 @@
# 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 @@
#
# 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_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 @@
size_t m, n;
char *s;
- if (((unsigned int)(argc-2)) >= 2) {
+ if ((unsigned)(argc-2) >= 2) {
bb_show_usage();
}
@@ -50,7 +48,7 @@
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 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 @@
#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 @@
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 @@
/* 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 @@
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 @@
{
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 @@
*
* 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 @@
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;