Commit 7c29e2c7 authored by Hallvard Furuseth's avatar Hallvard Furuseth
Browse files

ITS#6723: Handle EOF in test programs

parent def5d26f
......@@ -81,11 +81,9 @@ main( int argc, char *argv[] )
}
if ( strcmp( argv[ 1 ], "-" ) == 0 ) {
size_t len;
fgets( buf, sizeof( buf ), stdin );
len = strlen( buf );
if ( len > 0 && buf[ --len ] == '\n' ) {
size_t len = fgets( buf, sizeof( buf ), stdin ) ? strlen( buf ) : 0;
if ( len == 0 || buf[ --len ] == '\n' ) {
buf[ len ] = '\0';
}
strin = buf;
......@@ -296,4 +294,3 @@ main( int argc, char *argv[] )
return( 0 );
}
......@@ -990,7 +990,8 @@ get_search_filters( char *filename, char *filters[], char *attrs[], char *bases[
} else {
bases[filter] = ArgDup( line );
}
fgets( line, BUFSIZ, fp );
if ( fgets( line, BUFSIZ, fp ) == NULL )
*line = '\0';
if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
*nl = '\0';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment