fix !ENABLE_FEATURE_GETOPT_LONG build. Closes 3775

When compiling with !ENABLE_FEATURE_GETOPT_LONG, busybox still tries
to include getopt.h which is not available; for example with uClibc
when !UCLIBC_HAS_GETOPT_LONG.  getopt.h is only required
for the _long set of functions.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2011-05-29 04:24:13 +02:00
parent 217a7f4bf9
commit 488dd70869
5 changed files with 12 additions and 11 deletions

View File

@ -679,11 +679,10 @@ line in the midst of your #includes, if you need to parse long options:
Then have long options defined: Then have long options defined:
static const struct option <applet>_long_options[] = { static const char <applet>_longopts[] ALIGN1 =
{ "list", 0, NULL, 't' }, "list\0" No_argument "t"
{ "extract", 0, NULL, 'x' }, "extract\0" No_argument "x"
{ NULL, 0, NULL, 0 } ;
};
And a code block similar to the following near the top of your applet_main() And a code block similar to the following near the top of your applet_main()
routine: routine:
@ -691,7 +690,7 @@ routine:
char *str_b; char *str_b;
opt_complementary = "cryptic_string"; opt_complementary = "cryptic_string";
applet_long_options = <applet>_long_options; /* if you have them */ applet_long_options = <applet>_longopts; /* if you have them */
opt = getopt32(argc, argv, "ab:c", &str_b); opt = getopt32(argc, argv, "ab:c", &str_b);
if (opt & 1) { if (opt & 1) {
handle_option_a(); handle_option_a();

View File

@ -7,7 +7,9 @@
* Licensed under GPLv2 or later, see file LICENSE in this source tree. * Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/ */
#include <getopt.h> #if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
# include <getopt.h>
#endif
#include "libbb.h" #include "libbb.h"
/* Documentation /* Documentation

View File

@ -40,7 +40,6 @@
//usage: "\n -R Recurse" //usage: "\n -R Recurse"
//usage: ) //usage: )
#include <getopt.h>
#include <selinux/context.h> #include <selinux/context.h>
#include "libbb.h" #include "libbb.h"

View File

@ -50,7 +50,6 @@
//usage: "\n -l RNG Levelrange" //usage: "\n -l RNG Levelrange"
//usage: ) //usage: )
#include <getopt.h>
#include <selinux/context.h> #include <selinux/context.h>
#include <selinux/flask.h> #include <selinux/flask.h>

View File

@ -25,7 +25,7 @@
* Added NLS support (partly written by Arkadiusz Mickiewicz * Added NLS support (partly written by Arkadiusz Mickiewicz
* <misiek@misiek.eu.org>) * <misiek@misiek.eu.org>)
* Ported to Busybox - Alfred M. Szmidt <ams@trillian.itslinux.org> * Ported to Busybox - Alfred M. Szmidt <ams@trillian.itslinux.org>
* Removed --version/-V and --help/-h in * Removed --version/-V and --help/-h
* Removed parse_error(), using bb_error_msg() from Busybox instead * Removed parse_error(), using bb_error_msg() from Busybox instead
* Replaced our_malloc with xmalloc and our_realloc with xrealloc * Replaced our_malloc with xmalloc and our_realloc with xrealloc
* *
@ -79,7 +79,9 @@
//usage: " esac\n" //usage: " esac\n"
//usage: "done\n" //usage: "done\n"
#include <getopt.h> #if ENABLE_FEATURE_GETOPT_LONG
# include <getopt.h>
#endif
#include "libbb.h" #include "libbb.h"
/* NON_OPT is the code that is returned when a non-option is found in '+' /* NON_OPT is the code that is returned when a non-option is found in '+'