diff --git a/src/misc/getopt.c b/src/misc/getopt.c index f1a1639c56da1ae9140cde36d486a928daf872fd..8a2e4d50d891e63281411b997e57822745e9bb79 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; }