}
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;
return( 0 );
}
-
} 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';