getopt_ulflags -> getopt32.
It is impossible to formulate sane ABI based on size of ulong because it can be 32-bit or 64-bit. Basically it means that you cannot portably use more that 32 option chars in one call anyway... Make it explicit.
This commit is contained in:
@@ -91,7 +91,7 @@ int cal_main(int argc, char **argv)
|
||||
setlocale(LC_TIME, "");
|
||||
#endif
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "jy");
|
||||
flags = getopt32(argc, argv, "jy");
|
||||
|
||||
julian = flags & 1;
|
||||
|
||||
|
@@ -18,7 +18,7 @@ int cat_main(int argc, char **argv)
|
||||
FILE *f;
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
bb_getopt_ulflags(argc, argv, "u");
|
||||
getopt32(argc, argv, "u");
|
||||
|
||||
argv += optind;
|
||||
if (!*argv) {
|
||||
|
@@ -17,7 +17,7 @@ int catv_main(int argc, char **argv)
|
||||
int retval = EXIT_SUCCESS, fd;
|
||||
unsigned long flags;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "etv");
|
||||
flags = getopt32(argc, argv, "etv");
|
||||
#define CATV_OPT_e (1<<0)
|
||||
#define CATV_OPT_t (1<<1)
|
||||
#define CATV_OPT_v (1<<2)
|
||||
|
@@ -31,7 +31,7 @@ int chgrp_main(int argc, char **argv)
|
||||
int recursiveFlag;
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
recursiveFlag = bb_getopt_ulflags(argc, argv, "R");
|
||||
recursiveFlag = getopt32(argc, argv, "R");
|
||||
|
||||
if (argc - optind < 2) {
|
||||
bb_show_usage();
|
||||
|
@@ -43,7 +43,7 @@ int chown_main(int argc, char **argv)
|
||||
int retval = EXIT_SUCCESS;
|
||||
char *groupName;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "Rh");
|
||||
flags = getopt32(argc, argv, "Rh");
|
||||
|
||||
if (flags & FLAG_h) chown_func = lchown;
|
||||
|
||||
|
@@ -54,7 +54,7 @@ int cmp_main(int argc, char **argv)
|
||||
|
||||
xfunc_error_retval = 2; /* 1 is returned if files are different. */
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, opt_chars);
|
||||
opt = getopt32(argc, argv, opt_chars);
|
||||
|
||||
if (((opt & (CMP_OPT_s|CMP_OPT_l)) == (CMP_OPT_s|CMP_OPT_l))
|
||||
|| (((unsigned int)(--argc - optind)) > 1))
|
||||
|
@@ -112,7 +112,7 @@ int comm_main(int argc, char **argv)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "123");
|
||||
flags = getopt32(argc, argv, "123");
|
||||
|
||||
if (optind + 2 != argc)
|
||||
bb_show_usage();
|
||||
|
@@ -39,7 +39,7 @@ int cp_main(int argc, char **argv)
|
||||
int flags;
|
||||
int status = 0;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "pdRfiarPHL");
|
||||
flags = getopt32(argc, argv, "pdRfiarPHL");
|
||||
|
||||
if (flags & 32) {
|
||||
flags |= (FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR | FILEUTILS_DEREFERENCE);
|
||||
|
@@ -12,14 +12,13 @@
|
||||
#include "busybox.h"
|
||||
|
||||
/* option vars */
|
||||
static const char *const optstring = "b:c:f:d:sn";
|
||||
|
||||
static const char optstring[] = "b:c:f:d:sn";
|
||||
#define CUT_OPT_BYTE_FLGS (1<<0)
|
||||
#define CUT_OPT_CHAR_FLGS (1<<1)
|
||||
#define CUT_OPT_FIELDS_FLGS (1<<2)
|
||||
#define CUT_OPT_DELIM_FLGS (1<<3)
|
||||
#define CUT_OPT_SUPPRESS_FLGS (1<<4)
|
||||
static unsigned long opt;
|
||||
static unsigned opt;
|
||||
|
||||
static char delim = '\t'; /* delimiter, default is tab */
|
||||
|
||||
@@ -179,9 +178,8 @@ int cut_main(int argc, char **argv)
|
||||
{
|
||||
char *sopt, *ltok;
|
||||
|
||||
bb_opt_complementally = "b--bcf:c--bcf:f--bcf";
|
||||
opt =
|
||||
bb_getopt_ulflags(argc, argv, optstring, &sopt, &sopt, &sopt, <ok);
|
||||
opt_complementary = "b--bcf:c--bcf:f--bcf";
|
||||
opt = getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, <ok);
|
||||
if (!(opt & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
|
||||
bb_error_msg_and_die
|
||||
("expected a list of bytes, characters, or fields");
|
||||
|
@@ -42,7 +42,7 @@ int date_main(int argc, char **argv)
|
||||
{
|
||||
time_t tm;
|
||||
struct tm tm_time;
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
int ifmt = -1;
|
||||
char *date_str = NULL;
|
||||
char *date_fmt = NULL;
|
||||
@@ -50,9 +50,9 @@ int date_main(int argc, char **argv)
|
||||
char *isofmt_arg;
|
||||
char *hintfmt_arg;
|
||||
|
||||
bb_opt_complementally = "?:d--s:s--d"
|
||||
opt_complementary = "?:d--s:s--d"
|
||||
USE_FEATURE_DATE_ISOFMT(":R--I:I--R");
|
||||
opt = bb_getopt_ulflags(argc, argv, "Rs:ud:r:"
|
||||
opt = getopt32(argc, argv, "Rs:ud:r:"
|
||||
USE_FEATURE_DATE_ISOFMT("I::D:"),
|
||||
&date_str, &date_str, &filename
|
||||
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg));
|
||||
|
@@ -41,7 +41,7 @@ int df_main(int argc, char **argv)
|
||||
unsigned long df_disp_hr = KILOBYTE;
|
||||
#endif
|
||||
int status = EXIT_SUCCESS;
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
FILE *mount_table;
|
||||
struct mntent *mount_entry;
|
||||
struct statfs s;
|
||||
@@ -49,8 +49,8 @@ int df_main(int argc, char **argv)
|
||||
const char *disp_units_hdr = hdr_1k;
|
||||
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
bb_opt_complementally = "h-km:k-hm:m-hk";
|
||||
opt = bb_getopt_ulflags(argc, argv, "hmk");
|
||||
opt_complementary = "h-km:k-hm:m-hk";
|
||||
opt = getopt32(argc, argv, "hmk");
|
||||
if(opt & 1) {
|
||||
df_disp_hr = 0;
|
||||
disp_units_hdr = " Size";
|
||||
@@ -60,7 +60,7 @@ int df_main(int argc, char **argv)
|
||||
disp_units_hdr = "1M-blocks";
|
||||
}
|
||||
#else
|
||||
opt = bb_getopt_ulflags(argc, argv, "k");
|
||||
opt = getopt32(argc, argv, "k");
|
||||
#endif
|
||||
|
||||
bb_printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
|
||||
|
@@ -1164,9 +1164,9 @@ int diff_main(int argc, char **argv)
|
||||
char *U_opt;
|
||||
llist_t *L_arg = NULL;
|
||||
|
||||
bb_opt_complementally = "L::";
|
||||
opt_complementary = "L::";
|
||||
cmd_flags =
|
||||
bb_getopt_ulflags(argc, argv, "abdiL:NqrsS:tTU:wu", &L_arg, &start,
|
||||
getopt32(argc, argv, "abdiL:NqrsS:tTU:wu", &L_arg, &start,
|
||||
&U_opt);
|
||||
|
||||
if (cmd_flags & FLAG_L) {
|
||||
|
@@ -93,11 +93,11 @@ int dos2unix_main(int argc, char *argv[])
|
||||
ConvType = CT_UNIX2DOS; /*1 */
|
||||
}
|
||||
/* -u and -d are mutally exclusive */
|
||||
bb_opt_complementally = "?:u--d:d--u";
|
||||
opt_complementary = "?:u--d:d--u";
|
||||
/* process parameters */
|
||||
/* -u convert to unix */
|
||||
/* -d convert to dos */
|
||||
o = bb_getopt_ulflags(argc, argv, "du");
|
||||
o = getopt32(argc, argv, "du");
|
||||
|
||||
/* Do the conversion requested by an argument else do the default
|
||||
* conversion depending on our name. */
|
||||
|
@@ -153,7 +153,7 @@ int du_main(int argc, char **argv)
|
||||
int slink_depth_save;
|
||||
int print_final_total;
|
||||
char *smax_print_depth;
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
|
||||
#ifdef CONFIG_FEATURE_DU_DEFUALT_BLOCKSIZE_1K
|
||||
if (getenv("POSIXLY_CORRECT")) { /* TODO - a new libbb function? */
|
||||
@@ -172,8 +172,8 @@ int du_main(int argc, char **argv)
|
||||
* ignore -a. This is consistent with -s being equivalent to -d 0.
|
||||
*/
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
bb_opt_complementally = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
|
||||
opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
|
||||
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);
|
||||
if((opt & (1 << 9))) {
|
||||
/* -h opt */
|
||||
disp_hr = 0;
|
||||
@@ -187,8 +187,8 @@ int du_main(int argc, char **argv)
|
||||
disp_hr = KILOBYTE;
|
||||
}
|
||||
#else
|
||||
bb_opt_complementally = "H-L:L-H:s-d:d-s";
|
||||
opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
|
||||
opt_complementary = "H-L:L-H:s-d:d-s";
|
||||
opt = getopt32(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
|
||||
#if !defined CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
|
||||
if((opt & (1 << 2))) {
|
||||
/* -k opt */
|
||||
|
@@ -46,16 +46,16 @@ int env_main(int argc, char** argv)
|
||||
static char *cleanenv[1] = { NULL };
|
||||
|
||||
char **ep;
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
llist_t *unset_env = NULL;
|
||||
extern char **environ;
|
||||
|
||||
bb_opt_complementally = "u::";
|
||||
opt_complementary = "u::";
|
||||
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
|
||||
bb_applet_long_options = env_long_options;
|
||||
applet_long_options = env_long_options;
|
||||
#endif
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "+iu:", &unset_env);
|
||||
opt = getopt32(argc, argv, "+iu:", &unset_env);
|
||||
|
||||
argv += optind;
|
||||
if (*argv && (argv[0][0] == '-') && !argv[0][1]) {
|
||||
|
@@ -60,7 +60,7 @@ int fold_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "bsw:", &w_opt);
|
||||
flags = getopt32(argc, argv, "bsw:", &w_opt);
|
||||
if (flags & FLAG_WIDTH)
|
||||
width = bb_xgetlarg(w_opt, 10, 1, 10000);
|
||||
|
||||
|
@@ -60,7 +60,7 @@ int head_main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* No size benefit in converting this to bb_getopt_ulflags */
|
||||
/* No size benefit in converting this to getopt32 */
|
||||
while ((opt = getopt(argc, argv, head_opts)) > 0) {
|
||||
switch (opt) {
|
||||
#if ENABLE_FEATURE_FANCY_HEAD
|
||||
|
@@ -50,8 +50,8 @@ int id_main(int argc, char **argv)
|
||||
|
||||
/* Don't allow -n -r -nr -ug -rug -nug -rnug */
|
||||
/* Don't allow more than one username */
|
||||
bb_opt_complementally = "?1:?:u--g:g--u:r?ug:n?ug";
|
||||
flags = bb_getopt_ulflags(argc, argv, "rnug");
|
||||
opt_complementary = "?1:?:u--g:g--u:r?ug:n?ug";
|
||||
flags = getopt32(argc, argv, "rnug");
|
||||
|
||||
/* This values could be overwritten later */
|
||||
uid = geteuid();
|
||||
|
@@ -45,11 +45,11 @@ int install_main(int argc, char **argv)
|
||||
int ret = EXIT_SUCCESS, flags, i, isdir;
|
||||
|
||||
#if ENABLE_FEATURE_INSTALL_LONG_OPTIONS
|
||||
bb_applet_long_options = install_long_options;
|
||||
applet_long_options = install_long_options;
|
||||
#endif
|
||||
bb_opt_complementally = "?:s--d:d--s";
|
||||
opt_complementary = "?:s--d:d--s";
|
||||
/* -c exists for backwards compatibility, its needed */
|
||||
flags = bb_getopt_ulflags(argc, argv, "cdpsg:m:o:", &gid_str, &mode_str, &uid_str); /* 'a' must be 2nd */
|
||||
flags = getopt32(argc, argv, "cdpsg:m:o:", &gid_str, &mode_str, &uid_str); /* 'a' must be 2nd */
|
||||
|
||||
/* preserve access and modification time, this is GNU behaviour, BSD only preserves modification time */
|
||||
if (flags & INSTALL_OPT_PRESERVE_TIME) {
|
||||
|
@@ -31,7 +31,7 @@ mode_t getopt_mk_fifo_nod(int argc, char **argv)
|
||||
mode_t mode = 0666;
|
||||
char *smode = NULL;
|
||||
|
||||
bb_getopt_ulflags(argc, argv, "m:", &smode);
|
||||
getopt32(argc, argv, "m:", &smode);
|
||||
if(smode) {
|
||||
if (bb_parse_mode(smode, &mode))
|
||||
umask(0);
|
||||
|
@@ -30,7 +30,7 @@ int ln_main(int argc, char **argv)
|
||||
struct stat statbuf;
|
||||
int (*link_func)(const char *, const char *);
|
||||
|
||||
flag = bb_getopt_ulflags(argc, argv, "sfnbS:", &suffix);
|
||||
flag = getopt32(argc, argv, "sfnbS:", &suffix);
|
||||
|
||||
if (argc == optind) {
|
||||
bb_show_usage();
|
||||
|
@@ -877,7 +877,7 @@ int ls_main(int argc, char **argv)
|
||||
struct dnode **dnp;
|
||||
struct dnode *dn;
|
||||
struct dnode *cur;
|
||||
long opt;
|
||||
unsigned opt;
|
||||
int nfiles = 0;
|
||||
int dnfiles;
|
||||
int dndirs;
|
||||
@@ -904,12 +904,12 @@ int ls_main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FEATURE_LS_COLOR
|
||||
bb_applet_long_options = ls_color_opt;
|
||||
applet_long_options = ls_color_opt;
|
||||
#endif
|
||||
|
||||
/* process options */
|
||||
#ifdef CONFIG_FEATURE_AUTOWIDTH
|
||||
opt = bb_getopt_ulflags(argc, argv, ls_options, &tabstops_str, &terminal_width_str
|
||||
opt = getopt32(argc, argv, ls_options, &tabstops_str, &terminal_width_str
|
||||
#ifdef CONFIG_FEATURE_LS_COLOR
|
||||
, &color_opt
|
||||
#endif
|
||||
@@ -921,7 +921,7 @@ int ls_main(int argc, char **argv)
|
||||
terminal_width = atoi(terminal_width_str);
|
||||
}
|
||||
#else
|
||||
opt = bb_getopt_ulflags(argc, argv, ls_options
|
||||
opt = getopt32(argc, argv, ls_options
|
||||
#ifdef CONFIG_FEATURE_LS_COLOR
|
||||
, &color_opt
|
||||
#endif
|
||||
|
@@ -91,7 +91,7 @@ int md5_sha1_sum_main(int argc, char **argv)
|
||||
: HASH_SHA1;
|
||||
|
||||
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK)
|
||||
flags = bb_getopt_ulflags(argc, argv, "scw");
|
||||
flags = getopt32(argc, argv, "scw");
|
||||
else optind = 1;
|
||||
|
||||
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && !(flags & FLAG_CHECK)) {
|
||||
|
@@ -34,13 +34,13 @@ int mkdir_main (int argc, char **argv)
|
||||
mode_t mode = (mode_t)(-1);
|
||||
int status = EXIT_SUCCESS;
|
||||
int flags = 0;
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
char *smode;
|
||||
|
||||
#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
|
||||
bb_applet_long_options = mkdir_long_options;
|
||||
applet_long_options = mkdir_long_options;
|
||||
#endif
|
||||
opt = bb_getopt_ulflags(argc, argv, "m:p", &smode);
|
||||
opt = getopt32(argc, argv, "m:p", &smode);
|
||||
if(opt & 1) {
|
||||
mode = 0777;
|
||||
if (!bb_parse_mode (smode, &mode)) {
|
||||
|
@@ -45,10 +45,10 @@ int mv_main(int argc, char **argv)
|
||||
int status = 0;
|
||||
|
||||
#if ENABLE_FEATURE_MV_LONG_OPTIONS
|
||||
bb_applet_long_options = mv_long_options;
|
||||
applet_long_options = mv_long_options;
|
||||
#endif
|
||||
bb_opt_complementally = "f-i:i-f";
|
||||
flags = bb_getopt_ulflags(argc, argv, "fi");
|
||||
opt_complementary = "f-i:i-f";
|
||||
flags = getopt32(argc, argv, "fi");
|
||||
if (optind + 2 > argc) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
@@ -22,10 +22,10 @@ int rm_main(int argc, char **argv)
|
||||
{
|
||||
int status = 0;
|
||||
int flags = 0;
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
|
||||
bb_opt_complementally = "f-i:i-f";
|
||||
opt = bb_getopt_ulflags(argc, argv, "fiRr");
|
||||
opt_complementary = "f-i:i-f";
|
||||
opt = getopt32(argc, argv, "fiRr");
|
||||
if(opt & 1)
|
||||
flags |= FILEUTILS_FORCE;
|
||||
if(opt & 2)
|
||||
|
@@ -22,7 +22,7 @@ int rmdir_main(int argc, char **argv)
|
||||
int do_dot;
|
||||
char *path;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "p");
|
||||
flags = getopt32(argc, argv, "p");
|
||||
|
||||
argv += optind;
|
||||
|
||||
|
@@ -516,7 +516,7 @@ int stat_main(int argc, char **argv)
|
||||
int ok = 1;
|
||||
int (*statfunc)(char const *, char const *) = do_stat;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "ftL"
|
||||
flags = getopt32(argc, argv, "ftL"
|
||||
USE_FEATURE_STAT_FORMAT("c:", &format)
|
||||
);
|
||||
|
||||
|
@@ -136,7 +136,7 @@ int sum_main(int argc, char **argv)
|
||||
int (*sum_func)(const char *, int) = bsd_sum_file;
|
||||
|
||||
/* give the bsd func priority over sysv func */
|
||||
flags = bb_getopt_ulflags(argc, argv, "sr");
|
||||
flags = getopt32(argc, argv, "sr");
|
||||
if (flags & 1)
|
||||
sum_func = sysv_sum_file;
|
||||
if (flags & 2)
|
||||
|
@@ -28,7 +28,7 @@ int tee_main(int argc, char **argv)
|
||||
int c;
|
||||
#endif
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "ia"); /* 'a' must be 2nd */
|
||||
flags = getopt32(argc, argv, "ia"); /* 'a' must be 2nd */
|
||||
|
||||
mode += (flags & 2); /* Since 'a' is the 2nd option... */
|
||||
|
||||
|
@@ -32,7 +32,7 @@ int touch_main(int argc, char **argv)
|
||||
int flags;
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "c");
|
||||
flags = getopt32(argc, argv, "c");
|
||||
|
||||
argv += optind;
|
||||
|
||||
|
@@ -23,7 +23,7 @@ int tty_main(int argc, char **argv)
|
||||
|
||||
xfunc_error_retval = 2; /* SUSv3 requires > 1 for error. */
|
||||
|
||||
silent = bb_getopt_ulflags(argc, argv, "s");
|
||||
silent = getopt32(argc, argv, "s");
|
||||
|
||||
/* gnu tty outputs a warning that it is ignoring all args. */
|
||||
bb_warn_ignoring_args(argc - optind);
|
||||
|
@@ -63,7 +63,7 @@ int uname_main(int argc, char **argv)
|
||||
const unsigned short int *delta;
|
||||
char toprint;
|
||||
|
||||
toprint = bb_getopt_ulflags(argc, argv, options);
|
||||
toprint = getopt32(argc, argv, options);
|
||||
|
||||
if (argc != optind) {
|
||||
bb_show_usage();
|
||||
|
@@ -129,7 +129,7 @@ int uudecode_main(int argc, char **argv)
|
||||
char *outname = NULL;
|
||||
char *line;
|
||||
|
||||
bb_getopt_ulflags(argc, argv, "o:", &outname);
|
||||
getopt32(argc, argv, "o:", &outname);
|
||||
|
||||
if (optind == argc) {
|
||||
src_stream = stdin;
|
||||
|
@@ -27,7 +27,7 @@ int uuencode_main(int argc, char **argv)
|
||||
RESERVE_CONFIG_BUFFER(dst_buf, DST_BUF_SIZE + 1);
|
||||
|
||||
tbl = bb_uuenc_tbl_std;
|
||||
if (bb_getopt_ulflags(argc, argv, "m") & 1) {
|
||||
if (getopt32(argc, argv, "m") & 1) {
|
||||
tbl = bb_uuenc_tbl_base64;
|
||||
}
|
||||
|
||||
|
@@ -87,7 +87,7 @@ int wc_main(int argc, char **argv)
|
||||
char in_word;
|
||||
unsigned print_type;
|
||||
|
||||
print_type = bb_getopt_ulflags(argc, argv, "lwcL");
|
||||
print_type = getopt32(argc, argv, "lwcL");
|
||||
|
||||
if (print_type == 0) {
|
||||
print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS);
|
||||
|
Reference in New Issue
Block a user