From 22413166b0493136d7aa7c455e93dbc44f3874a6 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Mon, 9 Apr 2007 12:33:18 +0300 Subject: [PATCH] charset_list: Map the "System" codepage to the underlying one. If LC_CTYPE=fi_FI.ISO-8859-15, and terminal.*.charset = System, then the charset menu will select ISO 8859-15 by default. --- src/dialogs/options.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/dialogs/options.c b/src/dialogs/options.c index 43ce7595..75a59a8b 100644 --- a/src/dialogs/options.c +++ b/src/dialogs/options.c @@ -48,7 +48,9 @@ charset_list(struct terminal *term, void *xxx, void *ses_) { struct session *ses = ses_; int i, items; - int sel = int_max(0, get_opt_codepage_tree(term->spec, "charset")); + int sel = 0; + const unsigned char *const sel_mime = get_cp_mime_name( + get_opt_codepage_tree(term->spec, "charset")); struct menu_item *mi = new_menu(FREE_LIST); if (!mi) return; @@ -62,16 +64,16 @@ charset_list(struct terminal *term, void *xxx, void *ses_) if (is_cp_utf8(i)) continue; #endif /* CONFIG_UTF8 */ + /* Map the "System" codepage to the underlying one. + * A pointer comparison might suffice here but this + * code is not time-critical. */ + if (strcmp(sel_mime, get_cp_mime_name(i)) == 0) + sel = items; items++; add_to_menu(&mi, name, NULL, ACT_MAIN_NONE, display_codepage, get_cp_config_name(i), 0); } - /* Special codepages are not in the menu and it may cause assertion - * failures later if the selected item is out of bound. */ - if (sel >= items) - sel = 0; - do_menu_selected(term, mi, ses, sel, 0); }