summaryrefslogtreecommitdiffstats
path: root/Python/getopt.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-09-30 22:00:13 (GMT)
committerGuido van Rossum <guido@python.org>1997-09-30 22:00:13 (GMT)
commitb4102bf5f8bb429788e317312c353dd2965cdf4f (patch)
treedaacc5bff0f5a8c7900532e3d9847e241dd3513d /Python/getopt.c
parentb55e07f4eb409b37b01038f6b4ad586760c4ca67 (diff)
downloadcpython-b4102bf5f8bb429788e317312c353dd2965cdf4f.zip
cpython-b4102bf5f8bb429788e317312c353dd2965cdf4f.tar.gz
cpython-b4102bf5f8bb429788e317312c353dd2965cdf4f.tar.bz2
Fix a bug in this code that made it do the wrong thing when an option
was a single '-'. Thanks to Andrew Kuchling.
Diffstat (limited to 'Python/getopt.c')
-rw-r--r--Python/getopt.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/getopt.c b/Python/getopt.c
index 80a00ef..91aaa28 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);