aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-10-03 21:00:06 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-10-03 21:00:06 +0000
commit63adc7384791548741e3a2afbee1be40d99fe9d2 (patch)
treeedb58560b444979051b42ab7f0c0c718f7459754 /libbb
parent1fa12c6ebcb25e2924778bcbaae4bea1af7b7e6a (diff)
downloadbusybox-w32-63adc7384791548741e3a2afbee1be40d99fe9d2.tar.gz
busybox-w32-63adc7384791548741e3a2afbee1be40d99fe9d2.tar.bz2
busybox-w32-63adc7384791548741e3a2afbee1be40d99fe9d2.zip
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. git-svn-id: svn://busybox.net/trunk/busybox@16305 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r--libbb/Makefile.in2
-rw-r--r--libbb/getopt32.c (renamed from libbb/getopt_ulflags.c)145
2 files changed, 72 insertions, 75 deletions
diff --git a/libbb/Makefile.in b/libbb/Makefile.in
index f731e6e03..ef5c6b97a 100644
--- a/libbb/Makefile.in
+++ b/libbb/Makefile.in
@@ -30,7 +30,7 @@ LIBBB-y:= \
30 vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c \ 30 vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c \
31 xgethostbyname.c xgethostbyname2.c xreadlink.c xgetlarg.c \ 31 xgethostbyname.c xgethostbyname2.c xreadlink.c xgetlarg.c \
32 fclose_nonstdin.c fflush_stdout_and_exit.c \ 32 fclose_nonstdin.c fflush_stdout_and_exit.c \
33 getopt_ulflags.c default_error_retval.c wfopen_input.c speed_table.c \ 33 getopt32.c default_error_retval.c wfopen_input.c speed_table.c \
34 perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \ 34 perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \
35 warn_ignoring_args.c concat_subpath_file.c vfork_daemon_rexec.c \ 35 warn_ignoring_args.c concat_subpath_file.c vfork_daemon_rexec.c \
36 bb_do_delay.c 36 bb_do_delay.c
diff --git a/libbb/getopt_ulflags.c b/libbb/getopt32.c
index 9d27c1f11..e08496578 100644
--- a/libbb/getopt_ulflags.c
+++ b/libbb/getopt32.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * universal getopt_ulflags implementation for busybox 3 * universal getopt32 implementation for busybox
4 * 4 *
5 * Copyright (C) 2003-2005 Vladimir Oleynik <dzo@simtreas.ru> 5 * Copyright (C) 2003-2005 Vladimir Oleynik <dzo@simtreas.ru>
6 * 6 *
@@ -12,13 +12,13 @@
12 12
13/* Documentation 13/* Documentation
14 14
15unsigned long 15uint32_t
16bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...) 16getopt32(int argc, char **argv, const char *applet_opts, ...)
17 17
18 The command line options must be declared in const char 18 The command line options must be declared in const char
19 *applet_opts as a string of chars, for example: 19 *applet_opts as a string of chars, for example:
20 20
21 flags = bb_getopt_ulflags(argc, argv, "rnug"); 21 flags = getopt32(argc, argv, "rnug");
22 22
23 If one of the given options is found, a flag value is added to 23 If one of the given options is found, a flag value is added to
24 the return value (an unsigned long). 24 the return value (an unsigned long).
@@ -26,7 +26,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
26 The flag value is determined by the position of the char in 26 The flag value is determined by the position of the char in
27 applet_opts string. For example, in the above case: 27 applet_opts string. For example, in the above case:
28 28
29 flags = bb_getopt_ulflags(argc, argv, "rnug"); 29 flags = getopt32(argc, argv, "rnug");
30 30
31 "r" will add 1 (bit 0) 31 "r" will add 1 (bit 0)
32 "n" will add 2 (bit 1) 32 "n" will add 2 (bit 1)
@@ -52,13 +52,13 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
52 char *pointer_to_arg_for_c; 52 char *pointer_to_arg_for_c;
53 char *pointer_to_arg_for_d; 53 char *pointer_to_arg_for_d;
54 54
55 flags = bb_getopt_ulflags(argc, argv, "a:b:c:d:", 55 flags = getopt32(argc, argv, "a:b:c:d:",
56 &pointer_to_arg_for_a, &pointer_to_arg_for_b, 56 &pointer_to_arg_for_a, &pointer_to_arg_for_b,
57 &pointer_to_arg_for_c, &pointer_to_arg_for_d); 57 &pointer_to_arg_for_c, &pointer_to_arg_for_d);
58 58
59 The type of the pointer (char* or llist_t*) may be controlled 59 The type of the pointer (char* or llist_t*) may be controlled
60 by the "::" special separator that is set in the external string 60 by the "::" special separator that is set in the external string
61 bb_opt_complementally (see below for more info). 61 opt_complementary (see below for more info).
62 62
63 "::" If option can have an *optional* argument, then add a "::" 63 "::" If option can have an *optional* argument, then add a "::"
64 after its char in applet_opts and provide a pointer to store 64 after its char in applet_opts and provide a pointer to store
@@ -72,7 +72,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
72 env -i ls -d / 72 env -i ls -d /
73 Here we want env to process just the '-i', not the '-d'. 73 Here we want env to process just the '-i', not the '-d'.
74 74
75const struct option *bb_applet_long_options 75const struct option *applet_long_options
76 76
77 This struct allows you to define long options. The syntax for 77 This struct allows you to define long options. The syntax for
78 declaring the array is just like that of getopt's longopts. 78 declaring the array is just like that of getopt's longopts.
@@ -83,23 +83,20 @@ const struct option *bb_applet_long_options
83 { "verbose", 0, 0, 'v' }, 83 { "verbose", 0, 0, 'v' },
84 { 0, 0, 0, 0 } 84 { 0, 0, 0, 0 }
85 }; 85 };
86 bb_applet_long_options = applet_long_options; 86 applet_long_options = applet_long_options;
87 87
88 The last member of struct option (val) typically is set to 88 The last member of struct option (val) typically is set to
89 matching short option from applet_opts. If there is no matching 89 matching short option from applet_opts. If there is no matching
90 char in applet_opts, then: 90 char in applet_opts, then:
91 - return bit have next position after short options 91 - return bit have next position after short options
92 - if has_arg is not "no_argument", use ptr for arg also 92 - if has_arg is not "no_argument", use ptr for arg also
93 - bb_opt_complementally affects it too 93 - opt_complementary affects it too
94 94
95 Note: a good applet will make long options configurable via the 95 Note: a good applet will make long options configurable via the
96 config process and not a required feature. The current standard 96 config process and not a required feature. The current standard
97 is to name the config option CONFIG_FEATURE_<applet>_LONG_OPTIONS. 97 is to name the config option CONFIG_FEATURE_<applet>_LONG_OPTIONS.
98 98
99const char *bb_opt_complementally 99const char *opt_complementary
100
101 this should be bb_opt_complementary, but we'll just keep it as
102 bb_opt_complementally due to the Russian origins
103 100
104 ":" The colon (":") is used to separate groups of two or more chars 101 ":" The colon (":") is used to separate groups of two or more chars
105 and/or groups of chars and special characters (stating some 102 and/or groups of chars and special characters (stating some
@@ -110,11 +107,11 @@ const char *bb_opt_complementally
110 Their flags will be turned on if the main option is found even 107 Their flags will be turned on if the main option is found even
111 if they are not specifed on the command line. For example: 108 if they are not specifed on the command line. For example:
112 109
113 bb_opt_complementally = "abc"; 110 opt_complementary = "abc";
114 flags = bb_getopt_ulflags(argc, argv, "abcd") 111 flags = getopt32(argc, argv, "abcd")
115 112
116 If getopt() finds "-a" on the command line, then 113 If getopt() finds "-a" on the command line, then
117 bb_getopt_ulflags's return value will be as if "-a -b -c" were 114 getopt32's return value will be as if "-a -b -c" were
118 found. 115 found.
119 116
120 "ww" Adjacent double options have a counter associated which indicates 117 "ww" Adjacent double options have a counter associated which indicates
@@ -124,15 +121,15 @@ const char *bb_opt_complementally
124 if w is given more than once, it is "unlimited" 121 if w is given more than once, it is "unlimited"
125 122
126 int w_counter = 0; 123 int w_counter = 0;
127 bb_opt_complementally = "ww"; 124 opt_complementary = "ww";
128 bb_getopt_ulflags(argc, argv, "w", &w_counter); 125 getopt32(argc, argv, "w", &w_counter);
129 if (w_counter) 126 if (w_counter)
130 width = (w_counter == 1) ? 132 : INT_MAX; 127 width = (w_counter == 1) ? 132 : INT_MAX;
131 else 128 else
132 get_terminal_width(...&width...); 129 get_terminal_width(...&width...);
133 130
134 w_counter is a pointer to an integer. It has to be passed to 131 w_counter is a pointer to an integer. It has to be passed to
135 bb_getopt_ulflags() after all other option argument sinks. 132 getopt32() after all other option argument sinks.
136 133
137 For example: accept multiple -v to indicate the level of verbosity 134 For example: accept multiple -v to indicate the level of verbosity
138 and for each -b optarg, add optarg to my_b. Finally, if b is given, 135 and for each -b optarg, add optarg to my_b. Finally, if b is given,
@@ -140,8 +137,8 @@ const char *bb_opt_complementally
140 137
141 llist_t *my_b = NULL; 138 llist_t *my_b = NULL;
142 int verbose_level = 0; 139 int verbose_level = 0;
143 bb_opt_complementally = "vv:b::b-c:c-b"; 140 opt_complementary = "vv:b::b-c:c-b";
144 f = bb_getopt_ulflags(argc, argv, "vb:c", &my_b, &verbose_level); 141 f = getopt32(argc, argv, "vb:c", &my_b, &verbose_level);
145 if (f & 2) // -c after -b unsets -b flag 142 if (f & 2) // -c after -b unsets -b flag
146 while (my_b) { dosomething_with(my_b->data); my_b = my_b->link; } 143 while (my_b) { dosomething_with(my_b->data); my_b = my_b->link; }
147 if (my_b) // but llist is stored if -b is specified 144 if (my_b) // but llist is stored if -b is specified
@@ -157,37 +154,37 @@ Special characters:
157 154
158 For example: 155 For example:
159 The du applet has the options "-s" and "-d depth". If 156 The du applet has the options "-s" and "-d depth". If
160 bb_getopt_ulflags finds -s, then -d is unset or if it finds -d 157 getopt32 finds -s, then -d is unset or if it finds -d
161 then -s is unset. (Note: busybox implements the GNU 158 then -s is unset. (Note: busybox implements the GNU
162 "--max-depth" option as "-d".) To obtain this behavior, you 159 "--max-depth" option as "-d".) To obtain this behavior, you
163 set bb_opt_complementally = "s-d:d-s". Only one flag value is 160 set opt_complementary = "s-d:d-s". Only one flag value is
164 added to bb_getopt_ulflags's return value depending on the 161 added to getopt32's return value depending on the
165 position of the options on the command line. If one of the 162 position of the options on the command line. If one of the
166 two options requires an argument pointer (":" in applet_opts 163 two options requires an argument pointer (":" in applet_opts
167 as in "d:") optarg is set accordingly. 164 as in "d:") optarg is set accordingly.
168 165
169 char *smax_print_depth; 166 char *smax_print_depth;
170 167
171 bb_opt_complementally = "s-d:d-s:x-x"; 168 opt_complementary = "s-d:d-s:x-x";
172 opt = bb_getopt_ulflags(argc, argv, "sd:x", &smax_print_depth); 169 opt = getopt32(argc, argv, "sd:x", &smax_print_depth);
173 170
174 if (opt & 2) 171 if (opt & 2)
175 max_print_depth = atoi(smax_print_depth); 172 max_print_depth = atoi(smax_print_depth);
176 if (opt & 4) 173 if (opt & 4)
177 printf("Detected odd -x usage\n"); 174 printf("Detected odd -x usage\n");
178 175
179 "-" A dash as the first char in a bb_opt_complementally group forces 176 "-" A dash as the first char in a opt_complementary group forces
180 all arguments to be treated as options, even if they have 177 all arguments to be treated as options, even if they have
181 no leading dashes. Next char in this case can't be a digit (0-9), 178 no leading dashes. Next char in this case can't be a digit (0-9),
182 use ':' or end of line. For example: 179 use ':' or end of line. For example:
183 180
184 bb_opt_complementally = "-:w-x:x-w"; 181 opt_complementary = "-:w-x:x-w";
185 bb_getopt_ulflags(argc, argv, "wx"); 182 getopt32(argc, argv, "wx");
186 183
187 Allows any arguments to be given without a dash (./program w x) 184 Allows any arguments to be given without a dash (./program w x)
188 as well as with a dash (./program -x). 185 as well as with a dash (./program -x).
189 186
190 "-N" A dash as the first char in a bb_opt_complementally group followed 187 "-N" A dash as the first char in a opt_complementary group followed
191 by a single digit (0-9) means that at least N non-option 188 by a single digit (0-9) means that at least N non-option
192 arguments must be present on the command line 189 arguments must be present on the command line
193 190
@@ -205,8 +202,8 @@ Special characters:
205 The cut applet must have only one type of list specified, so 202 The cut applet must have only one type of list specified, so
206 -b, -c and -f are mutally exclusive and should raise an error 203 -b, -c and -f are mutally exclusive and should raise an error
207 if specified together. In this case you must set 204 if specified together. In this case you must set
208 bb_opt_complementally = "b--cf:c--bf:f--bc". If two of the 205 opt_complementary = "b--cf:c--bf:f--bc". If two of the
209 mutually exclusive options are found, bb_getopt_ulflags's 206 mutually exclusive options are found, getopt32's
210 return value will have the error flag set (BB_GETOPT_ERROR) so 207 return value will have the error flag set (BB_GETOPT_ERROR) so
211 that we can check for it: 208 that we can check for it:
212 209
@@ -216,35 +213,35 @@ Special characters:
216 "x--x" Variation of the above, it means that -x option should occur 213 "x--x" Variation of the above, it means that -x option should occur
217 at most once. 214 at most once.
218 215
219 "?" A "?" as the first char in a bb_opt_complementally group means: 216 "?" A "?" as the first char in a opt_complementary group means:
220 if BB_GETOPT_ERROR is detected, don't return, call bb_show_usage 217 if BB_GETOPT_ERROR is detected, don't return, call bb_show_usage
221 and exit instead. Next char after '?' can't be a digit. 218 and exit instead. Next char after '?' can't be a digit.
222 219
223 "?N" A "?" as the first char in a bb_opt_complementally group followed 220 "?N" A "?" as the first char in a opt_complementary group followed
224 by a single digit (0-9) means that at most N arguments must be present 221 by a single digit (0-9) means that at most N arguments must be present
225 on the command line. 222 on the command line.
226 223
227 "::" A double colon after a char in bb_opt_complementally means that the 224 "::" A double colon after a char in opt_complementary means that the
228 option can occur multiple times. Each occurrence will be saved as 225 option can occur multiple times. Each occurrence will be saved as
229 a llist_t element instead of char*. 226 a llist_t element instead of char*.
230 227
231 For example: 228 For example:
232 The grep applet can have one or more "-e pattern" arguments. 229 The grep applet can have one or more "-e pattern" arguments.
233 In this case you should use bb_getopt_ulflags() as follows: 230 In this case you should use getopt32() as follows:
234 231
235 llist_t *patterns = NULL; 232 llist_t *patterns = NULL;
236 233
237 (this pointer must be initializated to NULL if the list is empty 234 (this pointer must be initializated to NULL if the list is empty
238 as required by *llist_add_to(llist_t *old_head, char *new_item).) 235 as required by *llist_add_to(llist_t *old_head, char *new_item).)
239 236
240 bb_opt_complementally = "e::"; 237 opt_complementary = "e::";
241 238
242 bb_getopt_ulflags(argc, argv, "e:", &patterns); 239 getopt32(argc, argv, "e:", &patterns);
243 $ grep -e user -e root /etc/passwd 240 $ grep -e user -e root /etc/passwd
244 root:x:0:0:root:/root:/bin/bash 241 root:x:0:0:root:/root:/bin/bash
245 user:x:500:500::/home/user:/bin/bash 242 user:x:500:500::/home/user:/bin/bash
246 243
247 "--" A double dash at the beginning of bb_opt_complementally means the 244 "--" A double dash at the beginning of opt_complementary means the
248 argv[1] string should always be treated as options, even if it isn't 245 argv[1] string should always be treated as options, even if it isn't
249 prefixed with a "-". This is useful for special syntax in applets 246 prefixed with a "-". This is useful for special syntax in applets
250 such as "ar" and "tar": 247 such as "ar" and "tar":
@@ -257,20 +254,20 @@ Special characters:
257 For example from "id" applet: 254 For example from "id" applet:
258 255
259 // Don't allow -n -r -rn -ug -rug -nug -rnug 256 // Don't allow -n -r -rn -ug -rug -nug -rnug
260 bb_opt_complementally = "r?ug:n?ug:?u--g:g--u"; 257 opt_complementary = "r?ug:n?ug:?u--g:g--u";
261 flags = bb_getopt_ulflags(argc, argv, "rnug"); 258 flags = getopt32(argc, argv, "rnug");
262 259
263 This example allowed only: 260 This example allowed only:
264 $ id; id -u; id -g; id -ru; id -nu; id -rg; id -ng; id -rnu; id -rng 261 $ id; id -u; id -g; id -ru; id -nu; id -rg; id -ng; id -rnu; id -rng
265 262
266 "X" A bb_opt_complementally group with just a single letter means 263 "X" A opt_complementary group with just a single letter means
267 that this option is required. If more than one such group exists, 264 that this option is required. If more than one such group exists,
268 at least one option is required to occur (not all of them). 265 at least one option is required to occur (not all of them).
269 For example from "start-stop-daemon" applet: 266 For example from "start-stop-daemon" applet:
270 267
271 // Don't allow -KS -SK, but -S or -K is required 268 // Don't allow -KS -SK, but -S or -K is required
272 bb_opt_complementally = "K:S:?K--S:S--K"; 269 opt_complementary = "K:S:?K--S:S--K";
273 flags = bb_getopt_ulflags(argc, argv, "KS...); 270 flags = getopt32(argc, argv, "KS...);
274 271
275 272
276 Don't forget to use ':'. For example, "?322-22-23X-x-a" 273 Don't forget to use ':'. For example, "?322-22-23X-x-a"
@@ -280,45 +277,45 @@ Special characters:
280 a '-2' and after it a '-x' then error out. 277 a '-2' and after it a '-x' then error out.
281*/ 278*/
282 279
283/* this should be bb_opt_complementary, but we'll just keep it as 280/* Code here assumes that 'unsigned' is at least 32 bits wide */
284 bb_opt_complementally due to the Russian origins */ 281
285const char *bb_opt_complementally; 282const char *opt_complementary;
286 283
287typedef struct { 284typedef struct {
288 int opt; 285 int opt;
289 int list_flg; 286 int list_flg;
290 unsigned long switch_on; 287 unsigned switch_on;
291 unsigned long switch_off; 288 unsigned switch_off;
292 unsigned long incongruously; 289 unsigned incongruously;
293 unsigned long requires; 290 unsigned requires;
294 void **optarg; /* char **optarg or llist_t **optarg */ 291 void **optarg; /* char **optarg or llist_t **optarg */
295 int *counter; 292 int *counter;
296} t_complementally; 293} t_complementary;
297 294
298/* You can set bb_applet_long_options for parse called long options */ 295/* You can set applet_long_options for parse called long options */
299#if ENABLE_GETOPT_LONG 296#if ENABLE_GETOPT_LONG
300static const struct option bb_default_long_options[] = { 297static const struct option bb_default_long_options[] = {
301/* { "help", 0, NULL, '?' }, */ 298/* { "help", 0, NULL, '?' }, */
302 { 0, 0, 0, 0 } 299 { 0, 0, 0, 0 }
303}; 300};
304 301
305const struct option *bb_applet_long_options = bb_default_long_options; 302const struct option *applet_long_options = bb_default_long_options;
306#endif 303#endif
307 304
308unsigned long 305uint32_t
309bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...) 306getopt32(int argc, char **argv, const char *applet_opts, ...)
310{ 307{
311 unsigned long flags = 0; 308 unsigned flags = 0;
312 unsigned long requires = 0; 309 unsigned requires = 0;
313 t_complementally complementally[sizeof(flags) * 8 + 1]; 310 t_complementary complementary[sizeof(flags) * 8 + 1];
314 int c; 311 int c;
315 const unsigned char *s; 312 const unsigned char *s;
316 t_complementally *on_off; 313 t_complementary *on_off;
317 va_list p; 314 va_list p;
318#if ENABLE_GETOPT_LONG 315#if ENABLE_GETOPT_LONG
319 const struct option *l_o; 316 const struct option *l_o;
320#endif 317#endif
321 unsigned long trigger; 318 unsigned trigger;
322 char **pargv = NULL; 319 char **pargv = NULL;
323 int min_arg = 0; 320 int min_arg = 0;
324 int max_arg = -1; 321 int max_arg = -1;
@@ -332,8 +329,8 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
332 va_start(p, applet_opts); 329 va_start(p, applet_opts);
333 330
334 c = 0; 331 c = 0;
335 on_off = complementally; 332 on_off = complementary;
336 memset(on_off, 0, sizeof(complementally)); 333 memset(on_off, 0, sizeof(complementary));
337 334
338 /* skip GNU extension */ 335 /* skip GNU extension */
339 s = (const unsigned char *)applet_opts; 336 s = (const unsigned char *)applet_opts;
@@ -355,10 +352,10 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
355 } 352 }
356 353
357#if ENABLE_GETOPT_LONG 354#if ENABLE_GETOPT_LONG
358 for (l_o = bb_applet_long_options; l_o->name; l_o++) { 355 for (l_o = applet_long_options; l_o->name; l_o++) {
359 if (l_o->flag) 356 if (l_o->flag)
360 continue; 357 continue;
361 for (on_off = complementally; on_off->opt != 0; on_off++) 358 for (on_off = complementary; on_off->opt != 0; on_off++)
362 if (on_off->opt == l_o->val) 359 if (on_off->opt == l_o->val)
363 break; 360 break;
364 if (on_off->opt == 0) { 361 if (on_off->opt == 0) {
@@ -372,9 +369,9 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
372 } 369 }
373 } 370 }
374#endif /* ENABLE_GETOPT_LONG */ 371#endif /* ENABLE_GETOPT_LONG */
375 for (s = (const unsigned char *)bb_opt_complementally; s && *s; s++) { 372 for (s = (const unsigned char *)opt_complementary; s && *s; s++) {
376 t_complementally *pair; 373 t_complementary *pair;
377 unsigned long *pair_switch; 374 unsigned *pair_switch;
378 375
379 if (*s == ':') 376 if (*s == ':')
380 continue; 377 continue;
@@ -401,7 +398,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
401 } 398 }
402 continue; 399 continue;
403 } 400 }
404 for (on_off = complementally; on_off->opt; on_off++) 401 for (on_off = complementary; on_off->opt; on_off++)
405 if (on_off->opt == *s) 402 if (on_off->opt == *s)
406 break; 403 break;
407 if (c == ':' && s[2] == ':') { 404 if (c == ':' && s[2] == ':') {
@@ -433,7 +430,7 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
433 else 430 else
434 pair_switch = &(pair->switch_off); 431 pair_switch = &(pair->switch_off);
435 } else { 432 } else {
436 for (on_off = complementally; on_off->opt; on_off++) 433 for (on_off = complementary; on_off->opt; on_off++)
437 if (on_off->opt == *s) { 434 if (on_off->opt == *s) {
438 *pair_switch |= on_off->switch_on; 435 *pair_switch |= on_off->switch_on;
439 break; 436 break;
@@ -455,12 +452,12 @@ bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...)
455#endif 452#endif
456#if ENABLE_GETOPT_LONG 453#if ENABLE_GETOPT_LONG
457 while ((c = getopt_long(argc, argv, applet_opts, 454 while ((c = getopt_long(argc, argv, applet_opts,
458 bb_applet_long_options, NULL)) >= 0) { 455 applet_long_options, NULL)) >= 0) {
459#else 456#else
460 while ((c = getopt(argc, argv, applet_opts)) >= 0) { 457 while ((c = getopt(argc, argv, applet_opts)) >= 0) {
461#endif /* ENABLE_GETOPT_LONG */ 458#endif /* ENABLE_GETOPT_LONG */
462loop_arg_is_opt: 459loop_arg_is_opt:
463 for (on_off = complementally; on_off->opt != c; on_off++) { 460 for (on_off = complementary; on_off->opt != c; on_off++) {
464 /* c==0 if long opt have non NULL flag */ 461 /* c==0 if long opt have non NULL flag */
465 if (on_off->opt == 0 && c != 0) 462 if (on_off->opt == 0 && c != 0)
466 bb_show_usage(); 463 bb_show_usage();
@@ -505,7 +502,7 @@ loop_arg_is_opt:
505 free(argv[1]); 502 free(argv[1]);
506#endif 503#endif
507 /* check depending requires for given options */ 504 /* check depending requires for given options */
508 for (on_off = complementally; on_off->opt; on_off++) { 505 for (on_off = complementary; on_off->opt; on_off++) {
509 if (on_off->requires && (flags & on_off->switch_on) && 506 if (on_off->requires && (flags & on_off->switch_on) &&
510 (flags & on_off->requires) == 0) 507 (flags & on_off->requires) == 0)
511 bb_show_usage(); 508 bb_show_usage();