From 42d430fa5c046fec43554f7d3c2eeb680e6c5f2f Mon Sep 17 00:00:00 2001 From: handa Date: Thu, 17 Feb 2005 07:44:01 +0000 Subject: [PATCH] (setup_input_methods): Fix for the case that no input method is available. --- example/medit.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/example/medit.c b/example/medit.c index b2043f8..7f56f80 100644 --- a/example/medit.c +++ b/example/medit.c @@ -2052,7 +2052,7 @@ setup_input_methods (int with_xim, char *initial_input_method) method_name = initial_input_method; } - num_input_methods = mplist_length (plist); + num_input_methods = plist ? mplist_length (plist) : 0; if (with_xim) { @@ -2077,20 +2077,23 @@ setup_input_methods (int with_xim, char *initial_input_method) i++; } - for (pl = plist; mplist_key (pl) != Mnil; pl = mplist_next (pl)) + if (plist) { - MDatabase *mdb = mplist_value (pl); - MSymbol *tag = mdatabase_tag (mdb); - - if (tag[1] != Mnil) + for (pl = plist; mplist_key (pl) != Mnil; pl = mplist_next (pl)) { - input_method_table[i].language = tag[1]; - input_method_table[i].name = tag[2]; - i++; + MDatabase *mdb = mplist_value (pl); + MSymbol *tag = mdatabase_tag (mdb); + + if (tag[1] != Mnil) + { + input_method_table[i].language = tag[1]; + input_method_table[i].name = tag[2]; + i++; + } } - } - m17n_object_unref (plist); + m17n_object_unref (plist); + } num_input_methods = i; qsort (input_method_table, num_input_methods, sizeof input_method_table[0], compare_input_method); -- 1.7.10.4