Skip to content

Commit 71b5984

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bca45fb commit 71b5984

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

color.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ int color_parse(const char *value, char *dst)
144144
return color_parse_mem(value, strlen(value), dst);
145145
}
146146

147-
#define COLOR_FOREGROUND '3'
148-
#define COLOR_BACKGROUND '4'
149-
150147
/*
151148
* Write the ANSI color codes for "c" to "out"; the string should
152149
* 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)
245242
if (!color_empty(&fg)) {
246243
if (sep++)
247244
*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');
249247
}
250248
if (!color_empty(&bg)) {
251249
if (sep++)
252250
*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');
254253
}
255254
*dst++ = 'm';
256255
}

0 commit comments

Comments
 (0)