summaryrefslogtreecommitdiff
path: root/color.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2017-01-19 11:41:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-01-19 19:22:01 (GMT)
commitbc4075653e3f704f0440ec54e16f88fbc39a682d (patch)
treea2a68aca6942d3f04672f7640d1a2d5c16ad1a16 /color.c
parentc2f41bf521b5b2ffb9ea93b98e4a57bf73d70864 (diff)
downloadgit-bc4075653e3f704f0440ec54e16f88fbc39a682d.zip
git-bc4075653e3f704f0440ec54e16f88fbc39a682d.tar.gz
git-bc4075653e3f704f0440ec54e16f88fbc39a682d.tar.bz2
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>
Diffstat (limited to 'color.c')
-rw-r--r--color.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/color.c b/color.c
index a9eadd1..7bb4a96 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;
}