1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

sort: buffer writes to the output

This fixes a regression from a33b6d87b5
This commit is contained in:
Michael Debertol 2021-07-31 16:15:22 +02:00
parent 849086e9c5
commit f29239beec

View file

@ -36,7 +36,7 @@ use std::env;
use std::ffi::{OsStr, OsString}; use std::ffi::{OsStr, OsString};
use std::fs::{File, OpenOptions}; use std::fs::{File, OpenOptions};
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use std::io::{stdin, stdout, BufRead, BufReader, Read, Write}; use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write};
use std::ops::Range; use std::ops::Range;
use std::path::Path; use std::path::Path;
use std::path::PathBuf; use std::path::PathBuf;
@ -169,15 +169,15 @@ impl Output {
} }
} }
fn into_write(self) -> Box<dyn Write> { fn into_write(self) -> BufWriter<Box<dyn Write>> {
match self.file { BufWriter::new(match self.file {
Some((_name, file)) => { Some((_name, file)) => {
// truncate the file // truncate the file
file.set_len(0).unwrap(); file.set_len(0).unwrap();
Box::new(file) Box::new(file)
} }
None => Box::new(stdout()), None => Box::new(stdout()),
} })
} }
fn as_output_name(&self) -> Option<&str> { fn as_output_name(&self) -> Option<&str> {