about summary refs log tree commit diff
path: root/src/misc
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/getopt_long.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/misc/getopt_long.c b/src/misc/getopt_long.c
index 568ae7ba..0d1501d4 100644
--- a/src/misc/getopt_long.c
+++ b/src/misc/getopt_long.c
@@ -58,13 +58,14 @@ static int __getopt_long_core(int argc, char *const *argv, const char *optstring
 	{
 		int colon = optstring[optstring[0]=='+'||optstring[0]=='-']==':';
 		int i, cnt, match;
-		char *opt;
+		char *arg, *opt;
 		for (cnt=i=0; longopts[i].name; i++) {
 			const char *name = longopts[i].name;
 			opt = argv[optind]+1;
 			if (*opt == '-') opt++;
 			for (; *name && *name == *opt; name++, opt++);
 			if (*opt && *opt != '=') continue;
+			arg = opt;
 			match = i;
 			if (!*name) {
 				cnt = 1;
@@ -74,6 +75,7 @@ static int __getopt_long_core(int argc, char *const *argv, const char *optstring
 		}
 		if (cnt==1) {
 			i = match;
+			opt = arg;
 			optind++;
 			if (*opt == '=') {
 				if (!longopts[i].has_arg) {