diff options
author | Peng Wu <alexepico@gmail.com> | 2013-09-16 12:48:50 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2013-09-16 12:48:50 +0800 |
commit | 5ed605676150810da376710beddefb6af787fd55 (patch) | |
tree | c98ce07829dbce00d477b56151c4ccbddd5c69e3 /src | |
parent | b1316b1d6d4ccb04004b8b901243ecd6daaf04ed (diff) | |
download | libzhuyin-5ed605676150810da376710beddefb6af787fd55.tar.gz libzhuyin-5ed605676150810da376710beddefb6af787fd55.tar.xz libzhuyin-5ed605676150810da376710beddefb6af787fd55.zip |
fixes parse_one_key
Diffstat (limited to 'src')
-rw-r--r-- | src/storage/pinyin_parser2.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
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. */ |