summaryrefslogtreecommitdiff
path: root/Python/getopt.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-09-30 22:00:13 +0000
committerGuido van Rossum <guido@python.org>1997-09-30 22:00:13 +0000
commit93b50409381f436f8cf9094469d31b0ff1b34400 (patch)
tree178f5cd69edf323100bab14d81770ca83bc16098 /Python/getopt.c
parentad80b4a3e00b5f134c8da6c3c73376e8127fe21e (diff)
downloadcpython-93b50409381f436f8cf9094469d31b0ff1b34400.tar.gz
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 80a00ef8bc..91aaa28e81 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);