Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
102 changes: 46 additions & 56 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 24 additions & 15 deletions src/uu/sort/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2045,27 +2045,36 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
path: files0_from.clone(),
error,
})?;
let f = std::str::from_utf8(&line)
.expect("Could not parse string from zero terminated input.");
match f {
STDIN_FILE => {
return Err(SortError::MinusInStdIn.into());

if line.is_empty() {
return Err(SortError::ZeroLengthFileName {
file: files0_from,
line_num: line_num + 1,
}
"" => {
return Err(SortError::ZeroLengthFileName {
file: files0_from,
line_num: line_num + 1,
}
.into());
.into());
}

let f: OsString = {
#[cfg(unix)]
{
OsStr::from_bytes(&line).to_os_string()
}
#[cfg(not(unix))]
{
OsString::from(String::from_utf8_lossy(&line).into_owned())
}
};

match f.to_str() {
Some(s) if s == STDIN_FILE => {
return Err(SortError::MinusInStdIn.into());
}
_ => {}
}

files.push(OsString::from(
std::str::from_utf8(&line)
.expect("Could not parse string from zero terminated input."),
));
files.push(f);
}

if files.is_empty() {
return Err(SortError::EmptyInputFile { file: files0_from }.into());
}
Expand Down
21 changes: 4 additions & 17 deletions src/uucore/src/lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,23 +591,10 @@ pub enum CharByte {
Byte(u8),
}

impl From<char> for CharByte {
fn from(value: char) -> Self {
Self::Char(value)
}
}

impl From<u8> for CharByte {
fn from(value: u8) -> Self {
Self::Byte(value)
}
}

impl From<&u8> for CharByte {
fn from(value: &u8) -> Self {
Self::Byte(*value)
}
}
impl_from_for_enum!(CharByte:
char => Char;
u8 => Byte, ref
);

struct Utf8ChunkIterator<'a> {
iter: Box<dyn Iterator<Item = CharByte> + 'a>,
Expand Down
Loading
Loading