Skip to content

Commit c964a7e

Browse files
committed
refactor: rename write functions to print for consistency in cat
1 parent df7ae35 commit c964a7e

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/uu/cat/src/cat.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl OutputOptions {
142142

143143
/// We can write fast if we can simply copy the contents of the file to
144144
/// stdout, without augmenting the output with e.g. line numbers.
145-
fn can_write_fast(&self) -> bool {
145+
fn can_print_fast(&self) -> bool {
146146
!(self.show_tabs
147147
|| self.show_nonprint
148148
|| self.show_ends
@@ -359,10 +359,10 @@ fn cat_handle<R: FdReadable>(
359359
options: &OutputOptions,
360360
state: &mut OutputState,
361361
) -> CatResult<()> {
362-
if options.can_write_fast() {
363-
write_fast(handle)
362+
if options.can_print_fast() {
363+
print_fast(handle)
364364
} else {
365-
write_lines(handle, options, state)
365+
print_lines(handle, options, state)
366366
}
367367
}
368368

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

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

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

525525
/// Outputs file contents to stdout in a line-by-line fashion,
526526
/// propagating any errors that might occur.
527-
fn write_lines<R: FdReadable>(
527+
fn print_lines<R: FdReadable>(
528528
handle: &mut InputHandle<R>,
529529
options: &OutputOptions,
530530
state: &mut OutputState,

src/uu/stat/src/stat.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ fn get_quoted_file_name(
486486

487487
fn process_token_filesystem(t: &Token, meta: &StatFs, display_name: &str) {
488488
match *t {
489-
Token::Byte(byte) => write_raw_byte(byte),
489+
Token::Byte(byte) => print_raw_byte(byte),
490490
Token::Char(c) => print!("{c}"),
491491
Token::Directive {
492492
flag,
@@ -696,7 +696,7 @@ fn print_unsigned_hex(
696696
pad_and_print(&s, flags.left, width, padding_char);
697697
}
698698

699-
fn write_raw_byte(byte: u8) {
699+
fn print_raw_byte(byte: u8) {
700700
std::io::stdout().write_all(&[byte]).unwrap();
701701
}
702702

@@ -1039,7 +1039,7 @@ impl Stater {
10391039
_: bool,
10401040
) -> Result<(), i32> {
10411041
match *t {
1042-
Token::Byte(byte) => write_raw_byte(byte),
1042+
Token::Byte(byte) => print_raw_byte(byte),
10431043
Token::Char(c) => print!("{c}"),
10441044

10451045
Token::Directive {

0 commit comments

Comments
 (0)