diff options
author | Peng Wu <alexepico@gmail.com> | 2022-05-30 12:03:44 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2022-05-30 12:03:44 +0800 |
commit | 41a395397ef19352504b0d194cd57b9fc01b8209 (patch) | |
tree | cf856751a5b1093c9073998c3d0153fed73f5bea | |
parent | a8def492d1c7c1b4e25f4bd23378c57139829f43 (diff) | |
download | ibus-libpinyin-41a395397ef19352504b0d194cd57b9fc01b8209.tar.gz |
Use check_result macro
-rw-r--r-- | src/PYLibPinyin.cc | 2 | ||||
-rw-r--r-- | src/PYPLibPinyinCandidates.cc | 2 | ||||
-rw-r--r-- | src/PYPunctEditor.cc | 12 | ||||
-rw-r--r-- | src/PYUtil.h | 1 |
4 files changed, 9 insertions, 8 deletions
diff --git a/src/PYLibPinyin.cc b/src/PYLibPinyin.cc index ff43f1a..fc70ff9 100644 --- a/src/PYLibPinyin.cc +++ b/src/PYLibPinyin.cc @@ -298,7 +298,7 @@ LibPinyinBackEnd::exportPinyinDictionary (const char *filename) gchar * phrase = NULL; gchar * pinyin = NULL; gint count = -1; - g_assert (pinyin_iterator_get_next_phrase (iter, &phrase, &pinyin, &count)); + check_result (pinyin_iterator_get_next_phrase (iter, &phrase, &pinyin, &count)); if (-1 == count) /* skip output the default count. */ fprintf (dictfile, "%s %s\n", phrase, pinyin); diff --git a/src/PYPLibPinyinCandidates.cc b/src/PYPLibPinyinCandidates.cc index e64c3df..d541967 100644 --- a/src/PYPLibPinyinCandidates.cc +++ b/src/PYPLibPinyinCandidates.cc @@ -154,7 +154,7 @@ LibPinyinCandidates::removeCandidate (EnhancedCandidate & enhanced) lookup_candidate_t * candidate = NULL; guint index = enhanced.m_candidate_id; pinyin_get_candidate (instance, index, &candidate); - assert (pinyin_is_user_candidate (instance, candidate)); + check_result (pinyin_is_user_candidate (instance, candidate)); pinyin_remove_user_candidate (instance, candidate); return TRUE; diff --git a/src/PYPunctEditor.cc b/src/PYPunctEditor.cc index adcb839..6babe13 100644 --- a/src/PYPunctEditor.cc +++ b/src/PYPunctEditor.cc @@ -281,8 +281,8 @@ PunctEditor::moveCursorLeft (void) it = std::find (m_punct_candidates.begin (), m_punct_candidates.end (), m_selected_puncts[m_cursor - 1]); - g_assert (it != m_punct_candidates.end ()); - m_lookup_table.setCursorPos (it - m_punct_candidates.begin ()); + if (it != m_punct_candidates.end ()) + m_lookup_table.setCursorPos (it - m_punct_candidates.begin ()); } update(); return TRUE; @@ -338,8 +338,8 @@ PunctEditor::moveCursorToEnd (void) it = std::find (m_punct_candidates.begin (), m_punct_candidates.end (), m_selected_puncts[m_cursor - 1]); - g_assert (it != m_punct_candidates.end ()); - m_lookup_table.setCursorPos (it - m_punct_candidates.begin ()); + if (it != m_punct_candidates.end ()) + m_lookup_table.setCursorPos (it - m_punct_candidates.begin ()); update(); return TRUE; @@ -366,8 +366,8 @@ PunctEditor::removeCharBefore (void) it = std::find (m_punct_candidates.begin (), m_punct_candidates.end (), m_selected_puncts[m_cursor - 1]); - g_assert (it != m_punct_candidates.end ()); - m_lookup_table.setCursorPos (it - m_punct_candidates.begin ()); + if (it != m_punct_candidates.end ()) + m_lookup_table.setCursorPos (it - m_punct_candidates.begin ()); } else { m_punct_candidates.clear (); diff --git a/src/PYUtil.h b/src/PYUtil.h index d5cc497..57c0f9f 100644 --- a/src/PYUtil.h +++ b/src/PYUtil.h @@ -27,6 +27,7 @@ #include <cstdlib> #include <string> +#include <assert.h> #ifdef __GXX_EXPERIMENTAL_CXX0X__ # include <memory> |