diff options
Diffstat (limited to 'tests/test_pinyin.cpp')
-rw-r--r-- | tests/test_pinyin.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/test_pinyin.cpp b/tests/test_pinyin.cpp index ee8f9d2..d335f77 100644 --- a/tests/test_pinyin.cpp +++ b/tests/test_pinyin.cpp @@ -31,9 +31,13 @@ int main(int argc, char * argv[]){ char* linebuf = NULL; size_t size = 0; - while( getline(&linebuf, &size, stdin) ){ - linebuf[strlen(linebuf)-1] = '\0'; - if ( strcmp ( linebuf, "quit" ) == 0) + ssize_t read; + while( (read = getline(&linebuf, &size, stdin)) != -1 ){ + if ( '\n' == linebuf[strlen(linebuf) - 1] ) { + linebuf[strlen(linebuf) - 1] = '\0'; + } + + if ( strcmp ( linebuf, "quit" ) == 0) break; pinyin_parse_more_fulls(context, linebuf, pinyin_keys); |