From 74d79589f499fadf55295706d1aebfa793f00941 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Fri, 11 Apr 2025 00:44:51 -0400 Subject: [PATCH] chore: minor fmt match cleanup Fix an overly complex case when w is 0. Note that this might have been an error - I kept the logic, but the initial implementation might have been incorrect. --- src/uu/fmt/src/fmt.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/uu/fmt/src/fmt.rs b/src/uu/fmt/src/fmt.rs index 2fdc17746..8d7c93640 100644 --- a/src/uu/fmt/src/fmt.rs +++ b/src/uu/fmt/src/fmt.rs @@ -110,9 +110,12 @@ impl FmtOptions { } (w, g) } - (Some(w), None) => { + (Some(0), None) => { // Only allow a goal of zero if the width is set to be zero - let g = (w * DEFAULT_GOAL_TO_WIDTH_RATIO / 100).max(if w == 0 { 0 } else { 1 }); + (0, 0) + } + (Some(w), None) => { + let g = (w * DEFAULT_GOAL_TO_WIDTH_RATIO / 100).max(1); (w, g) } (None, Some(g)) => {