Skip to content
Draft
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
1 change: 1 addition & 0 deletions src/uu/df/src/df.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ impl Options {
),
ParseSizeError::ParseFailure(s) => OptionsError::InvalidBlockSize(s),
ParseSizeError::PhysicalMem(s) => OptionsError::InvalidBlockSize(s),
ParseSizeError::BuilderConfig(e) => OptionsError::InvalidBlockSize(e.to_string()),
})?,
header_mode: {
if matches.get_flag(OPT_HUMAN_READABLE_BINARY)
Expand Down
3 changes: 3 additions & 0 deletions src/uu/du/src/du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,9 @@ fn format_error_message(error: &ParseSizeError, s: &str, option: &str) -> String
ParseSizeError::SizeTooBig(_) => {
translate!("du-error-argument-too-large", "option" => option, "value" => s.quote())
}
ParseSizeError::BuilderConfig(e) => {
format!("invalid configuration for {option}: {e}")
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/uu/od/src/od.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,5 +804,8 @@ fn format_error_message(error: &ParseSizeError, s: &str, option: &str) -> String
ParseSizeError::SizeTooBig(_) => {
translate!("od-error-argument-too-large", "option" => option, "value" => s.quote())
}
ParseSizeError::BuilderConfig(e) => {
format!("invalid configuration for {option}: {e}")
}
}
}
11 changes: 7 additions & 4 deletions src/uu/sort/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@ impl GlobalSettings {
// GNU sort (8.32) invalid: b, B, 1B, p, e, z, y
let size = Parser::default()
.with_allow_list(&[
"b", "k", "K", "m", "M", "g", "G", "t", "T", "P", "E", "Z", "Y", "R", "Q", "%",
])
.with_default_unit("K")
.with_b_byte_count(true)
"b", "k", "K", "m", "M", "g", "G", "t", "T", "P", "E", "Z", "Y", "R", "Q",
])?
.with_default_unit("K")?
.with_b_byte_count(true)?
.parse(input.trim())?;

usize::try_from(size).map_err(|_| {
Expand Down Expand Up @@ -2268,6 +2268,9 @@ fn format_error_message(error: &ParseSizeError, s: &str, option: &str) -> String
ParseSizeError::SizeTooBig(_) => {
translate!("sort-option-arg-too-large", "option" => option, "arg" => s.quote())
}
ParseSizeError::BuilderConfig(e) => {
format!("invalid configuration for {option}: {e}")
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/uucore/src/lib/features/i18n/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use icu_provider::prelude::*;
use crate::i18n::get_numeric_locale;

/// Return the decimal separator for the given locale
fn get_decimal_separator(loc: Locale) -> String {
fn get_decimal_separator(loc: &Locale) -> String {
let data_locale = DataLocale::from(loc);

let request = DataRequest {
Expand All @@ -34,7 +34,7 @@ fn get_decimal_separator(loc: Locale) -> String {
pub fn locale_decimal_separator() -> &'static str {
static DECIMAL_SEP: OnceLock<String> = OnceLock::new();

DECIMAL_SEP.get_or_init(|| get_decimal_separator(get_numeric_locale().0.clone()))
DECIMAL_SEP.get_or_init(|| get_decimal_separator(&get_numeric_locale().0))
}

#[cfg(test)]
Expand All @@ -45,7 +45,7 @@ mod tests {

#[test]
fn test_simple_separator() {
assert_eq!(get_decimal_separator(locale!("en")), ".");
assert_eq!(get_decimal_separator(locale!("fr")), ",");
assert_eq!(get_decimal_separator(&locale!("en")), ".");
assert_eq!(get_decimal_separator(&locale!("fr")), ",");
}
}
Loading
Loading