summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-09-16 12:48:50 +0800
committerPeng Wu <alexepico@gmail.com>2013-09-16 12:48:50 +0800
commit5ed605676150810da376710beddefb6af787fd55 (patch)
treec98ce07829dbce00d477b56151c4ccbddd5c69e3
parentb1316b1d6d4ccb04004b8b901243ecd6daaf04ed (diff)
downloadlibzhuyin-5ed605676150810da376710beddefb6af787fd55.tar.gz
libzhuyin-5ed605676150810da376710beddefb6af787fd55.tar.xz
libzhuyin-5ed605676150810da376710beddefb6af787fd55.zip
fixes parse_one_key
-rw-r--r--src/storage/pinyin_parser2.cpp13
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. */