On Fri, Jan 10, 2020 at 10:05:45AM -0500, Eyal Soha wrote: > Signed-off-by: Eyal Soha <shawarmakarma@xxxxxxxxx> > --- > color.c | 28 +++++++++++++++++----------- > 1 file changed, 17 insertions(+), 11 deletions(-) The patch itself looks good, but it would be nice to have a commit message explaining what's going on and why. Maybe something like: Using an enum reduces the number of magic numbers in the code. Note that we also use values that allow easier computations. For example, colors with type COLOR_ANSI now store the actual foreground code we expect (e.g., red=31) instead of an offset into our array, and we can switch between foreground/background for all types by adding an offset. That will help when we add new color types in a future patch. > @@ -280,13 +286,13 @@ int color_parse_mem(const char *value, int value_len, char *dst) > if (sep++) > OUT(';'); > /* foreground colors are all in the 3x range */ > - dst = color_output(dst, end - dst, &fg, '3'); > + dst = color_output(dst, end - dst, &fg, 0); > } > if (!color_empty(&bg)) { > if (sep++) > OUT(';'); > /* background colors are all in the 4x range */ > - dst = color_output(dst, end - dst, &bg, '4'); > + dst = color_output(dst, end - dst, &bg, COLOR_BACKGROUND_OFFSET); > } Your original dropped the comments here, since we're not saying "3" or "4" literally anymore. I could go either way, but I think I slightly preferred dropping them. It might be even nicer if we had COLOR_FOREGROUND_OFFSET = 0, which you could use instead of the bare "0". -Peff