From: Jonas Fonseca Date: Wed, 4 Feb 2009 13:25:29 +0000 (+0100) Subject: Use enum_map for handling obsolete color names X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1923cae0393e246f7a580f9e10b677040ce4c3d0;p=tig.git Use enum_map for handling obsolete color names --- 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]) ||