From 48fa6408f09833129bf56e33bdb3aa949ca213aa Mon Sep 17 00:00:00 2001 From: leeight Date: Fri, 23 Sep 2011 22:39:17 +0800 Subject: FIX core dump issues and upgrade .gitignore --- .gitignore | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/pinyin.cpp | 5 ++++- tests/test_pinyin.cpp | 7 ++++++- 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 6fe9fb5..5df19c9 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,54 @@ libltdl *~ *.o *.lo +.deps +.libs +tags +cscope.* +*.la +libpinyin.pc +libpinyin.spec +tests/include/test_memory_chunk +tests/lookup/test_phrase_lookup +tests/lookup/test_simple_lookup +tests/storage/test_flexible_ngram +tests/storage/test_ngram +tests/storage/test_parser +tests/storage/test_phrase_index +tests/storage/test_phrase_index_logger +tests/storage/test_phrase_table +tests/storage/test_pinyin_index +tests/test_chewing +tests/test_phrase +tests/test_pinyin +utils/segment/ngseg +utils/segment/spseg +utils/storage/export_interpolation +utils/storage/gen_binary_files +utils/storage/gen_pinyin_table +utils/storage/gen_zhuyin_map +utils/storage/import_interpolation +utils/training/estimate_interpolation +utils/training/estimate_k_mixture_model +utils/training/eval_correction_rate +utils/training/export_k_mixture_model +utils/training/gen_deleted_ngram +utils/training/gen_k_mixture_model +utils/training/gen_ngram +utils/training/gen_unigram +utils/training/import_k_mixture_model +utils/training/k_mixture_model_to_interpolation +utils/training/merge_k_mixture_model +utils/training/prune_k_mixture_model +utils/training/validate_k_mixture_model +data/bigram.db +data/gb_char.bin +data/gb_char.dbin +data/gb_char.table +data/gbk_char.bin +data/gbk_char.dbin +data/gbk_char.table +data/interpolation.text +data/phrase_index.bin +data/pinyin_index.bin + diff --git a/src/pinyin.cpp b/src/pinyin.cpp index a34136a..233d9d9 100644 --- a/src/pinyin.cpp +++ b/src/pinyin.cpp @@ -35,7 +35,10 @@ pinyin_context_t * pinyin_init(const char * systemdir, const char * userdir){ MemoryChunk * chunk = new MemoryChunk; gchar * filename = g_build_filename (context->m_system_dir, "pinyin_index.bin", NULL); - chunk->load(filename); + if (!chunk->load(filename)) { + fprintf(stderr, "open %s failed!\n", filename); + exit(ENOENT); + } context->m_pinyin_table->load(chunk); context->m_validator.initialize(context->m_pinyin_table); diff --git a/tests/test_pinyin.cpp b/tests/test_pinyin.cpp index 31aec84..5fe97ee 100644 --- a/tests/test_pinyin.cpp +++ b/tests/test_pinyin.cpp @@ -37,8 +37,13 @@ int main(int argc, char * argv[]){ linebuf[strlen(linebuf) - 1] = '\0'; } - if ( strcmp ( linebuf, "quit" ) == 0) + if ( strcmp ( linebuf, "quit" ) == 0) { break; + } + + if (linebuf[0] == '\0') { + continue; + } pinyin_parse_more_full_pinyins(instance, linebuf); pinyin_guess_sentence(instance); -- cgit