summaryrefslogtreecommitdiffstats
path: root/tests/lookup/test_simple_lookup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lookup/test_simple_lookup.cpp')
-rw-r--r--tests/lookup/test_simple_lookup.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/lookup/test_simple_lookup.cpp b/tests/lookup/test_simple_lookup.cpp
index 6a2ebcf..b58f248 100644
--- a/tests/lookup/test_simple_lookup.cpp
+++ b/tests/lookup/test_simple_lookup.cpp
@@ -54,8 +54,12 @@ int main( int argc, char * argv[]){
char* linebuf = NULL;
size_t size = 0;
- while( getline(&linebuf, &size, stdin) ){
- linebuf[strlen(linebuf)-1] = '\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;