aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vorel <petr.vorel@gmail.com>2017-10-13 15:57:18 +0200
committerStephen Hemminger <stephen@networkplumber.org>2017-10-16 09:24:11 -0700
commit99b89c518e929e32d9b1e9e5623550018f22b552 (patch)
treecd629a031fad8250544da47be0d257a63bafa027
parent24b058a2a4f5248becc3c148637a3644d11a65a9 (diff)
downloadplatform_external_iproute2-99b89c518e929e32d9b1e9e5623550018f22b552.tar.gz
platform_external_iproute2-99b89c518e929e32d9b1e9e5623550018f22b552.tar.bz2
platform_external_iproute2-99b89c518e929e32d9b1e9e5623550018f22b552.zip
color: Cleanup code to remove "magic" offset + 7
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
-rw-r--r--lib/color.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/color.c b/lib/color.c
index 05afcb21..497f5e1b 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -45,8 +45,8 @@ static const char * const color_codes[] = {
NULL,
};
-static enum color attr_colors[] = {
- /* light background */
+/* light background */
+static enum color attr_colors_light[] = {
C_CYAN,
C_YELLOW,
C_MAGENTA,
@@ -54,8 +54,10 @@ static enum color attr_colors[] = {
C_GREEN,
C_RED,
C_CLEAR,
+};
- /* dark background */
+/* dark background */
+static enum color attr_colors_dark[] = {
C_BOLD_CYAN,
C_BOLD_YELLOW,
C_BOLD_MAGENTA,
@@ -109,8 +111,9 @@ int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...)
goto end;
}
- ret += fprintf(fp, "%s",
- color_codes[attr_colors[is_dark_bg ? attr + 7 : attr]]);
+ ret += fprintf(fp, "%s", color_codes[is_dark_bg ?
+ attr_colors_dark[attr] : attr_colors_light[attr]]);
+
ret += vfprintf(fp, fmt, args);
ret += fprintf(fp, "%s", color_codes[C_CLEAR]);