diff options
author | Peng Wu <alexepico@gmail.com> | 2022-06-06 17:32:00 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2022-06-06 17:32:00 +0800 |
commit | 2323c59d337ca56c585a8b58b855e84938ecfc27 (patch) | |
tree | dc32a1af5a593170bd6149d361521832f1885ca5 | |
parent | 5f3df104b5ac0c3497a48cfc476eb3eedf1e543b (diff) | |
download | libpinyin-2323c59d337ca56c585a8b58b855e84938ecfc27.tar.gz |
Use abort function instead of assert macro
23 files changed, 67 insertions, 67 deletions
diff --git a/src/include/memory_chunk.h b/src/include/memory_chunk.h index 044fa0d..a9b9525 100644 --- a/src/include/memory_chunk.h +++ b/src/include/memory_chunk.h @@ -72,7 +72,7 @@ private: munmap(m_data_begin - header, header + capacity()); #endif else - assert(FALSE); + abort(); } diff --git a/src/lookup/phonetic_lookup.h b/src/lookup/phonetic_lookup.h index 30e1db4..72e70a5 100644 --- a/src/lookup/phonetic_lookup.h +++ b/src/lookup/phonetic_lookup.h @@ -322,7 +322,7 @@ public: return node->eval_item(candidate); } - assert(FALSE); + abort(); } /* get tails */ diff --git a/src/pinyin.cpp b/src/pinyin.cpp index 801e78f..8b0fed6 100644 --- a/src/pinyin.cpp +++ b/src/pinyin.cpp @@ -999,7 +999,7 @@ bool pinyin_set_zhuyin_scheme(pinyin_context_t * context, context->m_chewing_parser = new ZhuyinDaChenCP26Parser2(); break; default: - assert(FALSE); + abort(); } return true; } @@ -1664,7 +1664,7 @@ static bool _compute_phrase_length(pinyin_context_t * context, switch(candidate->m_candidate_type) { case NBEST_MATCH_CANDIDATE: - assert(FALSE); + abort(); case NORMAL_CANDIDATE: case PREDICTED_CANDIDATE: { phrase_index->get_phrase_item(candidate->m_token, item); @@ -1677,7 +1677,7 @@ static bool _compute_phrase_length(pinyin_context_t * context, break; } case ZOMBIE_CANDIDATE: - assert(FALSE); + abort(); } } @@ -1713,7 +1713,7 @@ static bool _compute_phrase_strings_of_items(pinyin_instance_t * instance, &(candidate->m_phrase_string)); break; case ZOMBIE_CANDIDATE: - assert(FALSE); + abort(); } } @@ -2845,7 +2845,7 @@ static gchar * _get_aux_text_prefix(pinyin_instance_t * instance, else if (IS_ZHUYIN == options) str = key.get_zhuyin_string(); else - assert(FALSE); + abort(); gchar * newprefix = g_strconcat(prefix, str, " ", NULL); @@ -2889,7 +2889,7 @@ static gchar * _get_aux_text_postfix(pinyin_instance_t * instance, else if (IS_ZHUYIN == options) str = key.get_zhuyin_string(); else - assert(FALSE); + abort(); gchar * newpostfix = g_strconcat(postfix, str, " ", NULL); @@ -3010,7 +3010,7 @@ bool pinyin_get_double_pinyin_auxiliary_text(pinyin_instance_t * instance, middle = g_strconcat(shengmu, yunmu, "|", NULL); break; default: - assert(FALSE); + abort(); } g_free(shengmu); diff --git a/src/storage/chewing_large_table.cpp b/src/storage/chewing_large_table.cpp index dccdc8e..e856caf 100644 --- a/src/storage/chewing_large_table.cpp +++ b/src/storage/chewing_large_table.cpp @@ -344,7 +344,7 @@ ChewingLengthIndexLevel::~ChewingLengthIndexLevel() { CASE(14); CASE(15); default: - assert(false); + abort(); } } #undef CASE @@ -389,7 +389,7 @@ int ChewingLengthIndexLevel::search(pinyin_option_t options, int phrase_length, CASE(14); CASE(15); default: - assert(false); + abort(); } #undef CASE @@ -545,7 +545,7 @@ int ChewingLengthIndexLevel::add_index(int phrase_length, CASE(14); CASE(15); default: - assert(false); + abort(); } #undef CASE @@ -599,7 +599,7 @@ int ChewingLengthIndexLevel::remove_index(int phrase_length, CASE(14); CASE(15); default: - assert(false); + abort(); } #undef CASE @@ -850,7 +850,7 @@ bool ChewingLengthIndexLevel::load(MemoryChunk * chunk, table_offset_t offset, CASE(14); CASE(15); default: - assert(false); + abort(); } #undef CASE @@ -910,7 +910,7 @@ bool ChewingLengthIndexLevel::store(MemoryChunk * new_chunk, CASE(14); CASE(15); default: - assert(false); + abort(); } #undef CASE @@ -1034,7 +1034,7 @@ bool ChewingLengthIndexLevel::mask_out(phrase_token_t mask, CASE(14); CASE(15); default: - assert(false); + abort(); } } #undef CASE diff --git a/src/storage/chewing_large_table2.cpp b/src/storage/chewing_large_table2.cpp index 0dc96f4..7ac1398 100644 --- a/src/storage/chewing_large_table2.cpp +++ b/src/storage/chewing_large_table2.cpp @@ -56,7 +56,7 @@ void ChewingLargeTable2::init_entries() { CASE(15); CASE(16); default: - assert(false); + abort(); } } @@ -97,7 +97,7 @@ void ChewingLargeTable2::fini_entries() { CASE(15); CASE(16); default: - assert(false); + abort(); } } diff --git a/src/storage/chewing_large_table2_bdb.cpp b/src/storage/chewing_large_table2_bdb.cpp index 9813b57..82b7fd9 100644 --- a/src/storage/chewing_large_table2_bdb.cpp +++ b/src/storage/chewing_large_table2_bdb.cpp @@ -195,7 +195,7 @@ int ChewingLargeTable2::search_internal(int phrase_length, CASE(15); CASE(16); default: - assert(false); + abort(); } #undef CASE @@ -302,7 +302,7 @@ int ChewingLargeTable2::add_index_internal(int phrase_length, CASE(15); CASE(16); default: - assert(false); + abort(); } #undef CASE @@ -376,7 +376,7 @@ int ChewingLargeTable2::remove_index_internal(int phrase_length, CASE(15); CASE(16); default: - assert(false); + abort(); } #undef CASE @@ -443,7 +443,7 @@ bool ChewingLargeTable2::mask_out(phrase_token_t mask, CASE(15); CASE(16); default: - assert(false); + abort(); } #undef CASE diff --git a/src/storage/chewing_large_table2_kyotodb.cpp b/src/storage/chewing_large_table2_kyotodb.cpp index e57552c..c606982 100644 --- a/src/storage/chewing_large_table2_kyotodb.cpp +++ b/src/storage/chewing_large_table2_kyotodb.cpp @@ -179,7 +179,7 @@ int ChewingLargeTable2::search_internal(int phrase_length, CASE(15); CASE(16); default: - assert(false); + abort(); } #undef CASE @@ -277,7 +277,7 @@ int ChewingLargeTable2::add_index_internal(int phrase_length, CASE(15); CASE(16); default: - assert(false); + abort(); } #undef CASE @@ -348,7 +348,7 @@ int ChewingLargeTable2::remove_index_internal(int phrase_length, CASE(15); CASE(16); default: - assert(false); + abort(); } #undef CASE @@ -409,12 +409,12 @@ public: CASE(15); CASE(16); default: - assert(false); + abort(); } #undef CASE - assert(false); + abort(); return NOP; } diff --git a/src/storage/flexible_ngram_bdb.h b/src/storage/flexible_ngram_bdb.h index e526e69..3453752 100644 --- a/src/storage/flexible_ngram_bdb.h +++ b/src/storage/flexible_ngram_bdb.h @@ -105,7 +105,7 @@ public: int ret = db_create(&m_db, NULL, 0); if ( ret != 0 ) - assert(false); + abort(); ret = m_db->open(m_db, NULL, dbfile, NULL, DB_HASH, db_flags, 0644); if ( ret != 0 && (flags & ATTACH_CREATE) ) { diff --git a/src/storage/ngram.cpp b/src/storage/ngram.cpp index ca845c5..c952768 100644 --- a/src/storage/ngram.cpp +++ b/src/storage/ngram.cpp @@ -105,7 +105,7 @@ guint32 SingleGram::mask_out(phrase_token_t mask, phrase_token_t value){ } bool SingleGram::prune(){ - assert(false); + abort(); #if 0 SingleGramItem * begin = (SingleGramItem *) ((const char *)(m_chunk.begin()) + sizeof(guint32)); diff --git a/src/storage/phrase_index.cpp b/src/storage/phrase_index.cpp index 36cb149..e9e9d5d 100644 --- a/src/storage/phrase_index.cpp +++ b/src/storage/phrase_index.cpp @@ -505,7 +505,7 @@ bool SubPhraseIndex::merge(PhraseIndexLogger * logger){ break; } default: - assert(false); + abort(); } } return true; @@ -801,7 +801,7 @@ bool _compute_new_header(PhraseIndexLogger * logger, break; } default: - assert(false); + abort(); } } diff --git a/src/storage/phrase_index_logger.h b/src/storage/phrase_index_logger.h index cffd937..d1e42b6 100644 --- a/src/storage/phrase_index_logger.h +++ b/src/storage/phrase_index_logger.h @@ -294,7 +294,7 @@ public: break; } default: - assert(false); + abort(); } /* store log record. */ diff --git a/src/storage/phrase_large_table2.cpp b/src/storage/phrase_large_table2.cpp index 0e6fa62..b72917c 100644 --- a/src/storage/phrase_large_table2.cpp +++ b/src/storage/phrase_large_table2.cpp @@ -184,7 +184,7 @@ PhraseLengthIndexLevel2::~PhraseLengthIndexLevel2(){ CASE(15); CASE(16); default: - assert(false); + abort(); } } g_array_free(m_phrase_array_indexes, TRUE); @@ -228,7 +228,7 @@ int PhraseLengthIndexLevel2::search(int phrase_length, CASE(15); CASE(16); default: - assert(false); + abort(); } #undef CASE } @@ -348,7 +348,7 @@ int PhraseLengthIndexLevel2::add_index(int phrase_length, CASE(15); CASE(16); default: - assert(false); + abort(); } #undef CASE @@ -402,7 +402,7 @@ int PhraseLengthIndexLevel2::remove_index(int phrase_length, CASE(15); CASE(16); default: - assert(false); + abort(); } #undef CASE } @@ -605,7 +605,7 @@ bool PhraseLengthIndexLevel2::load(MemoryChunk * chunk, CASE(15); CASE(16); default: - assert(false); + abort(); } #undef CASE } @@ -661,7 +661,7 @@ bool PhraseLengthIndexLevel2::store(MemoryChunk * new_chunk, CASE(15); CASE(16); default: - assert(false); + abort(); } //add '#' new_chunk->set_content(offset, &c_separate, sizeof(char)); @@ -781,7 +781,7 @@ bool PhraseLengthIndexLevel2::mask_out(phrase_token_t mask, CASE(15); CASE(16); default: - assert(false); + abort(); } } /* shrink self array. */ diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index 17aa358..ce640c3 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -395,7 +395,7 @@ bool FullPinyinParser2::set_scheme(FullPinyinScheme scheme){ m_pinyin_index_len = G_N_ELEMENTS(secondary_zhuyin_index); break; default: - assert(false); + abort(); } return true; } @@ -608,7 +608,7 @@ bool DoublePinyinParser2::set_scheme(DoublePinyinScheme scheme) { m_fallback_table = double_pinyin_xhe_fallback; return true; case DOUBLE_PINYIN_CUSTOMIZED: - assert(FALSE); + abort(); }; return false; /* no such scheme. */ diff --git a/src/storage/table_info.cpp b/src/storage/table_info.cpp index 44fcf60..41c7da0 100644 --- a/src/storage/table_info.cpp +++ b/src/storage/table_info.cpp @@ -113,7 +113,7 @@ static TABLE_PHONETIC_TYPE to_table_phonetic_type(const char * str) { if (0 == strcmp("zhuyin", str)) return ZHUYIN_TABLE; - assert(FALSE); + abort(); } static TABLE_DATABASE_FORMAT_TYPE to_table_database_format_type(const char * str) { @@ -123,7 +123,7 @@ static TABLE_DATABASE_FORMAT_TYPE to_table_database_format_type(const char * str if (0 == strcmp("KyotoCabinet", str)) return KYOTO_CABINET_FORMAT; - assert(FALSE); + abort(); } static TABLE_TARGET to_table_target(const char * str) { @@ -133,7 +133,7 @@ static TABLE_TARGET to_table_target(const char * str) { if (0 == strcmp("addon", str)) return ADDON_TABLE; - assert(FALSE); + abort(); } static guint8 to_index_of_default_tables(const char * str) { @@ -147,7 +147,7 @@ static guint8 to_index_of_default_tables(const char * str) { HANDLE(NETWORK_DICTIONARY); HANDLE(USER_DICTIONARY); - assert(FALSE); + abort(); } static guint8 to_index_of_addon_tables(const char * str) { @@ -166,7 +166,7 @@ static PHRASE_FILE_TYPE to_file_type(const char * str) { HANDLE(DICTIONARY); HANDLE(USER_FILE); - assert(FALSE); + abort(); } #undef HANDLE @@ -178,7 +178,7 @@ static const char * from_table_database_format_type(const TABLE_DATABASE_FORMAT_ if (format == KYOTO_CABINET_FORMAT) return "KyotoCabinet"; - assert(FALSE); + abort(); } diff --git a/src/storage/zhuyin_parser2.cpp b/src/storage/zhuyin_parser2.cpp index e711b76..3f14eab 100644 --- a/src/storage/zhuyin_parser2.cpp +++ b/src/storage/zhuyin_parser2.cpp @@ -291,7 +291,7 @@ bool ZhuyinSimpleParser2::set_scheme(ZhuyinScheme scheme) { m_symbol_table = chewing_standard_dvorak_symbols; m_tone_table = chewing_standard_dvorak_tones; default: - assert(FALSE); + abort(); } return false; @@ -484,7 +484,7 @@ bool ZhuyinDiscreteParser2::set_scheme(ZhuyinScheme scheme) { INIT_PARSER(hsu_zhuyin_index, hsu_dvorak); break; default: - assert(FALSE); + abort(); } #undef INIT_PARSER diff --git a/src/zhuyin.cpp b/src/zhuyin.cpp index 3d418c4..1aeecf5 100644 --- a/src/zhuyin.cpp +++ b/src/zhuyin.cpp @@ -733,7 +733,7 @@ bool zhuyin_set_chewing_scheme(zhuyin_context_t * context, context->m_chewing_parser = new ZhuyinDaChenCP26Parser2(); break; default: - assert(FALSE); + abort(); } return true; } @@ -1300,7 +1300,7 @@ static bool _compute_phrase_length(zhuyin_context_t * context, switch(candidate->m_candidate_type) { case BEST_MATCH_CANDIDATE: - assert(FALSE); + abort(); case NORMAL_CANDIDATE_AFTER_CURSOR: case NORMAL_CANDIDATE_BEFORE_CURSOR: { phrase_index->get_phrase_item(candidate->m_token, item); @@ -1308,7 +1308,7 @@ static bool _compute_phrase_length(zhuyin_context_t * context, break; } case ZOMBIE_CANDIDATE: - assert(FALSE); + abort(); } } @@ -1338,7 +1338,7 @@ static bool _compute_phrase_strings_of_items(zhuyin_instance_t * instance, &(candidate->m_phrase_string)); break; case ZOMBIE_CANDIDATE: - assert(FALSE); + abort(); } } diff --git a/tests/storage/test_table_info.cpp b/tests/storage/test_table_info.cpp index 4de1947..27933bc 100644 --- a/tests/storage/test_table_info.cpp +++ b/tests/storage/test_table_info.cpp @@ -44,7 +44,7 @@ void dump_table_info(const pinyin_table_info_t * table_info) { break; default: - assert(FALSE); + abort(); } } diff --git a/utils/storage/import_interpolation.cpp b/utils/storage/import_interpolation.cpp index b673a76..a07ed47 100644 --- a/utils/storage/import_interpolation.cpp +++ b/utils/storage/import_interpolation.cpp @@ -118,7 +118,7 @@ bool parse_body(FILE * input, PhraseLargeTable3 * phrase_table, parse_bigram(input, phrase_table, phrase_index, bigram); goto retry; default: - assert(FALSE); + abort(); } } while (my_getline(input) != -1) ; @@ -152,7 +152,7 @@ bool parse_unigram(FILE * input, PhraseLargeTable3 * phrase_table, case GRAM_2_LINE: goto end; default: - assert(FALSE); + abort(); } } while (my_getline(input) != -1); @@ -220,7 +220,7 @@ bool parse_bigram(FILE * input, PhraseLargeTable3 * phrase_table, case GRAM_2_LINE: goto end; default: - assert(FALSE); + abort(); } } while (my_getline(input) != -1); diff --git a/utils/training/gen_k_mixture_model.cpp b/utils/training/gen_k_mixture_model.cpp index 4595433..94969a4 100644 --- a/utils/training/gen_k_mixture_model.cpp +++ b/utils/training/gen_k_mixture_model.cpp @@ -168,7 +168,7 @@ static void train_word_pair(HashofUnigram hash_of_unigram, check_result(g_hash_table_steal(hash_of_unigram, GUINT_TO_POINTER(token2))); } else { - assert(FALSE); + abort(); } return; } @@ -195,7 +195,7 @@ static void train_word_pair(HashofUnigram hash_of_unigram, check_result(g_hash_table_steal(hash_of_unigram, GUINT_TO_POINTER(token2))); } else { - assert(FALSE); + abort(); } return; } diff --git a/utils/training/import_k_mixture_model.cpp b/utils/training/import_k_mixture_model.cpp index 6503dbf..45f8d5e 100644 --- a/utils/training/import_k_mixture_model.cpp +++ b/utils/training/import_k_mixture_model.cpp @@ -130,7 +130,7 @@ bool parse_body(FILE * input, PhraseLargeTable3 * phrase_table, parse_bigram(input, phrase_table, phrase_index, bigram); goto retry; default: - assert(FALSE); + abort(); } } while (my_getline(input) != -1) ; @@ -170,7 +170,7 @@ bool parse_unigram(FILE * input, PhraseLargeTable3 * phrase_table, case GRAM_2_LINE: goto end; default: - assert(FALSE); + abort(); } } while (my_getline(input) != -1); @@ -244,7 +244,7 @@ bool parse_bigram(FILE * input, PhraseLargeTable3 * phrase_table, case GRAM_2_LINE: goto end; default: - assert(FALSE); + abort(); } } while (my_getline(input) != -1); diff --git a/utils/training/k_mixture_model.h b/utils/training/k_mixture_model.h index 3e5eb32..3fa1dc9 100644 --- a/utils/training/k_mixture_model.h +++ b/utils/training/k_mixture_model.h @@ -79,7 +79,7 @@ static inline parameter_t compute_Pr_G_3(corpus_count_t k, return (alpha * gamma / (B - 1)) * pow((1 - 1 / (B - 1)) , k - 2); } - assert(FALSE); + abort(); } static inline parameter_t compute_Pr_G_3_with_count(corpus_count_t k, diff --git a/utils/training/k_mixture_model_to_interpolation.cpp b/utils/training/k_mixture_model_to_interpolation.cpp index 3c425ac..3a549a6 100644 --- a/utils/training/k_mixture_model_to_interpolation.cpp +++ b/utils/training/k_mixture_model_to_interpolation.cpp @@ -105,7 +105,7 @@ bool parse_body(FILE * input, FILE * output){ parse_bigram(input, output); goto retry; default: - assert(FALSE); + abort(); } } while (my_getline(input) != -1); @@ -143,7 +143,7 @@ bool parse_unigram(FILE * input, FILE * output){ case GRAM_2_LINE: goto end; default: - assert(FALSE); + abort(); } } while (my_getline(input) != -1); @@ -180,7 +180,7 @@ bool parse_bigram(FILE * input, FILE * output){ case GRAM_2_LINE: goto end; default: - assert(FALSE); + abort(); } } while (my_getline(input) != -1); diff --git a/utils/utils_helper.h b/utils/utils_helper.h index a39cf22..385415f 100644 --- a/utils/utils_helper.h +++ b/utils/utils_helper.h @@ -56,7 +56,7 @@ \ gchar ** strs = g_strsplit_set(line, " \t", 2); \ if (2 != g_strv_length(strs)) \ - assert(FALSE); \ + abort(); \ \ phrase_token_t _token = atoi(strs[0]); \ const char * phrase = strs[1]; \ |