diff options
author | Peng Wu <alexepico@gmail.com> | 2013-03-26 10:22:55 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2013-03-26 10:22:55 +0800 |
commit | 373affdcdcef75ef2d10c427221e0c17fa8a3b7f (patch) | |
tree | 566e4f2b5107c8a569d2248b739e8172a6e8929f /src | |
parent | 57ef745db0a4eb89b5194d110e5c66231ed40ddb (diff) | |
download | libpinyin-373affdcdcef75ef2d10c427221e0c17fa8a3b7f.tar.gz libpinyin-373affdcdcef75ef2d10c427221e0c17fa8a3b7f.tar.xz libpinyin-373affdcdcef75ef2d10c427221e0c17fa8a3b7f.zip |
add checks for add phrase function
Diffstat (limited to 'src')
-rw-r--r-- | src/pinyin.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp index 7462c8e..1c31b1a 100644 --- a/src/pinyin.cpp +++ b/src/pinyin.cpp @@ -345,12 +345,15 @@ bool pinyin_iterator_add_phrase(import_iterator_t * iter, FacadeChewingTable * & pinyin_table = context->m_pinyin_table; FacadePhraseIndex * & phrase_index = context->m_phrase_index; + bool result = false; + + if (NULL == pinyin) + return result; + /* check whether the phrase exists in phrase table */ glong len_phrase = 0; ucs4_t * ucs4_phrase = g_utf8_to_ucs4(phrase, -1, NULL, &len_phrase, NULL); - bool result = false; - pinyin_option_t options = PINYIN_CORRECT_ALL | USE_TONE; FullPinyinParser2 parser; ChewingKeyVector keys = @@ -364,7 +367,7 @@ bool pinyin_iterator_add_phrase(import_iterator_t * iter, if (len_phrase != keys->len) return result; - if (len_phrase >= MAX_PHRASE_LENGTH) + if (0 == len_phrase || len_phrase >= MAX_PHRASE_LENGTH) return result; phrase_token_t token = null_token; |