color.c: trim leading spaces in color_parse_mem()
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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Jan 19, 2017 at 18:41 UTC
bc4075653e3f704f0440ec54e16f88fbc39a682d
1 file changed
+6
-1
color.c
+6
-1
@@ -207,10 +207,15 @@ int color_parse_mem(const char *value, int value_len, char *dst)
207
struct color fg = { COLOR_UNSPECIFIED };
208
struct color bg = { COLOR_UNSPECIFIED };
209
210
+ while (len > 0 && isspace(*ptr)) {
211
+ ptr++;
212
+ len--;
213
+ }
214
+
215
if (!len)
216
return -1;
217
213
- if (!strncasecmp(value, "reset", len)) {
218
+ if (!strncasecmp(ptr, "reset", len)) {
219
xsnprintf(dst, end - dst, GIT_COLOR_RESET);
220
return 0;
221
}