1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #2664 from jfinkels/wc-remove-mut-width

wc: remove mutable min_width parameter
This commit is contained in:
Sylvestre Ledru 2021-09-13 08:25:46 +02:00 committed by GitHub
commit b4f45bcc1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -424,8 +424,15 @@ fn wc(inputs: Vec<Input>, settings: &Settings) -> Result<(), u32> {
// The width is the number of digits needed to print the number of
// bytes in the largest file. This is true regardless of whether
// the `settings` indicate that the bytes will be displayed.
//
// If we only need to display a single number, set this to 0 to
// prevent leading spaces.
let mut failure = false;
let max_width = max_width(&inputs);
let max_width = if settings.number_enabled() <= 1 {
0
} else {
max_width(&inputs)
};
let mut total_word_count = WordCount::default();
@ -475,20 +482,10 @@ fn wc(inputs: Vec<Input>, settings: &Settings) -> Result<(), u32> {
}
}
fn print_stats(
settings: &Settings,
result: &TitledWordCount,
mut min_width: usize,
) -> io::Result<()> {
fn print_stats(settings: &Settings, result: &TitledWordCount, min_width: usize) -> io::Result<()> {
let stdout = io::stdout();
let mut stdout_lock = stdout.lock();
if settings.number_enabled() <= 1 {
// Prevent a leading space in case we only need to display a single
// number.
min_width = 0;
}
let mut is_first: bool = true;
if settings.show_lines {