From b4102bf5f8bb429788e317312c353dd2965cdf4f Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 30 Sep 1997 22:00:13 +0000 Subject: Fix a bug in this code that made it do the wrong thing when an option was a single '-'. Thanks to Andrew Kuchling. --- Python/getopt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Python/getopt.c') diff --git a/Python/getopt.c b/Python/getopt.c index 80a00ef8bc2..91aaa28e817 100644 --- a/Python/getopt.c +++ b/Python/getopt.c @@ -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); -- cgit v1.2.3-65-gdbad