diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-21 18:41:46 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-21 18:41:46 +0200 |
| commit | fd5e66eb8eb4e39460a6cfde4b10dcab3870f26b (patch) | |
| tree | 47bfea148a09f17a6ba1ed7c2105103cd07d2dcf /coreutils | |
| parent | 578008a9897b2d64532ed5843807c05fba1f862f (diff) | |
| download | busybox-w32-fd5e66eb8eb4e39460a6cfde4b10dcab3870f26b.tar.gz busybox-w32-fd5e66eb8eb4e39460a6cfde4b10dcab3870f26b.tar.bz2 busybox-w32-fd5e66eb8eb4e39460a6cfde4b10dcab3870f26b.zip | |
basename: do not use argc
function old new delta
basename_main 153 148 -5
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/basename.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/coreutils/basename.c b/coreutils/basename.c index 481cdcee9..566aeebda 100644 --- a/coreutils/basename.c +++ b/coreutils/basename.c | |||
| @@ -47,25 +47,24 @@ | |||
| 47 | /* This is a NOFORK applet. Be very careful! */ | 47 | /* This is a NOFORK applet. Be very careful! */ |
| 48 | 48 | ||
| 49 | int basename_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 49 | int basename_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 50 | int basename_main(int argc, char **argv) | 50 | int basename_main(int argc UNUSED_PARAM, char **argv) |
| 51 | { | 51 | { |
| 52 | size_t m, n; | 52 | size_t m, n; |
| 53 | char *s; | 53 | char *s; |
| 54 | 54 | ||
| 55 | if (argv[1] && strcmp(argv[1], "--") == 0) { | 55 | if (argv[1] && strcmp(argv[1], "--") == 0) { |
| 56 | argv++; | 56 | argv++; |
| 57 | argc--; | ||
| 58 | } | 57 | } |
| 59 | 58 | if (!argv[1]) | |
| 60 | if ((unsigned)(argc-2) >= 2) { | ||
| 61 | bb_show_usage(); | 59 | bb_show_usage(); |
| 62 | } | ||
| 63 | 60 | ||
| 64 | /* It should strip slash: /abc/def/ -> def */ | 61 | /* It should strip slash: /abc/def/ -> def */ |
| 65 | s = bb_get_last_path_component_strip(*++argv); | 62 | s = bb_get_last_path_component_strip(*++argv); |
| 66 | 63 | ||
| 67 | m = strlen(s); | 64 | m = strlen(s); |
| 68 | if (*++argv) { | 65 | if (*++argv) { |
| 66 | if (argv[1]) | ||
| 67 | bb_show_usage(); | ||
| 69 | n = strlen(*argv); | 68 | n = strlen(*argv); |
| 70 | if ((m > n) && (strcmp(s+m-n, *argv) == 0)) { | 69 | if ((m > n) && (strcmp(s+m-n, *argv) == 0)) { |
| 71 | m -= n; | 70 | m -= n; |
