From bc4075653e3f704f0440ec54e16f88fbc39a682d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 19 Jan 2017 18:41:22 +0700 Subject: [PATCH] color.c: trim leading spaces in color_parse_mem() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Normally color_parse_mem() is called from config parser which trims the leading spaces already. The new caller in the next patch won't. Let's be tidy and trim leading spaces too (we already trim trailing spaces after a word). Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- color.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/color.c b/color.c index a9eadd190a..7bb4a96f8c 100644 --- a/color.c +++ b/color.c @@ -207,10 +207,15 @@ int color_parse_mem(const char *value, int value_len, char *dst) struct color fg = { COLOR_UNSPECIFIED }; struct color bg = { COLOR_UNSPECIFIED }; + while (len > 0 && isspace(*ptr)) { + ptr++; + len--; + } + if (!len) return -1; - if (!strncasecmp(value, "reset", len)) { + if (!strncasecmp(ptr, "reset", len)) { xsnprintf(dst, end - dst, GIT_COLOR_RESET); return 0; } -- 2.47.1