Skip to content
Merged
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
33 changes: 17 additions & 16 deletions src/uu/expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ fn tabstops_parse(s: &str) -> Result<(RemainingMode, Vec<usize>), ParseError> {
}

// Tab sizes must be ascending.
if let Some(last_stop) = nums.last() {
if *last_stop >= num {
return Err(ParseError::TabSizesMustBeAscending);
}
if let Some(last_stop) = nums.last()
&& *last_stop >= num
{
return Err(ParseError::TabSizesMustBeAscending);
}

if is_specifier_already_used {
Expand Down Expand Up @@ -223,14 +223,15 @@ fn expand_shortcuts(args: Vec<OsString>) -> Vec<OsString> {
let mut processed_args = Vec::with_capacity(args.len());

for arg in args {
if let Some(arg) = arg.to_str() {
if arg.starts_with('-') && arg[1..].chars().all(is_digit_or_comma) {
arg[1..]
.split(',')
.filter(|s| !s.is_empty())
.for_each(|s| processed_args.push(OsString::from(format!("--tabs={s}"))));
continue;
}
if let Some(arg) = arg.to_str()
&& arg.starts_with('-')
&& arg[1..].chars().all(is_digit_or_comma)
{
arg[1..]
.split(',')
.filter(|s| !s.is_empty())
.for_each(|s| processed_args.push(OsString::from(format!("--tabs={s}"))));
continue;
}
processed_args.push(arg);
}
Expand Down Expand Up @@ -378,10 +379,10 @@ fn classify_char(buf: &[u8], byte: usize, utf8: bool) -> (CharType, usize, usize
return (Other, 1, 1);
};

if let Ok(t) = from_utf8(slice) {
if let Some(c) = t.chars().next() {
return (Other, UnicodeWidthChar::width(c).unwrap_or(0), nbytes);
}
if let Ok(t) = from_utf8(slice)
&& let Some(c) = t.chars().next()
{
return (Other, UnicodeWidthChar::width(c).unwrap_or(0), nbytes);
}
}
(Other, 1, 1) // implicit assumption: non-UTF-8 char is 1 col wide
Expand Down
Loading