From 9fa01b9621b7cdc102f7efda35fac5260cbf622d Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 16 Nov 2011 14:45:18 +0800 Subject: update pinyin parsers interface --- src/storage/pinyin_parser2.cpp | 17 +++++++++-------- src/storage/pinyin_parser2.h | 10 +++++----- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index 6ba15bd..1663ad2 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -119,9 +119,9 @@ static bool compare_less_than(const pinyin_index_item_t & lhs, return 0 > strcmp(lhs.m_pinyin_input, rhs.m_pinyin_input); } -int FullPinyinParser2::parse_one_key (guint32 options, ChewingKey & key, - ChewingKeyRest & key_rest, - const char * pinyin, int len) const { +bool FullPinyinParser2::parse_one_key (guint32 options, ChewingKey & key, + ChewingKeyRest & key_rest, + const char * pinyin, int len) const { /* "'" are not accepted in parse_one_key. */ assert(NULL == strchr(pinyin, '\'')); gchar * input = g_strndup(pinyin, len); @@ -144,7 +144,8 @@ int FullPinyinParser2::parse_one_key (guint32 options, ChewingKey & key, pinyin_index_item_t item; memset(&item, 0, sizeof(item)); - for (; parsed_len > 0; --parsed_len) { + /* Note: optimize here? */ + for (; parsed_len >= len - 1; --parsed_len) { input[parsed_len] = '\0'; item.m_pinyin_input = input; std_lite::pair