about summary refs log tree commit diff
path: root/src/misc/getopt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc/getopt.c')
-rw-r--r--src/misc/getopt.c7
1 files changed, 5 insertions, 2 deletions
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;
 }