]> granicus.if.org Git - python/commitdiff
Fix a bug in this code that made it do the wrong thing when an option
authorGuido van Rossum <guido@python.org>
Tue, 30 Sep 1997 22:00:13 +0000 (22:00 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 30 Sep 1997 22:00:13 +0000 (22:00 +0000)
was a single '-'.  Thanks to Andrew Kuchling.

Python/getopt.c

index 80a00ef8bc287150830fddc95e98f2ba6e32f65b..91aaa28e81755b152f0e22329a27cc5531694f68 100644 (file)
@@ -62,7 +62,10 @@ char optstring[];
                opt_ptr = &argv[optind++][1]; 
        }
 
-       if ((ptr = strchr(optstring, option = *opt_ptr++)) == NULL) {
+       if ( (option = *opt_ptr++) == '\0')
+         return -1;
+       
+       if ((ptr = strchr(optstring, option)) == NULL) {
                if (opterr)
                        fprintf(stderr, "Unknown option: -%c\n", option);