parse_color: drop COLOR_BACKGROUND macro
Commit 695d95d (parse_color: refactor color storage, 2014-11-20) introduced two macros, COLOR_FOREGROUND and COLOR_BACKGROUND. The latter conflicts with a system macro defined on Windows, breaking compilation there. The simplest solution is to just get rid of these macros entirely. They are constants that are only used in one place (since the whole point of 695d95d was to avoid repeating ourselves). Their main function is to make the magic character constants more readable, but we can do the same thing with a comment. Reported-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Dec 9, 2014 at 16:01 UTC
71b59849753589c3faa04176e875071417ceddd5
1 file changed
+4
-5
color.c
+4
-5
@@ -144,9 +144,6 @@ int color_parse(const char *value, char *dst)
144
return color_parse_mem(value, strlen(value), dst);
145
}
146
147
-#define COLOR_FOREGROUND '3'
148
-#define COLOR_BACKGROUND '4'
149
-
147
/*
148
* Write the ANSI color codes for "c" to "out"; the string should
149
* already have the ANSI escape code in it. "out" should have enough
@@ -245,12 +242,14 @@ int color_parse_mem(const char *value, int value_len, char *dst)
242
if (!color_empty(&fg)) {
243
if (sep++)
244
*dst++ = ';';
248
- dst = color_output(dst, &fg, COLOR_FOREGROUND);
245
+ /* foreground colors are all in the 3x range */
246
+ dst = color_output(dst, &fg, '3');
247
}
248
if (!color_empty(&bg)) {
249
if (sep++)
250
*dst++ = ';';
253
- dst = color_output(dst, &bg, COLOR_BACKGROUND);
251
+ /* background colors are all in the 4x range */
252
+ dst = color_output(dst, &bg, '4');
253
}
254
*dst++ = 'm';
255
}