Thread (26 messages) flat view 26 messages, 5 authors, 2016-06-15
STALE3749d

[PATCH 12/14] opt_arg(): simplify pointer handling

From: Michael Haggerty <hidden>
Date: 2016-06-15 23:04:11
Subsystem: the rest · Maintainer: Linus Torvalds

Increment "arg" when a character is consumed, not just before consuming
the next character.

Signed-off-by: Michael Haggerty <redacted>
---
 diff.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/diff.c b/diff.c
index 03cdabf..bc1e3c3 100644
--- a/diff.c
+++ b/diff.c
@@ -3358,14 +3358,13 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va
 	char c, *eq;
 	int len;
 
-	if (*arg != '-')
+	if (*arg++ != '-')
 		return 0;
-	c = *++arg;
+	c = *arg++;
 	if (!c)
 		return 0;
 	if (c == arg_short) {
-		c = *++arg;
-		if (!c)
+		if (!*arg)
 			return 1; /* optional argument was missing */
 		if (convert_i(arg, 10, val))
 			die("The value for -%c must be a non-negative integer", arg_short);
@@ -3373,7 +3372,6 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va
 	}
 	if (c != '-')
 		return 0;
-	arg++;
 	eq = strchrnul(arg, '=');
 	len = eq - arg;
 	if (!len || strncmp(arg, arg_long, len))
-- 
2.1.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help