diff options
author | Peng Wu <alexepico@gmail.com> | 2012-06-27 15:55:18 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2012-06-27 15:58:54 +0800 |
commit | fc5ef3a3bad5fb1513ebf7e36321be5c03d781e2 (patch) | |
tree | 30b29b367c060cf045b7bccd64cba83df1148d7c /src | |
parent | 0634ab933695ef0ecbbffd7495da351b8ea0022f (diff) | |
download | libpinyin-fc5ef3a3bad5fb1513ebf7e36321be5c03d781e2.tar.gz libpinyin-fc5ef3a3bad5fb1513ebf7e36321be5c03d781e2.tar.xz libpinyin-fc5ef3a3bad5fb1513ebf7e36321be5c03d781e2.zip |
refine pinyin_guess_sentence_with_prefix
Diffstat (limited to 'src')
-rw-r--r-- | src/pinyin.cpp | 10 |
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); |