aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2005-05-11 00:39:03 +0000
committerMike Frysinger <vapier@gentoo.org>2005-05-11 00:39:03 +0000
commit348e84c202c4946d3694f130a6f81f61eb1d4b9e (patch)
tree0f8cea7ac869802aadea4346d73f122041adad5b
parent55e2cf6533582ba0e795176103df0df22436b230 (diff)
downloadbusybox-w32-348e84c202c4946d3694f130a6f81f61eb1d4b9e.tar.gz
busybox-w32-348e84c202c4946d3694f130a6f81f61eb1d4b9e.tar.bz2
busybox-w32-348e84c202c4946d3694f130a6f81f61eb1d4b9e.zip
change the hardcoded error constant (0x80000000UL) to a nice flexible define (BB_GETOPT_ERROR)
-rw-r--r--archival/ar.c2
-rw-r--r--archival/dpkg_deb.c2
-rw-r--r--archival/tar.c2
-rw-r--r--coreutils/cut.c2
-rw-r--r--coreutils/date.c2
-rw-r--r--coreutils/id.c2
-rw-r--r--coreutils/install.c2
-rw-r--r--debianutils/start_stop_daemon.c2
-rw-r--r--include/libbb.h1
-rw-r--r--libbb/getopt_ulflags.c6
-rw-r--r--util-linux/hwclock.c2
11 files changed, 13 insertions, 12 deletions
diff --git a/archival/ar.c b/archival/ar.c
index bbdf2fddc..8326aa6de 100644
--- a/archival/ar.c
+++ b/archival/ar.c
@@ -70,7 +70,7 @@ extern int ar_main(int argc, char **argv)
70 bb_opt_complementaly = "p~tx:t~px:x~pt"; 70 bb_opt_complementaly = "p~tx:t~px:x~pt";
71 opt = bb_getopt_ulflags(argc, argv, "ptxovcr"); 71 opt = bb_getopt_ulflags(argc, argv, "ptxovcr");
72 72
73 if ((opt & 0x80000000UL) || (opt == 0) || (optind == argc)) { 73 if ((opt & BB_GETOPT_ERROR) || (opt == 0) || (optind == argc)) {
74 bb_show_usage(); 74 bb_show_usage();
75 } 75 }
76 76
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index 5aa9881d5..b95ec2d6e 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -88,7 +88,7 @@ extern int dpkg_deb_main(int argc, char **argv)
88 argcount = 2; 88 argcount = 2;
89 } 89 }
90 90
91 if ((optind + argcount != argc) || (opt & 0x80000000UL)) { 91 if ((optind + argcount != argc) || (opt & BB_GETOPT_ERROR)) {
92 bb_show_usage(); 92 bb_show_usage();
93 } 93 }
94 94
diff --git a/archival/tar.c b/archival/tar.c
index 950e21dd3..b2a212397 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -724,7 +724,7 @@ int tar_main(int argc, char **argv)
724 ); 724 );
725 725
726 /* Check one and only one context option was given */ 726 /* Check one and only one context option was given */
727 if(opt & 0x80000000UL) { 727 if(opt & BB_GETOPT_ERROR) {
728 bb_show_usage(); 728 bb_show_usage();
729 } 729 }
730#ifdef CONFIG_FEATURE_TAR_CREATE 730#ifdef CONFIG_FEATURE_TAR_CREATE
diff --git a/coreutils/cut.c b/coreutils/cut.c
index d26e80eee..e5fb5aff7 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -300,7 +300,7 @@ extern int cut_main(int argc, char **argv)
300 part = opt & (OPT_BYTE_FLGS|OPT_CHAR_FLGS|OPT_FIELDS_FLGS); 300 part = opt & (OPT_BYTE_FLGS|OPT_CHAR_FLGS|OPT_FIELDS_FLGS);
301 if(part == 0) 301 if(part == 0)
302 bb_error_msg_and_die("you must specify a list of bytes, characters, or fields"); 302 bb_error_msg_and_die("you must specify a list of bytes, characters, or fields");
303 if(opt & 0x80000000UL) 303 if(opt & BB_GETOPT_ERROR)
304 bb_error_msg_and_die("only one type of list may be specified"); 304 bb_error_msg_and_die("only one type of list may be specified");
305 parse_lists(sopt); 305 parse_lists(sopt);
306 if((opt & (OPT_DELIM_FLGS))) { 306 if((opt & (OPT_DELIM_FLGS))) {
diff --git a/coreutils/date.c b/coreutils/date.c
index 3608df69f..513aadeec 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -166,7 +166,7 @@ int date_main(int argc, char **argv)
166 bb_error_msg_and_die(bb_msg_memory_exhausted); 166 bb_error_msg_and_die(bb_msg_memory_exhausted);
167 } 167 }
168 use_arg = opt & DATE_OPT_DATE; 168 use_arg = opt & DATE_OPT_DATE;
169 if(opt & 0x80000000UL) 169 if(opt & BB_GETOPT_ERROR)
170 bb_show_usage(); 170 bb_show_usage();
171#ifdef CONFIG_FEATURE_DATE_ISOFMT 171#ifdef CONFIG_FEATURE_DATE_ISOFMT
172 if(opt & DATE_OPT_TIMESPEC) { 172 if(opt & DATE_OPT_TIMESPEC) {
diff --git a/coreutils/id.c b/coreutils/id.c
index 541c3d16b..636049168 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -64,7 +64,7 @@ extern int id_main(int argc, char **argv)
64 bb_opt_complementaly = "u~g:g~u"; 64 bb_opt_complementaly = "u~g:g~u";
65 flags = bb_getopt_ulflags(argc, argv, "rnug"); 65 flags = bb_getopt_ulflags(argc, argv, "rnug");
66 66
67 if ((flags & 0x80000000UL) 67 if ((flags & BB_GETOPT_ERROR)
68 /* Don't allow -n -r -nr */ 68 /* Don't allow -n -r -nr */
69 || (flags <= 3 && flags > 0) 69 || (flags <= 3 && flags > 0)
70 /* Don't allow more than one username */ 70 /* Don't allow more than one username */
diff --git a/coreutils/install.c b/coreutils/install.c
index 36dc1d618..345e75af0 100644
--- a/coreutils/install.c
+++ b/coreutils/install.c
@@ -69,7 +69,7 @@ extern int install_main(int argc, char **argv)
69 flags = bb_getopt_ulflags(argc, argv, "cdpsg:m:o:", &gid_str, &mode_str, &uid_str); /* 'a' must be 2nd */ 69 flags = bb_getopt_ulflags(argc, argv, "cdpsg:m:o:", &gid_str, &mode_str, &uid_str); /* 'a' must be 2nd */
70 70
71 /* Check valid options were given */ 71 /* Check valid options were given */
72 if(flags & 0x80000000UL) { 72 if(flags & BB_GETOPT_ERROR) {
73 bb_show_usage(); 73 bb_show_usage();
74 } 74 }
75 75
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index e15944c59..1eaf0d78c 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -238,7 +238,7 @@ start_stop_daemon_main(int argc, char **argv)
238 &startas, &cmdname, &signame, &userspec, &execname, &pidfile); 238 &startas, &cmdname, &signame, &userspec, &execname, &pidfile);
239 239
240 /* Check one and only one context option was given */ 240 /* Check one and only one context option was given */
241 if ((opt & 0x80000000UL) || (opt & (SSD_CTX_STOP | SSD_CTX_START)) == 0) { 241 if ((opt & BB_GETOPT_ERROR) || (opt & (SSD_CTX_STOP | SSD_CTX_START)) == 0) {
242 bb_show_usage(); 242 bb_show_usage();
243 } 243 }
244 244
diff --git a/include/libbb.h b/include/libbb.h
index ac60dd6c2..1aa7b41bd 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -151,6 +151,7 @@ extern FILE *bb_xfopen(const char *path, const char *mode);
151extern int bb_fclose_nonstdin(FILE *f); 151extern int bb_fclose_nonstdin(FILE *f);
152extern void bb_fflush_stdout_and_exit(int retval) __attribute__ ((noreturn)); 152extern void bb_fflush_stdout_and_exit(int retval) __attribute__ ((noreturn));
153 153
154#define BB_GETOPT_ERROR 0x80000000UL
154extern const char *bb_opt_complementaly; 155extern const char *bb_opt_complementaly;
155extern const struct option *bb_applet_long_options; 156extern const struct option *bb_applet_long_options;
156extern unsigned long bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...); 157extern unsigned long bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...);
diff --git a/libbb/getopt_ulflags.c b/libbb/getopt_ulflags.c
index b6a35261d..6197e8d9f 100644
--- a/libbb/getopt_ulflags.c
+++ b/libbb/getopt_ulflags.c
@@ -155,10 +155,10 @@ Special characters:
155 if specified together. In this case you must set 155 if specified together. In this case you must set
156 bb_opt_complementaly = "b~cf:c~bf:f~bc". If two of the 156 bb_opt_complementaly = "b~cf:c~bf:f~bc". If two of the
157 mutually exclusive options are found, bb_getopt_ulflags's 157 mutually exclusive options are found, bb_getopt_ulflags's
158 return value will have the error flag set (0x80000000UL) so 158 return value will have the error flag set (BB_GETOPT_ERROR) so
159 that we can check for it: 159 that we can check for it:
160 160
161 if (flags & 0x80000000UL) 161 if (flags & BB_GETOPT_ERROR)
162 bb_show_usage(); 162 bb_show_usage();
163 163
164 "*" A star after a char in bb_opt_complementaly means that the 164 "*" A star after a char in bb_opt_complementaly means that the
@@ -280,7 +280,7 @@ bb_getopt_ulflags (int argc, char **argv, const char *applet_opts, ...)
280 bb_show_usage (); 280 bb_show_usage ();
281 } 281 }
282 if(flags & on_off->incongruously) 282 if(flags & on_off->incongruously)
283 flags |= 0x80000000UL; 283 flags |= BB_GETOPT_ERROR;
284 flags &= ~on_off->switch_off; 284 flags &= ~on_off->switch_off;
285 flags |= on_off->switch_on; 285 flags |= on_off->switch_on;
286 if(on_off->list_flg) { 286 if(on_off->list_flg) {
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
index 2f6266167..3c2683953 100644
--- a/util-linux/hwclock.c
+++ b/util-linux/hwclock.c
@@ -208,7 +208,7 @@ static const struct option hwclock_long_options[] = {
208 bb_opt_complementaly = "r~ws:w~rs:s~wr:l~u:u~l"; 208 bb_opt_complementaly = "r~ws:w~rs:s~wr:l~u:u~l";
209 opt = bb_getopt_ulflags(argc, argv, "lursw"); 209 opt = bb_getopt_ulflags(argc, argv, "lursw");
210 /* Check only one mode was given */ 210 /* Check only one mode was given */
211 if(opt & 0x80000000UL) { 211 if(opt & BB_GETOPT_ERROR) {
212 bb_show_usage(); 212 bb_show_usage();
213 } 213 }
214 214