summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-04-25 18:11:30 +0800
committerPeng Wu <alexepico@gmail.com>2011-04-25 18:11:30 +0800
commit8a3ab40902b4d0b3a576d669d2a40e2101b450c4 (patch)
tree9727e46f34b87d3d8caf9c2d6bdc31b725d537b6
parent54b399a04fff283dec5299fc9f1d66985456754d (diff)
downloadlibpinyin-8a3ab40902b4d0b3a576d669d2a40e2101b450c4.tar.gz
libpinyin-8a3ab40902b4d0b3a576d669d2a40e2101b450c4.tar.xz
libpinyin-8a3ab40902b4d0b3a576d669d2a40e2101b450c4.zip
fixes import interpolation
-rw-r--r--utils/storage/import_interpolation.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/utils/storage/import_interpolation.cpp b/utils/storage/import_interpolation.cpp
index d8d32e4..71c4e63 100644
--- a/utils/storage/import_interpolation.cpp
+++ b/utils/storage/import_interpolation.cpp
@@ -228,7 +228,11 @@ int main(int argc, char * argv[]){
//enter "\data" line
assert(taglib_add_tag(BEGIN_LINE, "\\data", 0, "model", ""));
- my_getline(input);
+ ssize_t result = my_getline(input);
+ if ( result == -1 ) {
+ fprintf(stderr, "empty file input.\n");
+ exit(1);
+ }
//read "\data" line
assert(taglib_read(linebuf, line_type, values, required));
@@ -240,8 +244,9 @@ int main(int argc, char * argv[]){
exit(1);
}
- my_getline(input);
- parse_body(input, &phrases, &phrase_index, &bigram);
+ result = my_getline(input);
+ if ( result != -1 )
+ parse_body(input, &phrases, &phrase_index, &bigram);
taglib_fini();