From 64e3ee153b152091983cf830d214bb20bfa44b46 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Fri, 10 Feb 2012 14:25:59 +0800 Subject: [PATCH] fixes in_chewing_scheme --- src/pinyin.cpp | 3 ++- src/storage/pinyin_parser2.cpp | 8 ++++++-- src/storage/pinyin_parser2.h | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pinyin.cpp b/src/pinyin.cpp index 4f32c68..e1ec93e 100644 --- a/src/pinyin.cpp +++ b/src/pinyin.cpp @@ -425,7 +425,8 @@ size_t pinyin_parse_more_chewings(pinyin_instance_t * instance, bool pinyin_in_chewing_keyboard(pinyin_instance_t * instance, const char key, const char ** symbol) { pinyin_context_t * & context = instance->m_context; - return context->m_chewing_parser->in_chewing_scheme(key, symbol); + return context->m_chewing_parser->in_chewing_scheme + (context->m_options, key, symbol); } diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index ab8330c..494daad 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -777,7 +777,7 @@ int ChewingParser2::parse(pinyin_option_t options, ChewingKeyVector & keys, int maximum_len = 0; int i; /* probe the longest possible chewing string. */ for (i = 0; i < len; ++i) { - if (!in_chewing_scheme(str[i], NULL)) + if (!in_chewing_scheme(options, str[i], NULL)) break; } maximum_len = i; @@ -835,7 +835,8 @@ bool ChewingParser2::set_scheme(ChewingScheme scheme) { } -bool ChewingParser2::in_chewing_scheme(const char key, const char ** symbol) +bool ChewingParser2::in_chewing_scheme(pinyin_option_t options, + const char key, const char ** symbol) const { const gchar * chewing = NULL; char tone = CHEWING_ZERO_TONE; @@ -846,6 +847,9 @@ bool ChewingParser2::in_chewing_scheme(const char key, const char ** symbol) return true; } + if (!(options & USE_TONE)) + return false; + if (search_chewing_tones(m_tone_table, key, &tone)) { if (symbol) *symbol = chewing_tone_table[tone]; diff --git a/src/storage/pinyin_parser2.h b/src/storage/pinyin_parser2.h index d651554..2ff46f3 100644 --- a/src/storage/pinyin_parser2.h +++ b/src/storage/pinyin_parser2.h @@ -213,7 +213,7 @@ public: public: bool set_scheme(ChewingScheme scheme); - bool in_chewing_scheme(const char key, const char ** symbol) const; + bool in_chewing_scheme(pinyin_option_t options, const char key, const char ** symbol) const; }; -- 2.7.4