1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

pinky: simplify and debug printing files

This commit is contained in:
Justin Tracey 2022-03-06 17:45:54 -05:00
parent f52f655934
commit 644c99ed2e

View file

@ -22,8 +22,6 @@ use clap::{crate_version, App, AppSettings, Arg};
use std::path::PathBuf; use std::path::PathBuf;
use uucore::{format_usage, InvalidEncodingHandling}; use uucore::{format_usage, InvalidEncodingHandling};
const BUFSIZE: usize = 1024;
static ABOUT: &str = "pinky - lightweight finger"; static ABOUT: &str = "pinky - lightweight finger";
const USAGE: &str = "{} [OPTION]... [USER]..."; const USAGE: &str = "{} [OPTION]... [USER]...";
@ -366,12 +364,8 @@ impl Pinky {
fn read_to_console<F: Read>(f: F) { fn read_to_console<F: Read>(f: F) {
let mut reader = BufReader::new(f); let mut reader = BufReader::new(f);
let mut iobuf = [0_u8; BUFSIZE]; let mut iobuf = Vec::new();
while let Ok(n) = reader.read(&mut iobuf) { if reader.read_to_end(&mut iobuf).is_ok() {
if n == 0 { print!("{}", String::from_utf8_lossy(&iobuf));
break;
}
let s = String::from_utf8_lossy(&iobuf);
print!("{}", s);
} }
} }