aboutsummaryrefslogtreecommitdiff
path: root/util-linux/getopt.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-06-19 12:10:38 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-06-19 12:10:38 +0200
commitf3b92d385695aecefd93d5f199be1f64270c2687 (patch)
tree5d6b2308ceafea6040bd78ea8401a91eb65d376b /util-linux/getopt.c
parente2e4cc249dc1bd4b280846f55a36208674eadd55 (diff)
downloadbusybox-w32-f3b92d385695aecefd93d5f199be1f64270c2687.tar.gz
busybox-w32-f3b92d385695aecefd93d5f199be1f64270c2687.tar.bz2
busybox-w32-f3b92d385695aecefd93d5f199be1f64270c2687.zip
getopt: FEATURE_GETOPT_LONG for -l; rename GETOPT_LONG to LONG_OPTS
Signed-off-by: Colin Watson <cjwatson@ubuntu.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/getopt.c')
-rw-r--r--util-linux/getopt.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/util-linux/getopt.c b/util-linux/getopt.c
index fd6728731..adb96751f 100644
--- a/util-linux/getopt.c
+++ b/util-linux/getopt.c
@@ -38,7 +38,7 @@
38 mode */ 38 mode */
39enum { 39enum {
40 NON_OPT = 1, 40 NON_OPT = 1,
41#if ENABLE_GETOPT_LONG 41#if ENABLE_FEATURE_GETOPT_LONG
42/* LONG_OPT is the code that is returned when a long option is found. */ 42/* LONG_OPT is the code that is returned when a long option is found. */
43 LONG_OPT = 2 43 LONG_OPT = 2
44#endif 44#endif
@@ -53,7 +53,7 @@ enum {
53 OPT_s = 0x10, // -s 53 OPT_s = 0x10, // -s
54 OPT_T = 0x20, // -T 54 OPT_T = 0x20, // -T
55 OPT_u = 0x40, // -u 55 OPT_u = 0x40, // -u
56#if ENABLE_GETOPT_LONG 56#if ENABLE_FEATURE_GETOPT_LONG
57 OPT_a = 0x80, // -a 57 OPT_a = 0x80, // -a
58 OPT_l = 0x100, // -l 58 OPT_l = 0x100, // -l
59#endif 59#endif
@@ -141,7 +141,7 @@ static const char *normalize(const char *arg)
141 * optstr must contain the short options, and longopts the long options. 141 * optstr must contain the short options, and longopts the long options.
142 * Other settings are found in global variables. 142 * Other settings are found in global variables.
143 */ 143 */
144#if !ENABLE_GETOPT_LONG 144#if !ENABLE_FEATURE_GETOPT_LONG
145#define generate_output(argv,argc,optstr,longopts) \ 145#define generate_output(argv,argc,optstr,longopts) \
146 generate_output(argv,argc,optstr) 146 generate_output(argv,argc,optstr)
147#endif 147#endif
@@ -149,7 +149,7 @@ static int generate_output(char **argv, int argc, const char *optstr, const stru
149{ 149{
150 int exit_code = 0; /* We assume everything will be OK */ 150 int exit_code = 0; /* We assume everything will be OK */
151 int opt; 151 int opt;
152#if ENABLE_GETOPT_LONG 152#if ENABLE_FEATURE_GETOPT_LONG
153 int longindex; 153 int longindex;
154#endif 154#endif
155 const char *charptr; 155 const char *charptr;
@@ -168,7 +168,7 @@ static int generate_output(char **argv, int argc, const char *optstr, const stru
168 168
169 while (1) { 169 while (1) {
170 opt = 170 opt =
171#if ENABLE_GETOPT_LONG 171#if ENABLE_FEATURE_GETOPT_LONG
172 alternative ? 172 alternative ?
173 getopt_long_only(argc, argv, optstr, longopts, &longindex) : 173 getopt_long_only(argc, argv, optstr, longopts, &longindex) :
174 getopt_long(argc, argv, optstr, longopts, &longindex); 174 getopt_long(argc, argv, optstr, longopts, &longindex);
@@ -180,7 +180,7 @@ static int generate_output(char **argv, int argc, const char *optstr, const stru
180 if (opt == '?' || opt == ':' ) 180 if (opt == '?' || opt == ':' )
181 exit_code = 1; 181 exit_code = 1;
182 else if (!quiet_output) { 182 else if (!quiet_output) {
183#if ENABLE_GETOPT_LONG 183#if ENABLE_FEATURE_GETOPT_LONG
184 if (opt == LONG_OPT) { 184 if (opt == LONG_OPT) {
185 printf(" --%s", longopts[longindex].name); 185 printf(" --%s", longopts[longindex].name);
186 if (longopts[longindex].has_arg) 186 if (longopts[longindex].has_arg)
@@ -209,7 +209,7 @@ static int generate_output(char **argv, int argc, const char *optstr, const stru
209 return exit_code; 209 return exit_code;
210} 210}
211 211
212#if ENABLE_GETOPT_LONG 212#if ENABLE_FEATURE_GETOPT_LONG
213/* 213/*
214 * Register several long options. options is a string of long options, 214 * Register several long options. options is a string of long options,
215 * separated by commas or whitespace. 215 * separated by commas or whitespace.
@@ -273,7 +273,7 @@ static void set_shell(const char *new_shell)
273 * 4) Returned for -T 273 * 4) Returned for -T
274 */ 274 */
275 275
276#if ENABLE_GETOPT_LONG 276#if ENABLE_FEATURE_GETOPT_LONG
277static const char getopt_longopts[] ALIGN1 = 277static const char getopt_longopts[] ALIGN1 =
278 "options\0" Required_argument "o" 278 "options\0" Required_argument "o"
279 "longoptions\0" Required_argument "l" 279 "longoptions\0" Required_argument "l"
@@ -295,7 +295,7 @@ int getopt_main(int argc, char **argv)
295 unsigned opt; 295 unsigned opt;
296 const char *compatible; 296 const char *compatible;
297 char *s_arg; 297 char *s_arg;
298#if ENABLE_GETOPT_LONG 298#if ENABLE_FEATURE_GETOPT_LONG
299 struct option *long_options = NULL; 299 struct option *long_options = NULL;
300 llist_t *l_arg = NULL; 300 llist_t *l_arg = NULL;
301#endif 301#endif
@@ -321,7 +321,7 @@ int getopt_main(int argc, char **argv)
321 return generate_output(argv+1, argc-1, s, long_options); 321 return generate_output(argv+1, argc-1, s, long_options);
322 } 322 }
323 323
324#if !ENABLE_GETOPT_LONG 324#if !ENABLE_FEATURE_GETOPT_LONG
325 opt = getopt32(argv, "+o:n:qQs:Tu", &optstr, &name, &s_arg); 325 opt = getopt32(argv, "+o:n:qQs:Tu", &optstr, &name, &s_arg);
326#else 326#else
327 applet_long_options = getopt_longopts; 327 applet_long_options = getopt_longopts;