Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/uu/cat/src/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl OutputOptions {

/// We can write fast if we can simply copy the contents of the file to
/// stdout, without augmenting the output with e.g. line numbers.
fn can_write_fast(&self) -> bool {
fn can_print_fast(&self) -> bool {
!(self.show_tabs
|| self.show_nonprint
|| self.show_ends
Expand Down Expand Up @@ -359,10 +359,10 @@ fn cat_handle<R: FdReadable>(
options: &OutputOptions,
state: &mut OutputState,
) -> CatResult<()> {
if options.can_write_fast() {
write_fast(handle)
if options.can_print_fast() {
print_fast(handle)
} else {
write_lines(handle, options, state)
print_lines(handle, options, state)
}
}

Expand Down Expand Up @@ -476,7 +476,7 @@ fn get_input_type(path: &OsString) -> CatResult<InputType> {

/// Writes handle to stdout with no configuration. This allows a
/// simple memory copy.
fn write_fast<R: FdReadable>(handle: &mut InputHandle<R>) -> CatResult<()> {
fn print_fast<R: FdReadable>(handle: &mut InputHandle<R>) -> CatResult<()> {
let stdout = io::stdout();
#[cfg(any(target_os = "linux", target_os = "android"))]
let mut stdout = stdout;
Expand All @@ -490,12 +490,12 @@ fn write_fast<R: FdReadable>(handle: &mut InputHandle<R>) -> CatResult<()> {
}
// If we're not on Linux or Android, or the splice() call failed,
// fall back on slower writing.
write_slow(handle, stdout)
print_slow(handle, stdout)
}

#[cfg_attr(any(target_os = "linux", target_os = "android"), inline(never))] // splice fast-path does not require this allocation
#[cfg_attr(not(any(target_os = "linux", target_os = "android")), inline)]
fn write_slow<R: FdReadable>(handle: &mut InputHandle<R>, stdout: io::Stdout) -> CatResult<()> {
fn print_slow<R: FdReadable>(handle: &mut InputHandle<R>, stdout: io::Stdout) -> CatResult<()> {
let mut stdout_lock = stdout.lock();
let mut buf = [0; 1024 * 64];
loop {
Expand Down Expand Up @@ -524,7 +524,7 @@ fn write_slow<R: FdReadable>(handle: &mut InputHandle<R>, stdout: io::Stdout) ->

/// Outputs file contents to stdout in a line-by-line fashion,
/// propagating any errors that might occur.
fn write_lines<R: FdReadable>(
fn print_lines<R: FdReadable>(
handle: &mut InputHandle<R>,
options: &OutputOptions,
state: &mut OutputState,
Expand Down
6 changes: 3 additions & 3 deletions src/uu/stat/src/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ fn get_quoted_file_name(

fn process_token_filesystem(t: &Token, meta: &StatFs, display_name: &str) {
match *t {
Token::Byte(byte) => write_raw_byte(byte),
Token::Byte(byte) => print_raw_byte(byte),
Token::Char(c) => print!("{c}"),
Token::Directive {
flag,
Expand Down Expand Up @@ -696,7 +696,7 @@ fn print_unsigned_hex(
pad_and_print(&s, flags.left, width, padding_char);
}

fn write_raw_byte(byte: u8) {
fn print_raw_byte(byte: u8) {
std::io::stdout().write_all(&[byte]).unwrap();
}

Expand Down Expand Up @@ -1039,7 +1039,7 @@ impl Stater {
_: bool,
) -> Result<(), i32> {
match *t {
Token::Byte(byte) => write_raw_byte(byte),
Token::Byte(byte) => print_raw_byte(byte),
Token::Char(c) => print!("{c}"),

Token::Directive {
Expand Down
Loading