author | Rich Felker <dalias@aerifal.cx> | 2014年06月11日 23:38:44 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2014年06月11日 23:38:44 -0400 |
commit | 66fcde4ae4a52ae3edb1cf237ce2c22d08d7a062 (patch) | |
tree | 26f7f4b223b219c19aeb51a586bee9617bb02536 | |
parent | d79b27785fb2476017225b13d24e4b8d408f61c6 (diff) | |
download | musl-66fcde4ae4a52ae3edb1cf237ce2c22d08d7a062.tar.gz |
-rw-r--r-- | src/misc/getopt.c | 7 |
diff --git a/src/misc/getopt.c b/src/misc/getopt.c index f1a1639c..8a2e4d50 100644 --- a/src/misc/getopt.c +++ b/src/misc/getopt.c @@ -65,8 +65,11 @@ int getopt(int argc, char * const argv[], const char *optstring) } return '?'; } - optarg = argv[optind++] + optpos; - optpos = 0; + if (optstring[i+2] == ':') optarg = 0; + if (optstring[i+2] != ':' || optpos) { + optarg = argv[optind++] + optpos; + optpos = 0; + } } return c; } |