diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-06-07 14:14:26 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-06-07 14:14:26 +0200 |
commit | 729ecb87bfbbaf9250837d8b8748503c5e97bfd6 (patch) | |
tree | c269d39f4d929671e12ca2dfba90814e3b6f9976 | |
parent | 121fb9506bcade96b6fb8b1dbcbbb7699bfb1a9d (diff) | |
download | busybox-w32-729ecb87bfbbaf9250837d8b8748503c5e97bfd6.tar.gz busybox-w32-729ecb87bfbbaf9250837d8b8748503c5e97bfd6.tar.bz2 busybox-w32-729ecb87bfbbaf9250837d8b8748503c5e97bfd6.zip |
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 f787e7a14..ba003a1fb 100644 --- a/TEST_config_noprintf +++ b/TEST_config_noprintf | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.17.0.git | 3 | # Busybox version: 1.17.0.git |
4 | # Sun Jun 6 21:38:58 2010 | 4 | # Mon Jun 7 13:37:55 2010 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | 7 | ||
@@ -579,7 +579,7 @@ CONFIG_VOLUMEID=y | |||
579 | # Miscellaneous Utilities | 579 | # Miscellaneous Utilities |
580 | # | 580 | # |
581 | # CONFIG_ADJTIMEX is not set | 581 | # CONFIG_ADJTIMEX is not set |
582 | # CONFIG_BBCONFIG is not set | 582 | CONFIG_BBCONFIG=y |
583 | # CONFIG_BEEP is not set | 583 | # CONFIG_BEEP is not set |
584 | CONFIG_FEATURE_BEEP_FREQ=0 | 584 | CONFIG_FEATURE_BEEP_FREQ=0 |
585 | CONFIG_FEATURE_BEEP_LENGTH_MS=0 | 585 | CONFIG_FEATURE_BEEP_LENGTH_MS=0 |
@@ -872,12 +872,6 @@ CONFIG_SV_DEFAULT_SERVICE_DIR="" | |||
872 | # | 872 | # |
873 | # Shells | 873 | # Shells |
874 | # | 874 | # |
875 | # CONFIG_FEATURE_SH_IS_ASH is not set | ||
876 | # CONFIG_FEATURE_SH_IS_HUSH is not set | ||
877 | CONFIG_FEATURE_SH_IS_NONE=y | ||
878 | # CONFIG_FEATURE_BASH_IS_ASH is not set | ||
879 | # CONFIG_FEATURE_BASH_IS_HUSH is not set | ||
880 | CONFIG_FEATURE_BASH_IS_NONE=y | ||
881 | # CONFIG_ASH is not set | 875 | # CONFIG_ASH is not set |
882 | # CONFIG_ASH_BASH_COMPAT is not set | 876 | # CONFIG_ASH_BASH_COMPAT is not set |
883 | # CONFIG_ASH_JOB_CONTROL is not set | 877 | # CONFIG_ASH_JOB_CONTROL is not set |
@@ -904,6 +898,12 @@ CONFIG_FEATURE_BASH_IS_NONE=y | |||
904 | # CONFIG_HUSH_LOCAL is not set | 898 | # CONFIG_HUSH_LOCAL is not set |
905 | # CONFIG_HUSH_EXPORT_N is not set | 899 | # CONFIG_HUSH_EXPORT_N is not set |
906 | # CONFIG_HUSH_RANDOM_SUPPORT is not set | 900 | # CONFIG_HUSH_RANDOM_SUPPORT is not set |
901 | # CONFIG_FEATURE_SH_IS_ASH is not set | ||
902 | # CONFIG_FEATURE_SH_IS_HUSH is not set | ||
903 | CONFIG_FEATURE_SH_IS_NONE=y | ||
904 | # CONFIG_FEATURE_BASH_IS_ASH is not set | ||
905 | # CONFIG_FEATURE_BASH_IS_HUSH is not set | ||
906 | CONFIG_FEATURE_BASH_IS_NONE=y | ||
907 | # CONFIG_LASH is not set | 907 | # CONFIG_LASH is not set |
908 | # CONFIG_MSH is not set | 908 | # CONFIG_MSH is not set |
909 | # CONFIG_SH_MATH_SUPPORT is not set | 909 | # CONFIG_SH_MATH_SUPPORT is not set |
diff --git a/console-tools/clear.c b/console-tools/clear.c index b0c6d65d2..cac716394 100644 --- a/console-tools/clear.c +++ b/console-tools/clear.c | |||
@@ -5,16 +5,12 @@ | |||
5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | 5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> |
6 | * | 6 | * |
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | * | ||
9 | */ | 8 | */ |
10 | |||
11 | /* no options, no getopt */ | ||
12 | |||
13 | #include "libbb.h" | 9 | #include "libbb.h" |
14 | 10 | ||
15 | int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 11 | int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
16 | int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | 12 | int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
17 | { | 13 | { |
18 | /* home; clear to the end of screen */ | 14 | /* home; clear to the end of screen */ |
19 | return printf("\033[H""\033[J") != 6; | 15 | return full_write1_str("\033[H""\033[J") != 6; |
20 | } | 16 | } |
diff --git a/coreutils/basename.c b/coreutils/basename.c index d1ad91ba1..b79d561c2 100644 --- a/coreutils/basename.c +++ b/coreutils/basename.c | |||
@@ -5,13 +5,8 @@ | |||
5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | 5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> |
6 | * | 6 | * |
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | * | ||
9 | */ | 8 | */ |
10 | 9 | ||
11 | /* BB_AUDIT SUSv3 compliant */ | ||
12 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/basename.html */ | ||
13 | |||
14 | |||
15 | /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) | 10 | /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) |
16 | * | 11 | * |
17 | * Changes: | 12 | * Changes: |
@@ -20,6 +15,9 @@ | |||
20 | * 3) Save some space by using strcmp(). Calling strncmp() here was silly. | 15 | * 3) Save some space by using strcmp(). Calling strncmp() here was silly. |
21 | */ | 16 | */ |
22 | 17 | ||
18 | /* BB_AUDIT SUSv3 compliant */ | ||
19 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/basename.html */ | ||
20 | |||
23 | //kbuild:lib-$(CONFIG_BASENAME) += basename.o | 21 | //kbuild:lib-$(CONFIG_BASENAME) += basename.o |
24 | 22 | ||
25 | //config:config BASENAME | 23 | //config:config BASENAME |
@@ -40,7 +38,7 @@ int basename_main(int argc, char **argv) | |||
40 | size_t m, n; | 38 | size_t m, n; |
41 | char *s; | 39 | char *s; |
42 | 40 | ||
43 | if (((unsigned int)(argc-2)) >= 2) { | 41 | if ((unsigned)(argc-2) >= 2) { |
44 | bb_show_usage(); | 42 | bb_show_usage(); |
45 | } | 43 | } |
46 | 44 | ||
@@ -50,7 +48,7 @@ int basename_main(int argc, char **argv) | |||
50 | m = strlen(s); | 48 | m = strlen(s); |
51 | if (*++argv) { | 49 | if (*++argv) { |
52 | n = strlen(*argv); | 50 | n = strlen(*argv); |
53 | if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) { | 51 | if ((m > n) && (strcmp(s+m-n, *argv) == 0)) { |
54 | m -= n; | 52 | m -= n; |
55 | /*s[m] = '\0'; - redundant */ | 53 | /*s[m] = '\0'; - redundant */ |
56 | } | 54 | } |
diff --git a/include/libbb.h b/include/libbb.h index 3fffa83ed..22c72d9ee 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; | |||
674 | extern ssize_t full_write(int fd, const void *buf, size_t count) FAST_FUNC; | 674 | extern ssize_t full_write(int fd, const void *buf, size_t count) FAST_FUNC; |
675 | extern void xwrite(int fd, const void *buf, size_t count) FAST_FUNC; | 675 | extern void xwrite(int fd, const void *buf, size_t count) FAST_FUNC; |
676 | extern void xwrite_str(int fd, const char *str) FAST_FUNC; | 676 | extern void xwrite_str(int fd, const char *str) FAST_FUNC; |
677 | extern ssize_t full_write1_str(const char *str) FAST_FUNC; | ||
678 | extern ssize_t full_write2_str(const char *str) FAST_FUNC; | ||
677 | extern void xopen_xwrite_close(const char* file, const char *str) FAST_FUNC; | 679 | extern void xopen_xwrite_close(const char* file, const char *str) FAST_FUNC; |
678 | 680 | ||
679 | /* Close fd, but check for failures (some types of write errors) */ | 681 | /* Close fd, but check for failures (some types of write errors) */ |
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 6267f2673..f3d530184 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -98,13 +98,6 @@ static const char *unpack_usage_messages(void) | |||
98 | #endif /* FEATURE_COMPRESS_USAGE */ | 98 | #endif /* FEATURE_COMPRESS_USAGE */ |
99 | 99 | ||
100 | 100 | ||
101 | static void full_write2_str(const char *str) | ||
102 | { | ||
103 | // This uses stdio: | ||
104 | //xwrite_str(STDERR_FILENO, str); | ||
105 | write(STDERR_FILENO, str, strlen(str)); | ||
106 | } | ||
107 | |||
108 | void FAST_FUNC bb_show_usage(void) | 101 | void FAST_FUNC bb_show_usage(void) |
109 | { | 102 | { |
110 | if (ENABLE_SHOW_USAGE) { | 103 | if (ENABLE_SHOW_USAGE) { |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 6200fc600..1cd8d7c01 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -204,6 +204,16 @@ int FAST_FUNC bb_putchar_stderr(char ch) | |||
204 | return write(STDERR_FILENO, &ch, 1); | 204 | return write(STDERR_FILENO, &ch, 1); |
205 | } | 205 | } |
206 | 206 | ||
207 | ssize_t FAST_FUNC full_write1_str(const char *str) | ||
208 | { | ||
209 | return full_write(STDOUT_FILENO, str, strlen(str)); | ||
210 | } | ||
211 | |||
212 | ssize_t FAST_FUNC full_write2_str(const char *str) | ||
213 | { | ||
214 | return full_write(STDERR_FILENO, str, strlen(str)); | ||
215 | } | ||
216 | |||
207 | static int wh_helper(int value, int def_val, const char *env_name, int *err) | 217 | static int wh_helper(int value, int def_val, const char *env_name, int *err) |
208 | { | 218 | { |
209 | if (value == 0) { | 219 | if (value == 0) { |
diff --git a/loginutils/getty.c b/loginutils/getty.c index 7fb861f9d..a5e8e906a 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c | |||
@@ -673,8 +673,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) | |||
673 | /* Write the modem init string and DON'T flush the buffers */ | 673 | /* Write the modem init string and DON'T flush the buffers */ |
674 | if (options.flags & F_INITSTRING) { | 674 | if (options.flags & F_INITSTRING) { |
675 | debug("writing init string\n"); | 675 | debug("writing init string\n"); |
676 | /* todo: use xwrite_str? */ | 676 | full_write1_str(options.initstring); |
677 | full_write(STDOUT_FILENO, options.initstring, strlen(options.initstring)); | ||
678 | } | 677 | } |
679 | 678 | ||
680 | /* Optionally detect the baud rate from the modem status message */ | 679 | /* Optionally detect the baud rate from the modem status message */ |
diff --git a/miscutils/bbconfig.c b/miscutils/bbconfig.c index 689052e86..0d649b4e5 100644 --- a/miscutils/bbconfig.c +++ b/miscutils/bbconfig.c | |||
@@ -7,6 +7,6 @@ | |||
7 | int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 7 | int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
8 | int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | 8 | int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
9 | { | 9 | { |
10 | printf(bbconfig_config); | 10 | full_write1_str(bbconfig_config); |
11 | return 0; | 11 | return 0; |
12 | } | 12 | } |
diff --git a/networking/telnet.c b/networking/telnet.c index ec3db0c5e..57997f6b9 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
@@ -418,7 +418,7 @@ static void to_echo(void) | |||
418 | put_iac2(DONT, TELOPT_ECHO); | 418 | put_iac2(DONT, TELOPT_ECHO); |
419 | 419 | ||
420 | setConMode(); | 420 | setConMode(); |
421 | write_str(1, "\r\n"); /* sudden modec */ | 421 | full_write1_str("\r\n"); /* sudden modec */ |
422 | } | 422 | } |
423 | 423 | ||
424 | static void to_sga(void) | 424 | static void to_sga(void) |
@@ -637,7 +637,7 @@ int telnet_main(int argc UNUSED_PARAM, char **argv) | |||
637 | { | 637 | { |
638 | len = safe_read(netfd, G.buf, DATABUFSIZE); | 638 | len = safe_read(netfd, G.buf, DATABUFSIZE); |
639 | if (len <= 0) { | 639 | if (len <= 0) { |
640 | write_str(1, "Connection closed by foreign host\r\n"); | 640 | full_write1_str("Connection closed by foreign host\r\n"); |
641 | doexit(EXIT_FAILURE); | 641 | doexit(EXIT_FAILURE); |
642 | } | 642 | } |
643 | TRACE(0, ("Read netfd (%d): %d\n", netfd, len)); | 643 | TRACE(0, ("Read netfd (%d): %d\n", netfd, len)); |
diff --git a/scripts/mkconfigs b/scripts/mkconfigs index 0d1771a36..ef6ae8aaf 100755 --- a/scripts/mkconfigs +++ b/scripts/mkconfigs | |||
@@ -42,9 +42,8 @@ echo "\ | |||
42 | * | 42 | * |
43 | * This file is generated automatically by scripts/mkconfigs. | 43 | * This file is generated automatically by scripts/mkconfigs. |
44 | * Do not edit. | 44 | * Do not edit. |
45 | * | ||
46 | */ | 45 | */ |
47 | static const char *const bbconfig_config =" | 46 | static const char bbconfig_config[] =" |
48 | 47 | ||
49 | sed 's/\"/\\\"/g' $config | grep "^#\? \?CONFIG_" | awk '{print "\"" $0 "\\n\"";}' | 48 | sed 's/\"/\\\"/g' $config | grep "^#\? \?CONFIG_" | awk '{print "\"" $0 "\\n\"";}' |
50 | 49 | ||
diff --git a/shell/hush.c b/shell/hush.c index 4cccf31a4..4832e2c48 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -7103,7 +7103,7 @@ int hush_main(int argc, char **argv) | |||
7103 | break; | 7103 | break; |
7104 | #if !BB_MMU | 7104 | #if !BB_MMU |
7105 | case '<': /* "big heredoc" support */ | 7105 | case '<': /* "big heredoc" support */ |
7106 | full_write(STDOUT_FILENO, optarg, strlen(optarg)); | 7106 | full_write1_str(optarg); |
7107 | _exit(0); | 7107 | _exit(0); |
7108 | case '$': { | 7108 | case '$': { |
7109 | unsigned long long empty_trap_mask; | 7109 | unsigned long long empty_trap_mask; |