diff options
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/Config.in | 9 | ||||
-rw-r--r-- | util-linux/getopt.c | 20 | ||||
-rw-r--r-- | util-linux/rtcwake.c | 2 | ||||
-rw-r--r-- | util-linux/script.c | 2 |
4 files changed, 20 insertions, 13 deletions
diff --git a/util-linux/Config.in b/util-linux/Config.in index 024550172..bfd51bc7b 100644 --- a/util-linux/Config.in +++ b/util-linux/Config.in | |||
@@ -250,6 +250,13 @@ config GETOPT | |||
250 | written by others, this utility may be for you. Most people will | 250 | written by others, this utility may be for you. Most people will |
251 | wisely leave this disabled. | 251 | wisely leave this disabled. |
252 | 252 | ||
253 | config FEATURE_GETOPT_LONG | ||
254 | bool "Support option -l" | ||
255 | default y if LONG_OPTS | ||
256 | help | ||
257 | Enable support for recognising long options using the -l option to | ||
258 | getopt. | ||
259 | |||
253 | config HEXDUMP | 260 | config HEXDUMP |
254 | bool "hexdump" | 261 | bool "hexdump" |
255 | default n | 262 | default n |
@@ -286,7 +293,7 @@ config HWCLOCK | |||
286 | config FEATURE_HWCLOCK_LONG_OPTIONS | 293 | config FEATURE_HWCLOCK_LONG_OPTIONS |
287 | bool "Support long options (--hctosys,...)" | 294 | bool "Support long options (--hctosys,...)" |
288 | default n | 295 | default n |
289 | depends on HWCLOCK && GETOPT_LONG | 296 | depends on HWCLOCK && LONG_OPTS |
290 | help | 297 | help |
291 | By default, the hwclock utility only uses short options. If you | 298 | By default, the hwclock utility only uses short options. If you |
292 | are overly fond of its long options, such as --hctosys, --utc, etc) | 299 | are overly fond of its long options, such as --hctosys, --utc, etc) |
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 */ |
39 | enum { | 39 | enum { |
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 |
277 | static const char getopt_longopts[] ALIGN1 = | 277 | static 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; |
diff --git a/util-linux/rtcwake.c b/util-linux/rtcwake.c index 9a73ba29c..278acf347 100644 --- a/util-linux/rtcwake.c +++ b/util-linux/rtcwake.c | |||
@@ -114,7 +114,7 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv) | |||
114 | int utc = -1; | 114 | int utc = -1; |
115 | int fd; | 115 | int fd; |
116 | 116 | ||
117 | #if ENABLE_GETOPT_LONG | 117 | #if ENABLE_LONG_OPTS |
118 | static const char rtcwake_longopts[] ALIGN1 = | 118 | static const char rtcwake_longopts[] ALIGN1 = |
119 | "auto\0" No_argument "a" | 119 | "auto\0" No_argument "a" |
120 | "local\0" No_argument "l" | 120 | "local\0" No_argument "l" |
diff --git a/util-linux/script.c b/util-linux/script.c index 2e2be33e7..d9a62fbfe 100644 --- a/util-linux/script.c +++ b/util-linux/script.c | |||
@@ -36,7 +36,7 @@ int script_main(int argc UNUSED_PARAM, char **argv) | |||
36 | OPT_t = (1 << 4), | 36 | OPT_t = (1 << 4), |
37 | }; | 37 | }; |
38 | 38 | ||
39 | #if ENABLE_GETOPT_LONG | 39 | #if ENABLE_LONG_OPTS |
40 | static const char getopt_longopts[] ALIGN1 = | 40 | static const char getopt_longopts[] ALIGN1 = |
41 | "append\0" No_argument "a" | 41 | "append\0" No_argument "a" |
42 | "command\0" Required_argument "c" | 42 | "command\0" Required_argument "c" |