Skip to content

Commit 3eb7c38

Browse files
authored
Fix PrintThread: Read stderr as bytes instead of str (#842)
1 parent 7adebb9 commit 3eb7c38

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/lib.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3830,14 +3830,20 @@ impl PrintThread {
38303830
// location to another.
38313831
let print = thread::spawn(move || {
38323832
let mut stderr = BufReader::with_capacity(4096, pipe_reader);
3833-
let mut line = String::with_capacity(20);
3834-
let mut stdout = io::stdout();
3833+
let mut line = Vec::with_capacity(20);
3834+
let stdout = io::stdout();
38353835

3836-
// read_line returns 0 on Eof
3837-
while stderr.read_line(&mut line).unwrap() != 0 {
3838-
writeln!(&mut stdout, "cargo:warning={}", line).ok();
3836+
// read_until returns 0 on Eof
3837+
while stderr.read_until(b'\n', &mut line).unwrap() != 0 {
3838+
{
3839+
let mut stdout = stdout.lock();
3840+
3841+
stdout.write_all(b"cargo:warning=").unwrap();
3842+
stdout.write_all(&line).unwrap();
3843+
stdout.write_all(b"\n").unwrap();
3844+
}
38393845

3840-
// read_line does not clear the buffer
3846+
// read_until does not clear the buffer
38413847
line.clear();
38423848
}
38433849
});

0 commit comments

Comments
 (0)