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>
This commit is contained in:
parent
c2f41bf521
commit
bc4075653e
7
color.c
7
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user