diff options
author | Peng Wu <alexepico@gmail.com> | 2016-06-28 12:33:33 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2016-06-28 12:33:33 +0800 |
commit | 9c2ca38f0b45f3d2937a7ccb05a7a119297107a3 (patch) | |
tree | d2a184597b17baeff73ddf3cf68f3b37955e373f /src/pinyin.cpp | |
parent | 05c2c6e853ce05a0843ae34f1df6a2226e255dc8 (diff) | |
download | libpinyin-9c2ca38f0b45f3d2937a7ccb05a7a119297107a3.tar.gz libpinyin-9c2ca38f0b45f3d2937a7ccb05a7a119297107a3.tar.xz libpinyin-9c2ca38f0b45f3d2937a7ccb05a7a119297107a3.zip |
update pinyin_get_character_offset function
Diffstat (limited to 'src/pinyin.cpp')
-rw-r--r-- | src/pinyin.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp index 28d5be2..4dd19ed 100644 --- a/src/pinyin.cpp +++ b/src/pinyin.cpp @@ -2815,15 +2815,18 @@ bool pinyin_get_right_character_offset(pinyin_instance_t * instance, } bool pinyin_get_character_offset(pinyin_instance_t * instance, - size_t cursor, - size_t * poffset) { + size_t offset, + size_t * plength) { pinyin_context_t * context = instance->m_context; FacadePhraseIndex * phrase_index = context->m_phrase_index; + + PhoneticKeyMatrix & matrix = instance->m_matrix; MatchResults results = instance->m_match_results; + _check_offset(matrix, offset); - size_t offset = 0; + size_t length = 0; PhraseItem item; - for (size_t i = 0; i < cursor; ++i) { + for (size_t i = 0; i < offset; ++i) { phrase_token_t token = g_array_index(results, phrase_token_t, i); if (null_token == token) continue; @@ -2831,10 +2834,10 @@ bool pinyin_get_character_offset(pinyin_instance_t * instance, int retval = phrase_index->get_phrase_item(token, item); assert(ERROR_OK == retval); guint8 len = item.get_phrase_length(); - offset += len; + length += len; } - *poffset = offset; + *plength = length; return true; } |