Skip to content

Commit

Permalink
don't pass argc in getopt32, it's superfluous
Browse files Browse the repository at this point in the history
(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
  • Loading branch information
Denis Vlasenko committed Aug 18, 2007
1 parent d6cd9d7 commit fe7cd64
Show file tree
Hide file tree
Showing 143 changed files with 174 additions and 169 deletions.
2 changes: 1 addition & 1 deletion archival/ar.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int ar_main(int argc, char **argv)

/* Prepend '-' to the first argument if required */
opt_complementary = "--:p:t:x:-1:p--tx:t--px:x--pt";
opt = getopt32(argc, argv, "ptxovcr");
opt = getopt32(argv, "ptxovcr");

if (opt & AR_CTX_PRINT) {
archive_handle->action_data = data_extract_to_stdout;
Expand Down
8 changes: 4 additions & 4 deletions archival/bbunzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ USE_DESKTOP(long long) int unpack_bunzip2(void)
int bunzip2_main(int argc, char **argv);
int bunzip2_main(int argc, char **argv)
{
getopt32(argc, argv, "cf");
getopt32(argv, "cf");
argv += optind;
if (applet_name[2] == 'c')
option_mask32 |= OPT_STDOUT;
Expand Down Expand Up @@ -260,7 +260,7 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
int gunzip_main(int argc, char **argv);
int gunzip_main(int argc, char **argv)
{
getopt32(argc, argv, "cfvdt");
getopt32(argv, "cfvdt");
argv += optind;
/* if called as zcat */
if (applet_name[1] == 'c')
Expand Down Expand Up @@ -298,7 +298,7 @@ USE_DESKTOP(long long) int unpack_unlzma(void)
int unlzma_main(int argc, char **argv);
int unlzma_main(int argc, char **argv)
{
getopt32(argc, argv, "c");
getopt32(argv, "c");
argv += optind;
/* lzmacat? */
if (applet_name[4] == 'c')
Expand Down Expand Up @@ -340,7 +340,7 @@ USE_DESKTOP(long long) int unpack_uncompress(void)
int uncompress_main(int argc, char **argv);
int uncompress_main(int argc, char **argv)
{
getopt32(argc, argv, "cf");
getopt32(argv, "cf");
argv += optind;

return bbunpack(argv, make_new_name_uncompress, unpack_uncompress);
Expand Down
2 changes: 1 addition & 1 deletion archival/cpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int cpio_main(int argc, char **argv)
archive_handle->seek = seek_by_read;
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;

opt = getopt32(argc, argv, "ituvF:dm", &cpio_filename);
opt = getopt32(argv, "ituvF:dm", &cpio_filename);

/* One of either extract or test options must be given */
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion archival/dpkg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@ int dpkg_main(int argc, char **argv)
OPT_unpack = 0x40,
};

opt = getopt32(argc, argv, "CF:ilPru", &str_f);
opt = getopt32(argv, "CF:ilPru", &str_f);
//if (opt & OPT_configure) ... // -C
if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg)
if (strcmp(str_f, "depends"))
Expand Down
2 changes: 1 addition & 1 deletion archival/dpkg_deb.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int dpkg_deb_main(int argc, char **argv)
#endif

opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
opt = getopt32(argc, argv, "cefXx");
opt = getopt32(argv, "cefXx");

if (opt & DPKG_DEB_OPT_CONTENTS) {
tar_archive->action_header = header_verbose_list;
Expand Down
2 changes: 1 addition & 1 deletion archival/gzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,7 @@ int gzip_main(int argc, char **argv)
unsigned opt;

/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
opt = getopt32(argc, argv, "cfv" USE_GUNZIP("d") "q123456789" );
opt = getopt32(argv, "cfv" USE_GUNZIP("d") "q123456789" );
option_mask32 &= 0x7; /* Clear -d, ignore -q, -0..9 */
//if (opt & 0x1) // -c
//if (opt & 0x2) // -f
Expand Down
2 changes: 1 addition & 1 deletion archival/tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ int tar_main(int argc, char **argv)
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
applet_long_options = tar_longopts;
#endif
opt = getopt32(argc, argv,
opt = getopt32(argv,
"txC:f:Opvk"
USE_FEATURE_TAR_CREATE( "ch" )
USE_FEATURE_TAR_BZIP2( "j" )
Expand Down
2 changes: 1 addition & 1 deletion console-tools/setconsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int setconsole_main(int argc, char **argv)
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
applet_long_options = setconsole_longopts;
#endif
flags = getopt32(argc, argv, "r");
flags = getopt32(argv, "r");

if (argc - optind > 1)
bb_show_usage();
Expand Down
2 changes: 1 addition & 1 deletion coreutils/cal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion coreutils/cat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion coreutils/catv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion coreutils/chmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion coreutils/chown.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down
2 changes: 1 addition & 1 deletion coreutils/comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion coreutils/cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion coreutils/cut.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, &ltok);
getopt32(argv, optstring, &sopt, &sopt, &sopt, &ltok);
// argc -= optind;
argv += optind;
if (!(option_mask32 & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
Expand Down
2 changes: 1 addition & 1 deletion coreutils/date.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions coreutils/df.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion coreutils/dos2unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
4 changes: 2 additions & 2 deletions coreutils/du.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion coreutils/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions coreutils/expand.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion coreutils/fold.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion coreutils/id.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion coreutils/install.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion coreutils/libcoreutils/getopt_mk_fifo_nod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion coreutils/ln.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions coreutils/ls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion coreutils/md5_sha1_sum.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion coreutils/mkdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion coreutils/mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion coreutils/od_bloaty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion coreutils/readlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion coreutils/rm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion coreutils/rmdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion coreutils/sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion coreutils/split.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit fe7cd64

Please sign in to comment.