Skip to content

Commit

Permalink
Add support for long options to cmp
Browse files Browse the repository at this point in the history
In order to improve compatibility with GNU cmp add support for long
options to busybox cmp.

function                                             old     new   delta
static.cmp_longopts                                    -      36     +36
cmp_main                                             589     594      +5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 41/0)               Total: 41 bytes

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
  • Loading branch information
wlozano0collabora authored and Denys Vlasenko committed Jan 23, 2022
1 parent f12fb1e commit 6dd6a6c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions editors/cmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ int cmp_main(int argc UNUSED_PARAM, char **argv)
int retval = 0;
int max_count = -1;

#if !ENABLE_LONG_OPTS
opt = getopt32(argv, "^"
OPT_STR
"\0" "-1"
Expand All @@ -62,6 +63,23 @@ int cmp_main(int argc UNUSED_PARAM, char **argv)
":l--s:s--l",
&max_count
);
#else
static const char cmp_longopts[] ALIGN1 =
"bytes\0" Required_argument "n"
"quiet\0" No_argument "s"
"silent\0" No_argument "s"
"verbose\0" No_argument "l"
;
opt = getopt32long(argv, "^"
OPT_STR
"\0" "-1"
IF_DESKTOP(":?4")
IF_NOT_DESKTOP(":?2")
":l--s:s--l",
cmp_longopts,
&max_count
);
#endif
argv += optind;

filename1 = *argv;
Expand Down

0 comments on commit 6dd6a6c

Please sign in to comment.