32 lines
1.0 KiB
Plaintext
32 lines
1.0 KiB
Plaintext
$NetBSD: patch-ac,v 1.2 2013/03/20 05:25:58 obache Exp $
|
|
|
|
* Use C++ way for getline(3) less platforms.
|
|
* fixes bogus NULL usage as Integer 0.
|
|
|
|
--- tests/lookup/test_simple_lookup.cpp.orig 2008-07-21 12:39:27.000000000 +0000
|
|
+++ tests/lookup/test_simple_lookup.cpp
|
|
@@ -1,3 +1,4 @@
|
|
+#include <iostream>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <sys/time.h>
|
|
@@ -57,7 +58,8 @@ int main( int argc, char * argv[]){
|
|
|
|
char* linebuf = (char *)malloc ( 1024 * sizeof (char) );
|
|
size_t size = 1024;
|
|
- while( getline(&linebuf, &size, stdin) ){
|
|
+ while( !std::cin.eof() ){
|
|
+ std::cin.getline(linebuf, size);
|
|
linebuf[strlen(linebuf)-1] = '\0';
|
|
if ( strcmp ( linebuf, "quit" ) == 0)
|
|
break;
|
|
@@ -91,7 +93,7 @@ int main( int argc, char * argv[]){
|
|
print_time(start_time, times);
|
|
for ( size_t i = 0; i < results->len; ++i){
|
|
phrase_token_t * token = &g_array_index(results, phrase_token_t, i);
|
|
- if ( NULL == *token)
|
|
+ if ( 0 == *token)
|
|
continue;
|
|
printf("pos:%d,token:%d\t", i, *token);
|
|
}
|