don't pass argc in getopt32, it's superfluous
(add/remove: 0/0 grow/shrink: 12/131 up/down: 91/-727) Total: -636 bytes text data bss dec hex filename 773469 1058 11092 785619 bfcd3 busybox_old 772644 1058 11092 784794 bf99a busybox_unstripped
This commit is contained in:
@@ -86,7 +86,7 @@ int cal_main(int argc, char **argv)
|
||||
char day_headings[28]; /* 28 for julian, 21 for nonjulian */
|
||||
char buf[40];
|
||||
|
||||
flags = getopt32(argc, argv, "jy");
|
||||
flags = getopt32(argv, "jy");
|
||||
julian = flags & 1;
|
||||
month = 0;
|
||||
argv += optind;
|
||||
|
@@ -46,7 +46,7 @@ int bb_cat(char **argv)
|
||||
int cat_main(int argc, char **argv);
|
||||
int cat_main(int argc, char **argv)
|
||||
{
|
||||
getopt32(argc, argv, "u");
|
||||
getopt32(argv, "u");
|
||||
argv += optind;
|
||||
return bb_cat(argv);
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ int catv_main(int argc, char **argv)
|
||||
int fd;
|
||||
unsigned flags;
|
||||
|
||||
flags = getopt32(argc, argv, "etv");
|
||||
flags = getopt32(argv, "etv");
|
||||
#define CATV_OPT_e (1<<0)
|
||||
#define CATV_OPT_t (1<<1)
|
||||
#define CATV_OPT_v (1<<2)
|
||||
|
@@ -93,7 +93,7 @@ int chmod_main(int argc, char **argv)
|
||||
|
||||
/* Parse options */
|
||||
opt_complementary = "-2";
|
||||
getopt32(argc, argv, ("-"OPT_STR) + 1); /* Reuse string */
|
||||
getopt32(argv, ("-"OPT_STR) + 1); /* Reuse string */
|
||||
argv += optind;
|
||||
|
||||
/* Restore option-like mode if needed */
|
||||
|
@@ -69,7 +69,7 @@ int chown_main(int argc, char **argv)
|
||||
chown_fptr chown_func;
|
||||
|
||||
opt_complementary = "-2";
|
||||
getopt32(argc, argv, OPT_STR);
|
||||
getopt32(argv, OPT_STR);
|
||||
argv += optind;
|
||||
|
||||
/* This matches coreutils behavior (almost - see below) */
|
||||
|
@@ -47,7 +47,7 @@ int comm_main(int argc, char **argv)
|
||||
unsigned flags;
|
||||
|
||||
opt_complementary = "=2";
|
||||
flags = getopt32(argc, argv, "123");
|
||||
flags = getopt32(argv, "123");
|
||||
argv += optind;
|
||||
|
||||
for (i = 0; i < 2; ++i) {
|
||||
|
@@ -45,7 +45,7 @@ int cp_main(int argc, char **argv)
|
||||
// -r and -R are the same
|
||||
// -a = -pdR
|
||||
opt_complementary = "l--s:s--l:Pd:rR:apdR";
|
||||
flags = getopt32(argc, argv, FILEUTILS_CP_OPTSTR "arPHL");
|
||||
flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPHL");
|
||||
/* Default behavior of cp is to dereference, so we don't have to do
|
||||
* anything special when we are given -L.
|
||||
* The behavior of -H is *almost* like -L, but not quite, so let's
|
||||
|
@@ -171,7 +171,7 @@ int cut_main(int argc, char **argv)
|
||||
char *sopt, *ltok;
|
||||
|
||||
opt_complementary = "b--bcf:c--bcf:f--bcf";
|
||||
getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, <ok);
|
||||
getopt32(argv, optstring, &sopt, &sopt, &sopt, <ok);
|
||||
// argc -= optind;
|
||||
argv += optind;
|
||||
if (!(option_mask32 & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
|
||||
|
@@ -53,7 +53,7 @@ int date_main(int argc, char **argv)
|
||||
|
||||
opt_complementary = "d--s:s--d"
|
||||
USE_FEATURE_DATE_ISOFMT(":R--I:I--R");
|
||||
opt = getopt32(argc, argv, "Rs:ud:r:"
|
||||
opt = getopt32(argv, "Rs:ud:r:"
|
||||
USE_FEATURE_DATE_ISOFMT("I::D:"),
|
||||
&date_str, &date_str, &filename
|
||||
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg));
|
||||
|
@@ -47,7 +47,7 @@ int df_main(int argc, char **argv)
|
||||
|
||||
#if ENABLE_FEATURE_HUMAN_READABLE
|
||||
opt_complementary = "h-km:k-hm:m-hk";
|
||||
opt = getopt32(argc, argv, "hmk");
|
||||
opt = getopt32(argv, "hmk");
|
||||
if (opt & 1) {
|
||||
df_disp_hr = 0;
|
||||
disp_units_hdr = " Size";
|
||||
@@ -57,7 +57,7 @@ int df_main(int argc, char **argv)
|
||||
disp_units_hdr = "1M-blocks";
|
||||
}
|
||||
#else
|
||||
opt = getopt32(argc, argv, "k");
|
||||
opt = getopt32(argv, "k");
|
||||
#endif
|
||||
|
||||
printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
|
||||
|
@@ -92,7 +92,7 @@ int dos2unix_main(int argc, char **argv)
|
||||
|
||||
/* -u convert to unix, -d convert to dos */
|
||||
opt_complementary = "u--d:d--u"; /* mutually exclusive */
|
||||
o = getopt32(argc, argv, "du");
|
||||
o = getopt32(argv, "du");
|
||||
|
||||
/* Do the conversion requested by an argument else do the default
|
||||
* conversion depending on our name. */
|
||||
|
@@ -170,7 +170,7 @@ int du_main(int argc, char **argv)
|
||||
*/
|
||||
#if ENABLE_FEATURE_HUMAN_READABLE
|
||||
opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
|
||||
opt = getopt32(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
|
||||
opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
|
||||
if (opt & (1 << 9)) {
|
||||
/* -h opt */
|
||||
disp_hr = 0;
|
||||
@@ -185,7 +185,7 @@ int du_main(int argc, char **argv)
|
||||
}
|
||||
#else
|
||||
opt_complementary = "H-L:L-H:s-d:d-s";
|
||||
opt = getopt32(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
|
||||
opt = getopt32(argv, "aHkLsx" "d:" "lc", &smax_print_depth);
|
||||
#if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
|
||||
if (opt & (1 << 2)) {
|
||||
/* -k opt */
|
||||
|
@@ -54,7 +54,7 @@ int env_main(int argc, char** argv)
|
||||
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
|
||||
applet_long_options = env_longopts;
|
||||
#endif
|
||||
opt = getopt32(argc, argv, "+iu:", &unset_env);
|
||||
opt = getopt32(argv, "+iu:", &unset_env);
|
||||
argv += optind;
|
||||
if (*argv && LONE_DASH(argv[0])) {
|
||||
opt |= 1;
|
||||
|
@@ -153,12 +153,12 @@ int expand_main(int argc, char **argv)
|
||||
|
||||
if (ENABLE_EXPAND && (!ENABLE_UNEXPAND || applet_name[0] == 'e')) {
|
||||
USE_FEATURE_EXPAND_LONG_OPTIONS(applet_long_options = expand_longopts);
|
||||
opt = getopt32(argc, argv, "it:", &opt_t);
|
||||
opt = getopt32(argv, "it:", &opt_t);
|
||||
} else if (ENABLE_UNEXPAND) {
|
||||
USE_FEATURE_UNEXPAND_LONG_OPTIONS(applet_long_options = unexpand_longopts);
|
||||
/* -t NUM sets also -a */
|
||||
opt_complementary = "ta";
|
||||
opt = getopt32(argc, argv, "ft:a", &opt_t);
|
||||
opt = getopt32(argv, "ft:a", &opt_t);
|
||||
/* -f --first-only is the default */
|
||||
if (!(opt & OPT_ALL)) opt |= OPT_INITIAL;
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ int fold_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
flags = getopt32(argc, argv, "bsw:", &w_opt);
|
||||
flags = getopt32(argv, "bsw:", &w_opt);
|
||||
if (flags & FLAG_WIDTH)
|
||||
width = xatoul_range(w_opt, 1, 10000);
|
||||
|
||||
|
@@ -50,7 +50,7 @@ int id_main(int argc, char **argv)
|
||||
/* Don't allow -n -r -nr -ug -rug -nug -rnug */
|
||||
/* Don't allow more than one username */
|
||||
opt_complementary = "?1:u--g:g--u:r?ug:n?ug" USE_SELINUX(":u--Z:Z--u:g--Z:Z--g");
|
||||
flags = getopt32(argc, argv, "rnug" USE_SELINUX("Z"));
|
||||
flags = getopt32(argv, "rnug" USE_SELINUX("Z"));
|
||||
|
||||
/* This values could be overwritten later */
|
||||
uid = geteuid();
|
||||
|
@@ -101,7 +101,7 @@ int install_main(int argc, char **argv)
|
||||
opt_complementary = "s--d:d--s" USE_SELINUX(":Z--\xff:\xff--Z");
|
||||
/* -c exists for backwards compatibility, it's needed */
|
||||
|
||||
flags = getopt32(argc, argv, "cdpsg:m:o:" USE_SELINUX("Z:"),
|
||||
flags = getopt32(argv, "cdpsg:m:o:" USE_SELINUX("Z:"),
|
||||
&gid_str, &mode_str, &uid_str USE_SELINUX(, &scontext));
|
||||
|
||||
#if ENABLE_SELINUX
|
||||
|
@@ -31,7 +31,7 @@ mode_t getopt_mk_fifo_nod(int argc, char **argv)
|
||||
security_context_t scontext;
|
||||
#endif
|
||||
int opt;
|
||||
opt = getopt32(argc, argv, "m:" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext));
|
||||
opt = getopt32(argv, "m:" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext));
|
||||
if (opt & 1) {
|
||||
if (bb_parse_mode(smode, &mode))
|
||||
umask(0);
|
||||
|
@@ -34,7 +34,7 @@ int ln_main(int argc, char **argv)
|
||||
struct stat statbuf;
|
||||
int (*link_func)(const char *, const char *);
|
||||
|
||||
flag = getopt32(argc, argv, "sfnbS:", &suffix);
|
||||
flag = getopt32(argv, "sfnbS:", &suffix);
|
||||
|
||||
if (argc == optind) {
|
||||
bb_show_usage();
|
||||
|
@@ -820,14 +820,14 @@ int ls_main(int argc, char **argv)
|
||||
/* process options */
|
||||
USE_FEATURE_LS_COLOR(applet_long_options = ls_color_opt;)
|
||||
#if ENABLE_FEATURE_AUTOWIDTH
|
||||
opt = getopt32(argc, argv, ls_options, &tabstops_str, &terminal_width_str
|
||||
opt = getopt32(argv, ls_options, &tabstops_str, &terminal_width_str
|
||||
USE_FEATURE_LS_COLOR(, &color_opt));
|
||||
if (tabstops_str)
|
||||
tabstops = xatou(tabstops_str);
|
||||
if (terminal_width_str)
|
||||
terminal_width = xatou(terminal_width_str);
|
||||
#else
|
||||
opt = getopt32(argc, argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt));
|
||||
opt = getopt32(argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt));
|
||||
#endif
|
||||
for (i = 0; opt_flags[i] != (1U<<31); i++) {
|
||||
if (opt & (1 << i)) {
|
||||
|
@@ -88,7 +88,7 @@ int md5_sha1_sum_main(int argc, char **argv)
|
||||
: HASH_SHA1;
|
||||
|
||||
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK)
|
||||
flags = getopt32(argc, argv, "scw");
|
||||
flags = getopt32(argv, "scw");
|
||||
else optind = 1;
|
||||
|
||||
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && !(flags & FLAG_CHECK)) {
|
||||
|
@@ -49,7 +49,7 @@ int mkdir_main(int argc, char **argv)
|
||||
#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
|
||||
applet_long_options = mkdir_longopts;
|
||||
#endif
|
||||
opt = getopt32(argc, argv, "m:p" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext));
|
||||
opt = getopt32(argv, "m:p" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext));
|
||||
if (opt & 1) {
|
||||
mode = 0777;
|
||||
if (!bb_parse_mode(smode, &mode)) {
|
||||
|
@@ -48,7 +48,7 @@ int mv_main(int argc, char **argv)
|
||||
applet_long_options = mv_longopts;
|
||||
#endif
|
||||
opt_complementary = "f-i:i-f";
|
||||
flags = getopt32(argc, argv, "fi");
|
||||
flags = getopt32(argv, "fi");
|
||||
if (optind + 2 > argc) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
@@ -1259,7 +1259,7 @@ int od_main(int argc, char **argv)
|
||||
#if ENABLE_GETOPT_LONG
|
||||
applet_long_options = od_longopts;
|
||||
#endif
|
||||
opt = getopt32(argc, argv, "A:N:abcdfhij:lot:vxsS:"
|
||||
opt = getopt32(argv, "A:N:abcdfhij:lot:vxsS:"
|
||||
"w::", // -w with optional param
|
||||
// -S was -s and also had optional parameter
|
||||
// but in coreutils 6.3 it was renamed and now has
|
||||
|
@@ -21,7 +21,7 @@ int readlink_main(int argc, char **argv)
|
||||
unsigned opt;
|
||||
/* We need exactly one non-option argument. */
|
||||
opt_complementary = "=1";
|
||||
opt = getopt32(argc, argv, "f");
|
||||
opt = getopt32(argv, "f");
|
||||
fname = argv[optind];
|
||||
)
|
||||
SKIP_FEATURE_READLINK_FOLLOW(
|
||||
|
@@ -27,7 +27,7 @@ int rm_main(int argc, char **argv)
|
||||
unsigned opt;
|
||||
|
||||
opt_complementary = "f-i:i-f";
|
||||
opt = getopt32(argc, argv, "fiRr");
|
||||
opt = getopt32(argv, "fiRr");
|
||||
argv += optind;
|
||||
if (opt & 1)
|
||||
flags |= FILEUTILS_FORCE;
|
||||
|
@@ -24,7 +24,7 @@ int rmdir_main(int argc, char **argv)
|
||||
int do_dot;
|
||||
char *path;
|
||||
|
||||
flags = getopt32(argc, argv, "p");
|
||||
flags = getopt32(argv, "p");
|
||||
argv += optind;
|
||||
|
||||
if (!*argv) {
|
||||
|
@@ -290,7 +290,7 @@ int sort_main(int argc, char **argv)
|
||||
/* -o and -t can be given at most once */
|
||||
opt_complementary = "o--o:t--t:" /* -t, -o: maximum one of each */
|
||||
"k::"; /* -k takes list */
|
||||
getopt32(argc, argv, OPT_STR, &str_ignored, &str_ignored, &str_o, &lst_k, &str_t);
|
||||
getopt32(argv, OPT_STR, &str_ignored, &str_ignored, &str_o, &lst_k, &str_t);
|
||||
#if ENABLE_FEATURE_SORT_BIG
|
||||
if (option_mask32 & FLAG_o) outfile = xfopen(str_o, "w");
|
||||
if (option_mask32 & FLAG_t) {
|
||||
|
@@ -69,7 +69,7 @@ int split_main(int argc, char **argv)
|
||||
char *src;
|
||||
|
||||
opt_complementary = "?2";
|
||||
opt = getopt32(argc, argv, "l:b:a:", &count_p, &count_p, &sfx);
|
||||
opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &sfx);
|
||||
|
||||
if (opt & SPLIT_OPT_l)
|
||||
cnt = xatoul(count_p);
|
||||
|
@@ -614,7 +614,7 @@ int stat_main(int argc, char **argv)
|
||||
int ok = 1;
|
||||
bool (*statfunc)(char const *, char const *) = do_stat;
|
||||
|
||||
getopt32(argc, argv, "ftL"
|
||||
getopt32(argv, "ftL"
|
||||
USE_SELINUX("Z")
|
||||
USE_FEATURE_STAT_FORMAT("c:", &format)
|
||||
);
|
||||
|
@@ -80,7 +80,7 @@ int sum_main(int argc, char **argv)
|
||||
unsigned n;
|
||||
unsigned type = SUM_BSD;
|
||||
|
||||
n = getopt32(argc, argv, "sr");
|
||||
n = getopt32(argv, "sr");
|
||||
if (n & 1) type = SUM_SYSV;
|
||||
/* give the bsd priority over sysv func */
|
||||
if (n & 2) type = SUM_BSD;
|
||||
|
@@ -107,7 +107,7 @@ int tail_main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
opt = getopt32(argc, argv, "fc:n:" USE_FEATURE_FANCY_TAIL("qs:v"),
|
||||
opt = getopt32(argv, "fc:n:" USE_FEATURE_FANCY_TAIL("qs:v"),
|
||||
&str_c, &str_n USE_FEATURE_FANCY_TAIL(,&str_s));
|
||||
#define FOLLOW (opt & 0x1)
|
||||
#define COUNT_BYTES (opt & 0x2)
|
||||
|
@@ -28,7 +28,7 @@ int tee_main(int argc, char **argv)
|
||||
#else
|
||||
int c;
|
||||
#endif
|
||||
retval = getopt32(argc, argv, "ia"); /* 'a' must be 2nd */
|
||||
retval = getopt32(argv, "ia"); /* 'a' must be 2nd */
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
|
@@ -26,7 +26,7 @@ int touch_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
int status = EXIT_SUCCESS;
|
||||
int flags = getopt32(argc, argv, "c");
|
||||
int flags = getopt32(argv, "c");
|
||||
|
||||
argv += optind;
|
||||
|
||||
|
@@ -21,7 +21,7 @@ int tty_main(int argc, char **argv)
|
||||
|
||||
xfunc_error_retval = 2; /* SUSv3 requires > 1 for error. */
|
||||
|
||||
USE_INCLUDE_SUSv2(silent = getopt32(argc, argv, "s");)
|
||||
USE_INCLUDE_SUSv2(silent = getopt32(argv, "s");)
|
||||
|
||||
/* gnu tty outputs a warning that it is ignoring all args. */
|
||||
bb_warn_ignoring_args(argc - optind);
|
||||
|
@@ -58,7 +58,7 @@ int uname_main(int argc, char **argv)
|
||||
const unsigned short int *delta;
|
||||
char toprint;
|
||||
|
||||
toprint = getopt32(argc, argv, options);
|
||||
toprint = getopt32(argv, options);
|
||||
|
||||
if (argc != optind) {
|
||||
bb_show_usage();
|
||||
|
@@ -45,7 +45,7 @@ int uniq_main(int argc, char **argv)
|
||||
|
||||
skip_fields = skip_chars = 0;
|
||||
|
||||
opt = getopt32(argc, argv, "cduf:s:", &s0, &s1);
|
||||
opt = getopt32(argv, "cduf:s:", &s0, &s1);
|
||||
if (opt & OPT_f)
|
||||
skip_fields = xatoul(s0);
|
||||
if (opt & OPT_s)
|
||||
|
@@ -134,7 +134,7 @@ int uudecode_main(int argc, char **argv)
|
||||
char *line;
|
||||
|
||||
opt_complementary = "?1"; /* 1 argument max */
|
||||
getopt32(argc, argv, "o:", &outname);
|
||||
getopt32(argv, "o:", &outname);
|
||||
argv += optind;
|
||||
|
||||
if (argv[0])
|
||||
|
@@ -28,7 +28,7 @@ int uuencode_main(int argc, char **argv)
|
||||
tbl = bb_uuenc_tbl_std;
|
||||
mode = 0666 & ~umask(0666);
|
||||
opt_complementary = "-1:?2"; /* must have 1 or 2 args */
|
||||
if (getopt32(argc, argv, "m")) {
|
||||
if (getopt32(argv, "m")) {
|
||||
tbl = bb_uuenc_tbl_base64;
|
||||
}
|
||||
argv += optind;
|
||||
|
@@ -86,7 +86,7 @@ int wc_main(int argc, char **argv)
|
||||
smallint in_word;
|
||||
unsigned print_type;
|
||||
|
||||
print_type = getopt32(argc, argv, "lwcL");
|
||||
print_type = getopt32(argv, "lwcL");
|
||||
|
||||
if (print_type == 0) {
|
||||
print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS);
|
||||
|
Reference in New Issue
Block a user