Fix "write from stdin".

Reviewed by:	sos
MFC after:	1 week
This commit is contained in:
Pierre Beyssac 2003-07-26 12:14:58 +00:00
parent e139a45198
commit c6df222c98

View file

@ -611,8 +611,10 @@ write_file(int fd, struct track_info *track_info)
size = 0;
while ((count = read(track_info->file, buf,
MIN((track_info->file_size - size),
track_info->block_size * BLOCKS))) > 0) {
track_info->file_size == -1
? track_info->block_size * BLOCKS
: MIN((track_info->file_size - size),
track_info->block_size * BLOCKS))) > 0) {
int res;
if (count % track_info->block_size) {
@ -641,7 +643,8 @@ write_file(int fd, struct track_info *track_info)
fprintf(stderr, " total %jd KB\r",
(intmax_t)tot_size / 1024);
}
if (size >= track_info->file_size)
if (track_info->file_size != -1
&& size >= track_info->file_size)
break;
}