diff options
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/Kbuild | 3 | ||||
-rw-r--r-- | coreutils/cat.c | 22 | ||||
-rw-r--r-- | coreutils/diff.c | 2 | ||||
-rw-r--r-- | coreutils/echo.c | 4 | ||||
-rw-r--r-- | coreutils/expr.c | 2 | ||||
-rw-r--r-- | coreutils/test.c | 10 |
6 files changed, 26 insertions, 17 deletions
diff --git a/coreutils/Kbuild b/coreutils/Kbuild index cfb508d81..55f19b4ca 100644 --- a/coreutils/Kbuild +++ b/coreutils/Kbuild | |||
@@ -10,6 +10,7 @@ lib-y:= | |||
10 | lib-$(CONFIG_BASENAME) += basename.o | 10 | lib-$(CONFIG_BASENAME) += basename.o |
11 | lib-$(CONFIG_CAL) += cal.o | 11 | lib-$(CONFIG_CAL) += cal.o |
12 | lib-$(CONFIG_CAT) += cat.o | 12 | lib-$(CONFIG_CAT) += cat.o |
13 | lib-$(CONFIG_LESS) += cat.o # less uses it if stdout isn't a tty | ||
13 | lib-$(CONFIG_CATV) += catv.o | 14 | lib-$(CONFIG_CATV) += catv.o |
14 | lib-$(CONFIG_CHGRP) += chgrp.o chown.o | 15 | lib-$(CONFIG_CHGRP) += chgrp.o chown.o |
15 | lib-$(CONFIG_CHMOD) += chmod.o | 16 | lib-$(CONFIG_CHMOD) += chmod.o |
@@ -28,6 +29,7 @@ lib-$(CONFIG_DIRNAME) += dirname.o | |||
28 | lib-$(CONFIG_DOS2UNIX) += dos2unix.o | 29 | lib-$(CONFIG_DOS2UNIX) += dos2unix.o |
29 | lib-$(CONFIG_DU) += du.o | 30 | lib-$(CONFIG_DU) += du.o |
30 | lib-$(CONFIG_ECHO) += echo.o | 31 | lib-$(CONFIG_ECHO) += echo.o |
32 | lib-$(CONFIG_ASH) += echo.o # used by ash | ||
31 | lib-$(CONFIG_ENV) += env.o | 33 | lib-$(CONFIG_ENV) += env.o |
32 | lib-$(CONFIG_EXPR) += expr.o | 34 | lib-$(CONFIG_EXPR) += expr.o |
33 | lib-$(CONFIG_FALSE) += false.o | 35 | lib-$(CONFIG_FALSE) += false.o |
@@ -65,6 +67,7 @@ lib-$(CONFIG_SYNC) += sync.o | |||
65 | lib-$(CONFIG_TAIL) += tail.o | 67 | lib-$(CONFIG_TAIL) += tail.o |
66 | lib-$(CONFIG_TEE) += tee.o | 68 | lib-$(CONFIG_TEE) += tee.o |
67 | lib-$(CONFIG_TEST) += test.o | 69 | lib-$(CONFIG_TEST) += test.o |
70 | lib-$(CONFIG_ASH) += test.o # used by ash | ||
68 | lib-$(CONFIG_TOUCH) += touch.o | 71 | lib-$(CONFIG_TOUCH) += touch.o |
69 | lib-$(CONFIG_TR) += tr.o | 72 | lib-$(CONFIG_TR) += tr.o |
70 | lib-$(CONFIG_TRUE) += true.o | 73 | lib-$(CONFIG_TRUE) += true.o |
diff --git a/coreutils/cat.c b/coreutils/cat.c index a95980552..db4d33dc5 100644 --- a/coreutils/cat.c +++ b/coreutils/cat.c | |||
@@ -11,20 +11,12 @@ | |||
11 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */ | 11 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */ |
12 | 12 | ||
13 | #include "busybox.h" | 13 | #include "busybox.h" |
14 | #include <unistd.h> | ||
15 | 14 | ||
16 | int cat_main(int argc, char **argv) | 15 | int bb_cat(char **argv) |
17 | { | 16 | { |
18 | FILE *f; | 17 | FILE *f; |
19 | int retval = EXIT_SUCCESS; | 18 | int retval = EXIT_SUCCESS; |
20 | 19 | ||
21 | getopt32(argc, argv, "u"); | ||
22 | |||
23 | argv += optind; | ||
24 | if (!*argv) { | ||
25 | *--argv = "-"; | ||
26 | } | ||
27 | |||
28 | do { | 20 | do { |
29 | f = fopen_or_warn_stdin(*argv); | 21 | f = fopen_or_warn_stdin(*argv); |
30 | if (f) { | 22 | if (f) { |
@@ -39,3 +31,15 @@ int cat_main(int argc, char **argv) | |||
39 | 31 | ||
40 | return retval; | 32 | return retval; |
41 | } | 33 | } |
34 | |||
35 | int cat_main(int argc, char **argv) | ||
36 | { | ||
37 | getopt32(argc, argv, "u"); | ||
38 | |||
39 | argv += optind; | ||
40 | if (!*argv) { | ||
41 | *--argv = "-"; | ||
42 | } | ||
43 | |||
44 | return bb_cat(argv); | ||
45 | } | ||
diff --git a/coreutils/diff.c b/coreutils/diff.c index 887679a0a..a49d5195a 100644 --- a/coreutils/diff.c +++ b/coreutils/diff.c | |||
@@ -1079,7 +1079,7 @@ static char **get_dir(char *path) | |||
1079 | 1079 | ||
1080 | dp = warn_opendir(path); | 1080 | dp = warn_opendir(path); |
1081 | while ((ep = readdir(dp))) { | 1081 | while ((ep = readdir(dp))) { |
1082 | if ((!strcmp(ep->d_name, "..")) || (!strcmp(ep->d_name, "."))) | 1082 | if (!strcmp(ep->d_name, "..") || LONE_CHAR(ep->d_name, '.')) |
1083 | continue; | 1083 | continue; |
1084 | add_to_dirlist(ep->d_name, NULL, NULL, 0); | 1084 | add_to_dirlist(ep->d_name, NULL, NULL, 0); |
1085 | } | 1085 | } |
diff --git a/coreutils/echo.c b/coreutils/echo.c index 99063ae52..0c8eac3bc 100644 --- a/coreutils/echo.c +++ b/coreutils/echo.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
30 | #include "busybox.h" | 30 | #include "busybox.h" |
31 | 31 | ||
32 | int bb_echo(int ATTRIBUTE_UNUSED argc, char **argv) | 32 | int bb_echo(char **argv) |
33 | { | 33 | { |
34 | #ifndef CONFIG_FEATURE_FANCY_ECHO | 34 | #ifndef CONFIG_FEATURE_FANCY_ECHO |
35 | #define eflag '\\' | 35 | #define eflag '\\' |
@@ -114,7 +114,7 @@ just_echo: | |||
114 | 114 | ||
115 | int echo_main(int argc, char** argv) | 115 | int echo_main(int argc, char** argv) |
116 | { | 116 | { |
117 | (void)bb_echo(argc, argv); | 117 | (void)bb_echo(argv); |
118 | fflush_stdout_and_exit(EXIT_SUCCESS); | 118 | fflush_stdout_and_exit(EXIT_SUCCESS); |
119 | } | 119 | } |
120 | 120 | ||
diff --git a/coreutils/expr.c b/coreutils/expr.c index 191473446..51e553dc6 100644 --- a/coreutils/expr.c +++ b/coreutils/expr.c | |||
@@ -136,7 +136,7 @@ static int null(VALUE * v) | |||
136 | if (v->type == integer) | 136 | if (v->type == integer) |
137 | return v->u.i == 0; | 137 | return v->u.i == 0; |
138 | else /* string: */ | 138 | else /* string: */ |
139 | return v->u.s[0] == '\0' || strcmp(v->u.s, "0") == 0; | 139 | return v->u.s[0] == '\0' || LONE_CHAR(v->u.s, '0'); |
140 | } | 140 | } |
141 | 141 | ||
142 | /* Coerce V to a string value (can't fail). */ | 142 | /* Coerce V to a string value (can't fail). */ |
diff --git a/coreutils/test.c b/coreutils/test.c index ebb4f9086..d3d760467 100644 --- a/coreutils/test.c +++ b/coreutils/test.c | |||
@@ -175,14 +175,16 @@ int bb_test(int argc, char **argv) | |||
175 | { | 175 | { |
176 | int res; | 176 | int res; |
177 | 177 | ||
178 | if (strcmp(argv[0], "[") == 0) { | 178 | if (LONE_CHAR(argv[0], '[')) { |
179 | if (strcmp(argv[--argc], "]")) { | 179 | --argc; |
180 | if (NOT_LONE_CHAR(argv[argc], ']')) { | ||
180 | bb_error_msg("missing ]"); | 181 | bb_error_msg("missing ]"); |
181 | return 2; | 182 | return 2; |
182 | } | 183 | } |
183 | argv[argc] = NULL; | 184 | argv[argc] = NULL; |
184 | } else if (strcmp(argv[0], "[[") == 0) { | 185 | } else if (strcmp(argv[0], "[[") == 0) { |
185 | if (strcmp(argv[--argc], "]]")) { | 186 | --argc; |
187 | if (strcmp(argv[argc], "]]")) { | ||
186 | bb_error_msg("missing ]]"); | 188 | bb_error_msg("missing ]]"); |
187 | return 2; | 189 | return 2; |
188 | } | 190 | } |
@@ -578,6 +580,6 @@ static int is_a_group_member(gid_t gid) | |||
578 | 580 | ||
579 | int test_main(int argc, char **argv) | 581 | int test_main(int argc, char **argv) |
580 | { | 582 | { |
581 | exit(bb_test(argc, argv)); | 583 | return bb_test(argc, argv); |
582 | } | 584 | } |
583 | 585 | ||