diff options
author | Peng Wu <alexepico@gmail.com> | 2014-03-13 14:46:42 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2014-03-13 14:50:09 +0800 |
commit | 65d61cda3f2f3a46a6be2a535dbbc3ea6fed6063 (patch) | |
tree | f2c0dfd5294c5615d0226a469057ea1f17c0f14f /src/storage/pinyin_parser2.cpp | |
parent | 7c540af4894471116aadfed6a0b92d344938c1f0 (diff) | |
download | libzhuyin-65d61cda3f2f3a46a6be2a535dbbc3ea6fed6063.tar.gz libzhuyin-65d61cda3f2f3a46a6be2a535dbbc3ea6fed6063.tar.xz libzhuyin-65d61cda3f2f3a46a6be2a535dbbc3ea6fed6063.zip |
add the force tone option
Diffstat (limited to 'src/storage/pinyin_parser2.cpp')
-rw-r--r-- | src/storage/pinyin_parser2.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index 32cee92..6fe8a19 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -267,6 +267,12 @@ bool FullPinyinParser2::parse_one_key (pinyin_option_t options, parsed_len --; tone_pos = parsed_len; } + + /* check the force tone option. */ + if (options & FORCE_TONE && CHEWING_ZERO_TONE == tone) { + g_free(input); + return false; + } } /* parse pinyin core staff here. */ @@ -558,6 +564,10 @@ bool ChewingSimpleParser2::parse_one_key(pinyin_option_t options, /* remove tone from input */ if (search_chewing_tones(m_tone_table, ch, &tone)) symbols_len --; + + /* check the force tone option */ + if (options & FORCE_TONE && CHEWING_ZERO_TONE == tone) + return false; } int i; @@ -630,14 +640,23 @@ bool ChewingDiscreteParser2::parse_one_key(pinyin_option_t options, index++; } - if (index == len) + if (index == len) { + /* check the force tone option. */ + if (options & USE_TONE && options & FORCE_TONE) + return false; goto probe; + } /* probe tone */ if (options & USE_TONE) { if (search_chewing_tones(m_tone_table, str[index], &tone)) { index ++; } + + /* check the force tone option. */ + if (options & FORCE_TONE && CHEWING_ZERO_TONE == tone) { + return false; + } } probe: @@ -844,6 +863,12 @@ bool ChewingDaChenCP26Parser2::parse_one_key(pinyin_option_t options, /* remove tone from input */ if (search_chewing_tones(m_tone_table, ch, &tone)) len --; + + /* check the force tone option. */ + if (options & FORCE_TONE && CHEWING_ZERO_TONE == tone) { + g_free(input); + return false; + } } if (0 == len) |