diff options
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/Kbuild | 3 | ||||
-rw-r--r-- | coreutils/basename.c | 11 | ||||
-rw-r--r-- | coreutils/echo.c | 4 |
3 files changed, 10 insertions, 8 deletions
diff --git a/coreutils/Kbuild b/coreutils/Kbuild index b9ed0d79e..253eb6da8 100644 --- a/coreutils/Kbuild +++ b/coreutils/Kbuild | |||
@@ -30,6 +30,7 @@ lib-$(CONFIG_DOS2UNIX) += dos2unix.o | |||
30 | lib-$(CONFIG_DU) += du.o | 30 | lib-$(CONFIG_DU) += du.o |
31 | lib-$(CONFIG_ECHO) += echo.o | 31 | lib-$(CONFIG_ECHO) += echo.o |
32 | lib-$(CONFIG_ASH) += echo.o # used by ash | 32 | lib-$(CONFIG_ASH) += echo.o # used by ash |
33 | lib-$(CONFIG_HUSH) += echo.o # used by hush | ||
33 | lib-$(CONFIG_ENV) += env.o | 34 | lib-$(CONFIG_ENV) += env.o |
34 | lib-$(CONFIG_EXPR) += expr.o | 35 | lib-$(CONFIG_EXPR) += expr.o |
35 | lib-$(CONFIG_EXPAND) += expand.o | 36 | lib-$(CONFIG_EXPAND) += expand.o |
@@ -72,6 +73,8 @@ lib-$(CONFIG_TAIL) += tail.o | |||
72 | lib-$(CONFIG_TEE) += tee.o | 73 | lib-$(CONFIG_TEE) += tee.o |
73 | lib-$(CONFIG_TEST) += test.o | 74 | lib-$(CONFIG_TEST) += test.o |
74 | lib-$(CONFIG_ASH) += test.o # used by ash | 75 | lib-$(CONFIG_ASH) += test.o # used by ash |
76 | lib-$(CONFIG_HUSH) += test.o # used by hush | ||
77 | lib-$(CONFIG_MSH) += test.o # used by msh | ||
75 | lib-$(CONFIG_TOUCH) += touch.o | 78 | lib-$(CONFIG_TOUCH) += touch.o |
76 | lib-$(CONFIG_TR) += tr.o | 79 | lib-$(CONFIG_TR) += tr.o |
77 | lib-$(CONFIG_TRUE) += true.o | 80 | lib-$(CONFIG_TRUE) += true.o |
diff --git a/coreutils/basename.c b/coreutils/basename.c index d536a1bf3..ed2377948 100644 --- a/coreutils/basename.c +++ b/coreutils/basename.c | |||
@@ -37,15 +37,16 @@ int basename_main(int argc, char **argv) | |||
37 | /* It should strip slash: /abc/def/ -> def */ | 37 | /* It should strip slash: /abc/def/ -> def */ |
38 | s = bb_get_last_path_component_strip(*++argv); | 38 | s = bb_get_last_path_component_strip(*++argv); |
39 | 39 | ||
40 | m = strlen(s); | ||
40 | if (*++argv) { | 41 | if (*++argv) { |
41 | n = strlen(*argv); | 42 | n = strlen(*argv); |
42 | m = strlen(s); | ||
43 | if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) { | 43 | if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) { |
44 | s[m-n] = '\0'; | 44 | m -= n; |
45 | s[m] = '\0'; | ||
45 | } | 46 | } |
46 | } | 47 | } |
47 | 48 | ||
48 | puts(s); | 49 | /* puts(s) will do, but we can do without stdio this way: */ |
49 | 50 | s[m++] = '\n'; | |
50 | return fflush(stdout); | 51 | return full_write(STDOUT_FILENO, s, m) == m; |
51 | } | 52 | } |
diff --git a/coreutils/echo.c b/coreutils/echo.c index fd6c950ea..6e25db62c 100644 --- a/coreutils/echo.c +++ b/coreutils/echo.c | |||
@@ -27,10 +27,8 @@ | |||
27 | 27 | ||
28 | /* This is a NOFORK applet. Be very careful! */ | 28 | /* This is a NOFORK applet. Be very careful! */ |
29 | 29 | ||
30 | /* argc is unused, but removing it precludes compiler from | 30 | /* NB: can be used by shell even if not enabled as applet */ |
31 | * using call -> jump optimization */ | ||
32 | 31 | ||
33 | int echo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
34 | int echo_main(int argc ATTRIBUTE_UNUSED, char **argv) | 32 | int echo_main(int argc ATTRIBUTE_UNUSED, char **argv) |
35 | { | 33 | { |
36 | const char *arg; | 34 | const char *arg; |