summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/storage/pinyin_parser2.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp
index e7c8a71..b636117 100644
--- a/src/storage/pinyin_parser2.cpp
+++ b/src/storage/pinyin_parser2.cpp
@@ -957,12 +957,14 @@ int ChewingDaChenCP26Parser2::parse(pinyin_option_t options,
/* maximum forward match for chewing. */
int parsed_len = 0;
+ const char * cur_str = NULL;
+ ChewingKey key; ChewingKeyRest key_rest;
+
while (parsed_len < maximum_len) {
- const char * cur_str = str + parsed_len;
+ cur_str = str + parsed_len;
i = std_lite::min(maximum_len - parsed_len,
(int)max_chewing_dachen26_length);
- ChewingKey key; ChewingKeyRest key_rest;
for (; i > 0; --i) {
bool success = parse_one_key(options, key, cur_str, i);
if (success)
@@ -980,6 +982,27 @@ int ChewingDaChenCP26Parser2::parse(pinyin_option_t options,
g_array_append_val(key_rests, key_rest);
}
+ /* for the last partial input */
+ options |= CHEWING_INCOMPLETE;
+
+ cur_str = str + parsed_len;
+ i = std_lite::min(maximum_len - parsed_len,
+ (int) max_chewing_dachen26_length);
+ for (; i > 0; --i) {
+ bool success = parse_one_key(options, key, cur_str, i);
+ if (success)
+ break;
+ }
+
+ if (i > 0) { /* found one */
+ key_rest.m_raw_begin = parsed_len; key_rest.m_raw_end = parsed_len + i;
+ parsed_len += i;
+
+ /* save the pinyin. */
+ g_array_append_val(keys, key);
+ g_array_append_val(key_rests, key_rest);
+ }
+
return parsed_len;
}