summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-04-20 14:26:48 +0800
committerPeng Wu <alexepico@gmail.com>2012-04-20 14:29:08 +0800
commit93c159120335d171c4d3a01fcc9f39cf2aeb7205 (patch)
tree086356045babedc8a4be9a612cc6355b755a7e8f
parentbe2be435b1ad0371603407c567475d1490ade1ed (diff)
downloadlibpinyin-93c159120335d171c4d3a01fcc9f39cf2aeb7205.tar.gz
libpinyin-93c159120335d171c4d3a01fcc9f39cf2aeb7205.tar.xz
libpinyin-93c159120335d171c4d3a01fcc9f39cf2aeb7205.zip
polish code
-rw-r--r--src/pinyin.cpp11
-rw-r--r--src/storage/pinyin_parser2.cpp1
2 files changed, 7 insertions, 5 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index 0fd52e9..8d2314e 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -494,7 +494,7 @@ bool pinyin_in_chewing_keyboard(pinyin_instance_t * instance,
static gint compare_item_with_token(gconstpointer lhs,
- gconstpointer rhs) {
+ gconstpointer rhs) {
lookup_candidate_t * item_lhs = (lookup_candidate_t *)lhs;
lookup_candidate_t * item_rhs = (lookup_candidate_t *)rhs;
@@ -505,7 +505,7 @@ static gint compare_item_with_token(gconstpointer lhs,
}
static gint compare_item_with_frequency(gconstpointer lhs,
- gconstpointer rhs) {
+ gconstpointer rhs) {
lookup_candidate_t * item_lhs = (lookup_candidate_t *)lhs;
lookup_candidate_t * item_rhs = (lookup_candidate_t *)rhs;
@@ -886,12 +886,13 @@ bool pinyin_get_full_pinyin_candidates(pinyin_instance_t * instance,
}
for (i = pinyin_len; i >= 1; --i) {
+ bool found = false;
g_array_set_size(items, 0);
if (2 == i) {
/* handle fuzzy pinyin segment here. */
if (options & USE_DIVIDED_TABLE) {
- _try_divided_table(instance, ranges, offset, items);
+ found = _try_divided_table(instance, ranges, offset, items);
}
if (options & USE_RESPLIT_TABLE) {
assert(FALSE);
@@ -905,7 +906,9 @@ bool pinyin_get_full_pinyin_candidates(pinyin_instance_t * instance,
int retval = context->m_pinyin_table->search
(i, keys, ranges);
- if ( !(retval & SEARCH_OK) )
+ found = (retval & SEARCH_OK) || found;
+
+ if ( !found )
continue;
lookup_candidate_t template_item;
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp
index e9e5347..33c079a 100644
--- a/src/storage/pinyin_parser2.cpp
+++ b/src/storage/pinyin_parser2.cpp
@@ -576,7 +576,6 @@ bool FullPinyinParser2::post_process2(pinyin_option_t options,
const divided_table_item_t * FullPinyinParser2::retrieve_divided_item
(pinyin_option_t options, ChewingKey * key, ChewingKeyRest * rest,
const char * str, int len) const {
- guint16 tone = CHEWING_ZERO_TONE;
/* lookup divided table */
size_t k;