summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-06-27 15:55:18 +0800
committerPeng Wu <alexepico@gmail.com>2012-06-27 15:58:54 +0800
commitfc5ef3a3bad5fb1513ebf7e36321be5c03d781e2 (patch)
tree30b29b367c060cf045b7bccd64cba83df1148d7c
parent0634ab933695ef0ecbbffd7495da351b8ea0022f (diff)
downloadlibpinyin-fc5ef3a3bad5fb1513ebf7e36321be5c03d781e2.tar.gz
libpinyin-fc5ef3a3bad5fb1513ebf7e36321be5c03d781e2.tar.xz
libpinyin-fc5ef3a3bad5fb1513ebf7e36321be5c03d781e2.zip
refine pinyin_guess_sentence_with_prefix
-rw-r--r--src/pinyin.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index 7550368..573fd0d 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -546,17 +546,17 @@ bool pinyin_guess_sentence_with_prefix(pinyin_instance_t * instance,
g_array_set_size(instance->m_prefixes, 0);
g_array_append_val(instance->m_prefixes, sentence_start);
- glong written = 0;
- ucs4_t * ucs4_str = g_utf8_to_ucs4(prefix, -1, NULL, &written, NULL);
+ glong len_str = 0;
+ ucs4_t * ucs4_str = g_utf8_to_ucs4(prefix, -1, NULL, &len_str, NULL);
- if (ucs4_str && written) {
+ if (ucs4_str && len_str) {
/* add prefixes. */
- for (ssize_t i = 1; i <= written; ++i) {
+ for (ssize_t i = 1; i <= len_str; ++i) {
if (i > MAX_PHRASE_LENGTH)
break;
phrase_token_t token = null_token;
- ucs4_t * start = ucs4_str + written - i;
+ ucs4_t * start = ucs4_str + len_str - i;
int result = context->m_phrase_table->search(i, start, token);
if (result & SEARCH_OK)
g_array_append_val(instance->m_prefixes, token);