From 5ed605676150810da376710beddefb6af787fd55 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 16 Sep 2013 12:48:50 +0800 Subject: fixes parse_one_key --- src/storage/pinyin_parser2.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index 2cfd93d..98702fe 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -616,6 +616,9 @@ bool ChewingSimpleParser2::in_chewing_scheme(pinyin_option_t options, bool ChewingDiscreteParser2::parse_one_key(pinyin_option_t options, ChewingKey & key, const char * str, int len) const { + if (0 == len) + return false; + options &= ~PINYIN_AMB_ALL; int index = 0; @@ -629,16 +632,25 @@ bool ChewingDiscreteParser2::parse_one_key(pinyin_option_t options, index++; } + if (index == len) + goto probe; + /* probe middle */ if (search_chewing_symbols(m_middle_table, str[index], &middle)) { index++; } + if (index == len) + goto probe; + /* probe final */ if (search_chewing_symbols(m_final_table, str[index], &final)) { index++; } + if (index == len) + goto probe; + /* probe tone */ if (options & USE_TONE) { if (search_chewing_tones(m_tone_table, str[index], &tone)) { @@ -646,6 +658,7 @@ bool ChewingDiscreteParser2::parse_one_key(pinyin_option_t options, } } +probe: gchar * chewing = g_strconcat(initial, middle, final, NULL); /* search the chewing in the chewing index table. */ -- cgit