Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: uutils/coreutils
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1bff5f332a870fc068e0463931afcd7692bd163d
Choose a base ref
..
head repository: uutils/coreutils
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2aa6434417d33e36b555dc546020513872c4fc59
Choose a head ref
Showing with 9 additions and 16 deletions.
  1. +9 −16 src/uu/printf/src/printf.rs
25 changes: 9 additions & 16 deletions src/uu/printf/src/printf.rs
Original file line number Diff line number Diff line change
@@ -36,28 +36,21 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let format = format.as_bytes();

#[cfg(windows)]
let format_vec: Vec<u8> = format
.encode_wide()
.flat_map(|wchar| wchar.to_le_bytes())
.collect();
#[cfg(windows)]
let format = format_vec.as_slice();
let format = as_os_str().as_bytes_lossy();

let values: Vec<_> = match matches.get_many::<std::ffi::OsString>(options::ARGUMENT) {
Some(s) => s
.map(|os_str| {
#[cfg(unix)]
let raw_bytes: Vec<u8> = os_str.clone().into_vec();

#[cfg(unix)]
{
FormatArgument::Unparsed(
String::from_utf8(raw_bytes.clone())
.unwrap_or_else(|_| raw_bytes.iter().map(|&b| b as char).collect()),
)
}
#[cfg(windows)]
let raw_bytes: Vec<u8> = os_str
.encode_wide()
.flat_map(|wchar| wchar.to_le_bytes())
.collect();
FormatArgument::Unparsed(
String::from_utf8(raw_bytes.clone())
.unwrap_or_else(|_| raw_bytes.iter().map(|&b| b as char).collect()),
)
FormatArgument::Unparsed(String::from_utf8_lossy(&raw_bytes).into_owned())
})
.collect(),
None => vec![],