aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-11-29 11:09:43 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-11-29 11:09:43 +0000
commit28c6254d02ad9e9b1c70cf8b0bbe8fc47eefafbe (patch)
tree6af2895da70dda926317fac31cd4db6a4b20200c
parent182a8119063f6a02109783c28513dc7674ba5be7 (diff)
downloadbusybox-w32-28c6254d02ad9e9b1c70cf8b0bbe8fc47eefafbe.tar.gz
busybox-w32-28c6254d02ad9e9b1c70cf8b0bbe8fc47eefafbe.tar.bz2
busybox-w32-28c6254d02ad9e9b1c70cf8b0bbe8fc47eefafbe.zip
fix support for globally disabling --long-options.
(disabling them saves ~4K on fully configured bbox) git-svn-id: svn://busybox.net/trunk/busybox@16715 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--Config.in10
-rw-r--r--archival/tar.c7
-rw-r--r--coreutils/ls.c4
-rw-r--r--coreutils/od_bloaty.c14
-rw-r--r--include/libbb.h4
-rw-r--r--networking/ftpgetput.c20
-rw-r--r--networking/ipcalc.c27
-rw-r--r--networking/udhcp/dhcpc.c5
-rw-r--r--scripts/kconfig/zconf.tab.c_shipped2
-rw-r--r--scripts/kconfig/zconf.y2
10 files changed, 54 insertions, 41 deletions
diff --git a/Config.in b/Config.in
index 7e20e162b..5e70a523a 100644
--- a/Config.in
+++ b/Config.in
@@ -112,13 +112,11 @@ config LOCALE_SUPPORT
112 busybox to support locale settings. 112 busybox to support locale settings.
113 113
114config GETOPT_LONG 114config GETOPT_LONG
115 bool 115 bool "Enable support for --long-options"
116 default y 116 default y
117# bool "Enable support for --long-options" 117 help
118# default n 118 Enable this if you want busybox applets to use the gnu --long-option
119# help 119 style, in addition to single character -a -b -c style options.
120# Enable this if you want busybox applets to use the gnu --long-option
121# style, in addition to single character -a -b -c style options.
122 120
123config FEATURE_DEVPTS 121config FEATURE_DEVPTS
124 bool "Use the devpts filesystem for Unix98 PTYs" 122 bool "Use the devpts filesystem for Unix98 PTYs"
diff --git a/archival/tar.c b/archival/tar.c
index ca6c1696e..6a4c4e7e8 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -721,8 +721,6 @@ static const struct option tar_long_options[] = {
721# endif 721# endif
722 { 0, 0, 0, 0 } 722 { 0, 0, 0, 0 }
723}; 723};
724#else
725#define tar_long_options 0
726#endif 724#endif
727 725
728int tar_main(int argc, char **argv) 726int tar_main(int argc, char **argv)
@@ -750,8 +748,9 @@ int tar_main(int argc, char **argv)
750 USE_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd 748 USE_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd
751 USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive 749 USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
752 SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive 750 SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive
753 if (ENABLE_FEATURE_TAR_LONG_OPTIONS) 751#if ENABLE_FEATURE_TAR_LONG_OPTIONS
754 applet_long_options = tar_long_options; 752 applet_long_options = tar_long_options;
753#endif
755 opt = getopt32(argc, argv, 754 opt = getopt32(argc, argv,
756 "txC:f:Opvk" 755 "txC:f:Opvk"
757 USE_FEATURE_TAR_CREATE( "ch" ) 756 USE_FEATURE_TAR_CREATE( "ch" )
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 79e47ee6b..960c161b0 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -648,10 +648,12 @@ static int list_single(struct dnode *dn)
648#endif 648#endif
649 case LIST_FILENAME: 649 case LIST_FILENAME:
650 errno = 0; 650 errno = 0;
651#if ENABLE_FEATURE_LS_COLOR
651 if (show_color && !lstat(dn->fullname, &info)) { 652 if (show_color && !lstat(dn->fullname, &info)) {
652 printf("\033[%d;%dm", bgcolor(info.st_mode), 653 printf("\033[%d;%dm", bgcolor(info.st_mode),
653 fgcolor(info.st_mode)); 654 fgcolor(info.st_mode));
654 } 655 }
656#endif
655 column += printf("%s", dn->name); 657 column += printf("%s", dn->name);
656 if (show_color) { 658 if (show_color) {
657 printf("\033[0m"); 659 printf("\033[0m");
@@ -667,11 +669,13 @@ static int list_single(struct dnode *dn)
667 append = append_char(info.st_mode); 669 append = append_char(info.st_mode);
668 } 670 }
669#endif 671#endif
672#if ENABLE_FEATURE_LS_COLOR
670 if (show_color) { 673 if (show_color) {
671 errno = 0; 674 errno = 0;
672 printf("\033[%d;%dm", bgcolor(info.st_mode), 675 printf("\033[%d;%dm", bgcolor(info.st_mode),
673 fgcolor(info.st_mode)); 676 fgcolor(info.st_mode));
674 } 677 }
678#endif
675 column += printf("%s", lpath) + 4; 679 column += printf("%s", lpath) + 4;
676 if (show_color) { 680 if (show_color) {
677 printf("\033[0m"); 681 printf("\033[0m");
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index dff7e3f50..b818521e4 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -858,6 +858,8 @@ format_address_std(off_t address, char c)
858 printf(address_fmt, address_pad_len, address); 858 printf(address_fmt, address_pad_len, address);
859} 859}
860 860
861#if ENABLE_GETOPT_LONG
862/* only used with --traditional */
861static void 863static void
862format_address_paren(off_t address, char c) 864format_address_paren(off_t address, char c)
863{ 865{
@@ -872,7 +874,7 @@ format_address_label(off_t address, char c)
872 format_address_std(address, ' '); 874 format_address_std(address, ' ');
873 format_address_paren(address + pseudo_offset, c); 875 format_address_paren(address + pseudo_offset, c);
874} 876}
875 877#endif
876 878
877static void 879static void
878dump_hexl_mode_trailer(size_t n_bytes, const char *block) 880dump_hexl_mode_trailer(size_t n_bytes, const char *block)
@@ -978,6 +980,7 @@ get_lcm(void)
978 return l_c_m; 980 return l_c_m;
979} 981}
980 982
983#if ENABLE_GETOPT_LONG
981/* If S is a valid traditional offset specification with an optional 984/* If S is a valid traditional offset specification with an optional
982 leading '+' return nonzero and set *OFFSET to the offset it denotes. */ 985 leading '+' return nonzero and set *OFFSET to the offset it denotes. */
983 986
@@ -1011,6 +1014,7 @@ parse_old_offset(const char *s, off_t *offset)
1011 1014
1012 return (*offset >= 0); 1015 return (*offset >= 0);
1013} 1016}
1017#endif
1014 1018
1015/* Read a chunk of size BYTES_PER_BLOCK from the input files, write the 1019/* Read a chunk of size BYTES_PER_BLOCK from the input files, write the
1016 formatted block to standard output, and repeat until the specified 1020 formatted block to standard output, and repeat until the specified
@@ -1235,8 +1239,9 @@ od_main(int argc, char **argv)
1235 OPT_s = 1 << 15, 1239 OPT_s = 1 << 15,
1236 OPT_S = 1 << 16, 1240 OPT_S = 1 << 16,
1237 OPT_w = 1 << 17, 1241 OPT_w = 1 << 17,
1238 OPT_traditional = 1 << 18, 1242 OPT_traditional = (1 << 18) * ENABLE_GETOPT_LONG,
1239 }; 1243 };
1244#if ENABLE_GETOPT_LONG
1240 static const struct option long_options[] = { 1245 static const struct option long_options[] = {
1241 { "skip-bytes", required_argument, NULL, 'j' }, 1246 { "skip-bytes", required_argument, NULL, 'j' },
1242 { "address-radix", required_argument, NULL, 'A' }, 1247 { "address-radix", required_argument, NULL, 'A' },
@@ -1248,6 +1253,7 @@ od_main(int argc, char **argv)
1248 { "traditional", no_argument, NULL, 0xff }, 1253 { "traditional", no_argument, NULL, 0xff },
1249 { NULL, 0, NULL, 0 } 1254 { NULL, 0, NULL, 0 }
1250 }; 1255 };
1256#endif
1251 char *str_A, *str_N, *str_j, *str_S; 1257 char *str_A, *str_N, *str_j, *str_S;
1252 char *str_w = NULL; 1258 char *str_w = NULL;
1253 llist_t *lst_t = NULL; 1259 llist_t *lst_t = NULL;
@@ -1260,7 +1266,9 @@ od_main(int argc, char **argv)
1260 1266
1261 /* Parse command line */ 1267 /* Parse command line */
1262 opt_complementary = "t::"; // list 1268 opt_complementary = "t::"; // list
1269#if ENABLE_GETOPT_LONG
1263 applet_long_options = long_options; 1270 applet_long_options = long_options;
1271#endif
1264 opt = getopt32(argc, argv, "A:N:abcdfhij:lot:vxsS:" 1272 opt = getopt32(argc, argv, "A:N:abcdfhij:lot:vxsS:"
1265 "w::", // -w with optional param 1273 "w::", // -w with optional param
1266 // -S was -s and also had optional parameter 1274 // -S was -s and also had optional parameter
@@ -1333,6 +1341,7 @@ od_main(int argc, char **argv)
1333 * FIXME: POSIX 1003.1-2001 with XSI requires support for the 1341 * FIXME: POSIX 1003.1-2001 with XSI requires support for the
1334 * traditional syntax even if --traditional is not given. */ 1342 * traditional syntax even if --traditional is not given. */
1335 1343
1344#if ENABLE_GETOPT_LONG
1336 if (opt & OPT_traditional) { 1345 if (opt & OPT_traditional) {
1337 off_t o1, o2; 1346 off_t o1, o2;
1338 1347
@@ -1388,6 +1397,7 @@ od_main(int argc, char **argv)
1388 } 1397 }
1389 } 1398 }
1390 } 1399 }
1400#endif
1391 1401
1392 if (limit_bytes_to_format) { 1402 if (limit_bytes_to_format) {
1393 end_offset = n_bytes_to_skip + max_bytes_to_format; 1403 end_offset = n_bytes_to_skip + max_bytes_to_format;
diff --git a/include/libbb.h b/include/libbb.h
index baab74878..f891e1bc4 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -333,7 +333,9 @@ extern unsigned uidgid_get(struct bb_uidgid_t*, const char* /*, unsigned*/);
333 333
334enum { BB_GETOPT_ERROR = 0x80000000 }; 334enum { BB_GETOPT_ERROR = 0x80000000 };
335extern const char *opt_complementary; 335extern const char *opt_complementary;
336#if ENABLE_GETOPT_LONG
336extern const struct option *applet_long_options; 337extern const struct option *applet_long_options;
338#endif
337extern uint32_t option_mask32; 339extern uint32_t option_mask32;
338extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...); 340extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...);
339 341
@@ -369,7 +371,7 @@ extern void bb_herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn,
369extern void bb_perror_nomsg_and_die(void) ATTRIBUTE_NORETURN; 371extern void bb_perror_nomsg_and_die(void) ATTRIBUTE_NORETURN;
370extern void bb_perror_nomsg(void); 372extern void bb_perror_nomsg(void);
371extern void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); 373extern void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
372/* These two are used internally -- you shouldn't need to use them */ 374/* These are used internally -- you shouldn't need to use them */
373extern void bb_verror_msg(const char *s, va_list p, const char *strerr); 375extern void bb_verror_msg(const char *s, va_list p, const char *strerr);
374extern void bb_vperror_msg(const char *s, va_list p); 376extern void bb_vperror_msg(const char *s, va_list p);
375extern void bb_vinfo_msg(const char *s, va_list p); 377extern void bb_vinfo_msg(const char *s, va_list p);
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index 1facfa3d8..223d2435c 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -264,15 +264,13 @@ int ftp_send(ftp_host_info_t *server, FILE *control_stream,
264 264
265#if ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS 265#if ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS
266static const struct option ftpgetput_long_options[] = { 266static const struct option ftpgetput_long_options[] = {
267 {"continue", 1, NULL, 'c'}, 267 { "continue", 1, NULL, 'c' },
268 {"verbose", 0, NULL, 'v'}, 268 { "verbose", 0, NULL, 'v' },
269 {"username", 1, NULL, 'u'}, 269 { "username", 1, NULL, 'u' },
270 {"password", 1, NULL, 'p'}, 270 { "password", 1, NULL, 'p' },
271 {"port", 1, NULL, 'P'}, 271 { "port", 1, NULL, 'P' },
272 {0, 0, 0, 0} 272 { 0, 0, 0, 0 }
273}; 273};
274#else
275#define ftpgetput_long_options 0
276#endif 274#endif
277 275
278int ftpgetput_main(int argc, char **argv) 276int ftpgetput_main(int argc, char **argv)
@@ -307,9 +305,9 @@ int ftpgetput_main(int argc, char **argv)
307 /* 305 /*
308 * Decipher the command line 306 * Decipher the command line
309 */ 307 */
310 if (ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS) 308#if ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS
311 applet_long_options = ftpgetput_long_options; 309 applet_long_options = ftpgetput_long_options;
312 310#endif
313 opt = getopt32(argc, argv, "cvu:p:P:", &server->user, &server->password, &port); 311 opt = getopt32(argc, argv, "cvu:p:P:", &server->user, &server->password, &port);
314 312
315 /* Process the non-option command line arguments */ 313 /* Process the non-option command line arguments */
diff --git a/networking/ipcalc.c b/networking/ipcalc.c
index 909373cbb..0ee9646c2 100644
--- a/networking/ipcalc.c
+++ b/networking/ipcalc.c
@@ -64,19 +64,18 @@ int get_prefix(unsigned long netmask);
64 64
65#if ENABLE_FEATURE_IPCALC_LONG_OPTIONS 65#if ENABLE_FEATURE_IPCALC_LONG_OPTIONS
66 static const struct option long_options[] = { 66 static const struct option long_options[] = {
67 {"netmask", no_argument, NULL, 'm'}, 67 { "netmask", no_argument, NULL, 'm' },
68 {"broadcast", no_argument, NULL, 'b'}, 68 { "broadcast", no_argument, NULL, 'b' },
69 {"network", no_argument, NULL, 'n'}, 69 { "network", no_argument, NULL, 'n' },
70#ifdef CONFIG_FEATURE_IPCALC_FANCY 70# if ENABLE_FEATURE_IPCALC_FANCY
71 {"prefix", no_argument, NULL, 'p'}, 71 { "prefix", no_argument, NULL, 'p' },
72 {"hostname", no_argument, NULL, 'h'}, 72 { "hostname", no_argument, NULL, 'h' },
73 {"silent", no_argument, NULL, 's'}, 73 { "silent", no_argument, NULL, 's' },
74#endif 74# endif
75 {NULL, 0, NULL, 0} 75 { NULL, 0, NULL, 0 }
76 }; 76 };
77#else
78#define long_options 0
79#endif 77#endif
78
80int ipcalc_main(int argc, char **argv) 79int ipcalc_main(int argc, char **argv)
81{ 80{
82 unsigned opt; 81 unsigned opt;
@@ -85,9 +84,9 @@ int ipcalc_main(int argc, char **argv)
85 struct in_addr a; 84 struct in_addr a;
86 char *ipstr; 85 char *ipstr;
87 86
88 if (ENABLE_FEATURE_IPCALC_LONG_OPTIONS) 87#if ENABLE_FEATURE_IPCALC_LONG_OPTIONS
89 applet_long_options = long_options; 88 applet_long_options = long_options;
90 89#endif
91 opt = getopt32(argc, argv, "mbn" USE_FEATURE_IPCALC_FANCY("phs")); 90 opt = getopt32(argc, argv, "mbn" USE_FEATURE_IPCALC_FANCY("phs"));
92 argc -= optind; 91 argc -= optind;
93 argv += optind; 92 argv += optind;
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index f69b687b2..71315ff0a 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -160,6 +160,7 @@ int udhcpc_main(int argc, char *argv[])
160 OPT_t = 1 << 16, 160 OPT_t = 1 << 16,
161 OPT_v = 1 << 17, 161 OPT_v = 1 << 17,
162 }; 162 };
163#if ENABLE_GETOPT_LONG
163 static const struct option arg_options[] = { 164 static const struct option arg_options[] = {
164 { "clientid", required_argument, 0, 'c' }, 165 { "clientid", required_argument, 0, 'c' },
165 { "clientid-none", no_argument, 0, 'C' }, 166 { "clientid-none", no_argument, 0, 'C' },
@@ -181,7 +182,7 @@ int udhcpc_main(int argc, char *argv[])
181 { "retries", required_argument, 0, 't' }, 182 { "retries", required_argument, 0, 't' },
182 { 0, 0, 0, 0 } 183 { 0, 0, 0, 0 }
183 }; 184 };
184 185#endif
185 /* Default options. */ 186 /* Default options. */
186 client_config.interface = "eth0"; 187 client_config.interface = "eth0";
187 client_config.script = DEFAULT_SCRIPT; 188 client_config.script = DEFAULT_SCRIPT;
@@ -191,7 +192,9 @@ int udhcpc_main(int argc, char *argv[])
191 /* Parse command line */ 192 /* Parse command line */
192 opt_complementary = "?:c--C:C--c" // mutually exclusive 193 opt_complementary = "?:c--C:C--c" // mutually exclusive
193 ":hH:Hh"; // -h and -H are the same 194 ":hH:Hh"; // -h and -H are the same
195#if ENABLE_GETOPT_LONG
194 applet_long_options = arg_options; 196 applet_long_options = arg_options;
197#endif
195 opt = getopt32(argc, argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:v", 198 opt = getopt32(argc, argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:v",
196 &str_c, &str_V, &str_h, &str_h, &str_F, 199 &str_c, &str_V, &str_h, &str_h, &str_F,
197 &client_config.interface, &client_config.pidfile, &str_r, 200 &client_config.interface, &client_config.pidfile, &str_r,
diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped
index ea7755da8..e14eafa6c 100644
--- a/scripts/kconfig/zconf.tab.c_shipped
+++ b/scripts/kconfig/zconf.tab.c_shipped
@@ -1949,7 +1949,7 @@ void conf_parse(const char *name)
1949 sym_init(); 1949 sym_init();
1950 menu_init(); 1950 menu_init();
1951 modules_sym = sym_lookup("MODULES", 0); 1951 modules_sym = sym_lookup("MODULES", 0);
1952 rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); 1952 rootmenu.prompt = menu_add_prompt(P_MENU, "Busybox Configuration", NULL);
1953 1953
1954#if YYDEBUG 1954#if YYDEBUG
1955 if (getenv("ZCONF_DEBUG")) 1955 if (getenv("ZCONF_DEBUG"))
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 1f61fba6a..0a7a79664 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -459,7 +459,7 @@ void conf_parse(const char *name)
459 sym_init(); 459 sym_init();
460 menu_init(); 460 menu_init();
461 modules_sym = sym_lookup("MODULES", 0); 461 modules_sym = sym_lookup("MODULES", 0);
462 rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); 462 rootmenu.prompt = menu_add_prompt(P_MENU, "Busybox Configuration", NULL);
463 463
464#if YYDEBUG 464#if YYDEBUG
465 if (getenv("ZCONF_DEBUG")) 465 if (getenv("ZCONF_DEBUG"))