Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=2f4b489b77c68b9cba1bd9dec5a1bbf0ab3c47f8
Commit:     2f4b489b77c68b9cba1bd9dec5a1bbf0ab3c47f8
Parent:     666ab414fe14e8bbbe86a110437346128e1ec869
Author:     Andres Salomon <[EMAIL PROTECTED]>
AuthorDate: Mon Dec 17 01:34:58 2007 -0500
Committer:  Sam Ravnborg <[EMAIL PROTECTED]>
CommitDate: Mon Jan 28 23:14:36 2008 +0100

    kconfig: use getopt() in conf.c for handling command line arguments
    
    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 <[EMAIL PROTECTED]>
    Signed-off-by: Sam Ravnborg <[EMAIL PROTECTED]>
    Cc: Roman Zippel <[EMAIL PROTECTED]>
---
 scripts/kconfig/conf.c |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 8d6f174..d4737d3 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -495,12 +495,12 @@ static void check_conf(struct menu *menu)
 
 int main(int ac, char **av)
 {
-       int i = 1;
+       int opt;
        const char *name;
        struct stat tmpstat;
 
-       if (ac > i && av[i][0] == '-') {
-               switch (av[i++][1]) {
+       while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) {
+               switch (opt) {
                case 'o':
                        input_mode = ask_new;
                        break;
@@ -513,12 +513,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;
@@ -534,16 +529,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) {
+       if (ac == optind) {
                printf(_("%s: Kconfig file missing\n"), av[0]);
                exit(1);
        }
+       name = av[optind];
        conf_parse(name);
        //zconfdump(stdout);
        switch (input_mode) {
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to