First, rename ac/av to argc/argv; those are pretty conventional names.
Second, switch from doing our own parsing of command line arguments to
using getopt(3) to do it. Aside from simplifying things, this allows
us to specify multiple arguments; the old code could only accept two
arguments (input_mode and kconfig name).
Note some subtle changes:
- The argument '-?' is no longer supported.
- '-h' is not treated as an error, so output goes to stdout, and we
exit with '0'.
- There is no compatibility checking amongst arguments; the last option
will simply override earlier options. For example, 'conf -n -y foo'
is perfectly valid now (input_mode will be set_yes). Previously, that
would have been an error ("can't find file -y").
Signed-off-by: Andres Salomon <dilinger@debian.org>
---
scripts/kconfig/conf.c | 28 +++++++++++++---------------
1 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 8be6a42..ae541b5 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -489,14 +489,14 @@ static void check_conf(struct menu *menu)
check_conf(child);
}
-int main(int ac, char **av)
+int main(int argc, char **argv)
{
- int i = 1;
+ int opt;
const char *name;
struct stat tmpstat;
- if (ac > i && av[i][0] == '-') {
- switch (av[i++][1]) {
+ while ((opt = getopt(argc, argv, "osdD:nmyrh")) != -1) {
+ switch (opt) {
case 'o':
input_mode = ask_new;
break;
@@ -509,12 +509,7 @@ int main(int ac, char **av)
break;
case 'D':
input_mode = set_default;
- defconfig_file = av[i++];
- if (!defconfig_file) {
- printf(_("%s: No default config file specified\n"),
- av[0]);
- exit(1);
- }
+ defconfig_file = optarg;
break;
case 'n':
input_mode = set_no;
@@ -530,16 +525,19 @@ int main(int ac, char **av)
srandom(time(NULL));
break;
case 'h':
- case '?':
- fprintf(stderr, "See README for usage info\n");
+ printf("See README for usage info\n");
exit(0);
+ break;
+ default:
+ fprintf(stderr, "See README for usage info\n");
+ exit(1);
}
}
- name = av[i];
- if (!name) {
- printf(_("%s: Kconfig file missing\n"), av[0]);
+ if (argc == optind) {
+ printf(_("%s: Kconfig file missing\n"), argv[0]);
exit(1);
}
+ name = argv[optind];
conf_parse(name);
//zconfdump(stdout);
switch (input_mode) {
-
| James Bottomley | Re: Integration of SCST in the mainstream Linux kernel |
| Andy Whitcroft | Re: 2.6.23-rc6-mm1 |
| Dave Johnson | expected behavior of PF_PACKET on NETIF_F_HW_VLAN_RX device? |
| Anton Salikhmetov | [PATCH -v8 2/4] Update ctime and mtime for memory-mapped files |
git: | |
| Stephen Hemminger | git pull for update of netdev fails. |
| pavlix | GIT push to sftp (feature request) |
| Wincent Colaiuta | Possible to make a totally empty repository for remote access? |
| Andrew Morton | Untracked working tree files |
| Richard Stallman | Real men don't attack straw men |
| Aaron W. Hsu | Re: sudo & wheel group |
| Jason Dixon | Wasting our Freedom |
| Alex Thurlow | Router performance on OpenBSD and OpenBGPD |
| Jeff Garzik | Re: [bug?] tg3: Failed to load firmware "tigon/tg3_tso.bin" |
| Marc Pignat | Re: [PATCH] phylib: make mdio-gpio work without OF (v2) |
| Andrew Morton | Re: [Bugme-new] [Bug 11865] New: WOL for E100 Doesn't Work Anymore |
| Jeff Kirsher | [PATCH 1/3] e1000e: add support for the 82567LM-4 device |
| VPN's on NetBSD | 11 hours ago | NetBSD |
| Why does uClinux 2.6.18 bootup block SuperIO UART IRQs that BIOS configured | 13 hours ago | Linux kernel |
| USB statistics | 14 hours ago | Linux kernel |
| Block Sub System query | 18 hours ago | Linux kernel |
| kernel module to intercept socket creation | 19 hours ago | Linux kernel |
| Image size changing during each build | 20 hours ago | Linux kernel |
| Soft lock bug | 1 day ago | Linux kernel |
| sysctl - dynamic registration problem | 1 day ago | Linux kernel |
| Question on swap as ramdisk partition | 1 day ago | Linux kernel |
| serial driver xmit problem | 1 day ago | Linux kernel |
