diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-01 14:47:57 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-01 14:47:57 +0000 |
commit | 468aea2d8800cc0496383616d82d7c957ae8bc50 (patch) | |
tree | 8a2f3d80dc2440dd007caed4cfa235b3858c9170 /coreutils/basename.c | |
parent | 165f5b394fa337e71e08435b51108f4394199b2b (diff) | |
download | busybox-w32-468aea2d8800cc0496383616d82d7c957ae8bc50.tar.gz busybox-w32-468aea2d8800cc0496383616d82d7c957ae8bc50.tar.bz2 busybox-w32-468aea2d8800cc0496383616d82d7c957ae8bc50.zip |
shells: do not frocibly enable test, echo and kill _applets_,
just build relevant source and use xxx_main functions.
build system: add a special case when we have exactly one applet enabled
(makes "true", "false", "basename" REALLY tiny).
getopt32: do not use stdio.
function old new delta
getopt32 1385 1412 +27
make_device 1187 1200 +13
basename_main 120 127 +7
tcpudpsvd_main 1922 1926 +4
testcmd 5 - -5
echocmd 5 - -5
fuser_main 1243 1231 -12
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 4/1 up/down: 51/-22) Total: 29 bytes
Diffstat (limited to 'coreutils/basename.c')
-rw-r--r-- | coreutils/basename.c | 11 |
1 files changed, 6 insertions, 5 deletions
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 | } |