From 1923cae0393e246f7a580f9e10b677040ce4c3d0 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Wed, 4 Feb 2009 14:25:29 +0100 Subject: [PATCH] Use enum_map for handling obsolete color names --- tig.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tig.c b/tig.c index 6f13a2f..d99307e 100644 --- a/tig.c +++ b/tig.c @@ -1404,19 +1404,18 @@ option_color_command(int argc, const char *argv[]) info = get_line_info(argv[0]); if (!info) { - if (!string_enum_compare(argv[0], "main-delim", strlen("main-delim"))) { - info = get_line_info("delimiter"); - - } else if (!string_enum_compare(argv[0], "main-date", strlen("main-date"))) { - info = get_line_info("date"); - - } else if (!string_enum_compare(argv[0], "main-author", strlen("main-author"))) { - info = get_line_info("author"); + static struct enum_map obsolete[] = { + ENUM_MAP("main-delim", LINE_DELIMITER), + ENUM_MAP("main-date", LINE_DATE), + ENUM_MAP("main-author", LINE_AUTHOR), + }; + int index; - } else { + if (!map_enum(&index, obsolete, argv[0])) { config_msg = "Unknown color name"; return ERR; } + info = &line_info[index]; } if (!set_color(&info->fg, argv[1]) || -- 2.30.2