OSDN Git Service

diff: parse ws-error-highlight option more strictly
authorRené Scharfe <l.s.r@web.de>
Sat, 11 Jul 2015 12:58:21 +0000 (14:58 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 12 Jul 2015 16:55:23 +0000 (09:55 -0700)
Check if a matched token is followed by a delimiter before advancing the
pointer arg.  This avoids accepting composite words like "allnew" or
"defaultcontext" and misparsing them as "new" or "context".

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c

diff --git a/diff.c b/diff.c
index 34012b4..8af01f1 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -3654,7 +3654,12 @@ static void enable_patch_output(int *fmt) {
 
 static int parse_one_token(const char **arg, const char *token)
 {
-       return skip_prefix(*arg, token, arg) && (!**arg || **arg == ',');
+       const char *rest;
+       if (skip_prefix(*arg, token, &rest) && (!*rest || *rest == ',')) {
+               *arg = rest;
+               return 1;
+       }
+       return 0;
 }
 
 static int parse_ws_error_highlight(struct diff_options *opt, const char *arg)