aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-05-29 04:24:13 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2011-05-29 04:24:52 +0200
commit488dd7086925b83bb36568965558221e04d2cc91 (patch)
tree2c4ee47019880b24cb308eef3eb6f9fd211fbafb
parent217a7f4bf95339a93a217c5806c5b9a48c0027d5 (diff)
downloadbusybox-w32-488dd7086925b83bb36568965558221e04d2cc91.tar.gz
busybox-w32-488dd7086925b83bb36568965558221e04d2cc91.tar.bz2
busybox-w32-488dd7086925b83bb36568965558221e04d2cc91.zip
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>
-rw-r--r--docs/style-guide.txt11
-rw-r--r--libbb/getopt32.c4
-rw-r--r--selinux/chcon.c1
-rw-r--r--selinux/runcon.c1
-rw-r--r--util-linux/getopt.c6
5 files changed, 12 insertions, 11 deletions
diff --git a/docs/style-guide.txt b/docs/style-guide.txt
index fdf6cfe4d..10ed893dc 100644
--- a/docs/style-guide.txt
+++ b/docs/style-guide.txt
@@ -679,11 +679,10 @@ line in the midst of your #includes, if you need to parse long options:
679 679
680Then have long options defined: 680Then have long options defined:
681 681
682 static const struct option <applet>_long_options[] = { 682 static const char <applet>_longopts[] ALIGN1 =
683 { "list", 0, NULL, 't' }, 683 "list\0" No_argument "t"
684 { "extract", 0, NULL, 'x' }, 684 "extract\0" No_argument "x"
685 { NULL, 0, NULL, 0 } 685 ;
686 };
687 686
688And a code block similar to the following near the top of your applet_main() 687And a code block similar to the following near the top of your applet_main()
689routine: 688routine:
@@ -691,7 +690,7 @@ routine:
691 char *str_b; 690 char *str_b;
692 691
693 opt_complementary = "cryptic_string"; 692 opt_complementary = "cryptic_string";
694 applet_long_options = <applet>_long_options; /* if you have them */ 693 applet_long_options = <applet>_longopts; /* if you have them */
695 opt = getopt32(argc, argv, "ab:c", &str_b); 694 opt = getopt32(argc, argv, "ab:c", &str_b);
696 if (opt & 1) { 695 if (opt & 1) {
697 handle_option_a(); 696 handle_option_a();
diff --git a/libbb/getopt32.c b/libbb/getopt32.c
index 18f33c704..c7c4079c2 100644
--- a/libbb/getopt32.c
+++ b/libbb/getopt32.c
@@ -7,7 +7,9 @@
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9 9
10#include <getopt.h> 10#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
11# include <getopt.h>
12#endif
11#include "libbb.h" 13#include "libbb.h"
12 14
13/* Documentation 15/* Documentation
diff --git a/selinux/chcon.c b/selinux/chcon.c
index 8644502b5..88d0cfec6 100644
--- a/selinux/chcon.c
+++ b/selinux/chcon.c
@@ -40,7 +40,6 @@
40//usage: "\n -R Recurse" 40//usage: "\n -R Recurse"
41//usage: ) 41//usage: )
42 42
43#include <getopt.h>
44#include <selinux/context.h> 43#include <selinux/context.h>
45 44
46#include "libbb.h" 45#include "libbb.h"
diff --git a/selinux/runcon.c b/selinux/runcon.c
index f0b21269f..3183a2274 100644
--- a/selinux/runcon.c
+++ b/selinux/runcon.c
@@ -50,7 +50,6 @@
50//usage: "\n -l RNG Levelrange" 50//usage: "\n -l RNG Levelrange"
51//usage: ) 51//usage: )
52 52
53#include <getopt.h>
54#include <selinux/context.h> 53#include <selinux/context.h>
55#include <selinux/flask.h> 54#include <selinux/flask.h>
56 55
diff --git a/util-linux/getopt.c b/util-linux/getopt.c
index 10e1dc49b..85ff76189 100644
--- a/util-linux/getopt.c
+++ b/util-linux/getopt.c
@@ -25,7 +25,7 @@
25 * Added NLS support (partly written by Arkadiusz Mickiewicz 25 * Added NLS support (partly written by Arkadiusz Mickiewicz
26 * <misiek@misiek.eu.org>) 26 * <misiek@misiek.eu.org>)
27 * Ported to Busybox - Alfred M. Szmidt <ams@trillian.itslinux.org> 27 * Ported to Busybox - Alfred M. Szmidt <ams@trillian.itslinux.org>
28 * Removed --version/-V and --help/-h in 28 * Removed --version/-V and --help/-h
29 * Removed parse_error(), using bb_error_msg() from Busybox instead 29 * Removed parse_error(), using bb_error_msg() from Busybox instead
30 * Replaced our_malloc with xmalloc and our_realloc with xrealloc 30 * Replaced our_malloc with xmalloc and our_realloc with xrealloc
31 * 31 *
@@ -79,7 +79,9 @@
79//usage: " esac\n" 79//usage: " esac\n"
80//usage: "done\n" 80//usage: "done\n"
81 81
82#include <getopt.h> 82#if ENABLE_FEATURE_GETOPT_LONG
83# include <getopt.h>
84#endif
83#include "libbb.h" 85#include "libbb.h"
84 86
85/* NON_OPT is the code that is returned when a non-option is found in '+' 87/* NON_OPT is the code that is returned when a non-option is found in '+'