Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basenc: ignore Interrupted errors #6778

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
34 changes: 17 additions & 17 deletions src/uu/base32/src/base_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub fn get_input(config: &Config) -> UResult<Box<dyn Read>> {
}
}

pub fn handle_input<R: Read>(input: &mut R, format: Format, config: Config) -> UResult<()> {
pub fn handle_input(input: &mut dyn Read, format: Format, config: Config) -> UResult<()> {
let supports_fast_decode_and_encode = get_supports_fast_decode_and_encode(format);

let supports_fast_decode_and_encode_ref = supports_fast_decode_and_encode.as_ref();
Expand Down Expand Up @@ -377,13 +377,13 @@ pub mod fast_encode {
}

fn write_to_output(
line_wrapping_option: &mut Option<LineWrapping>,
line_wrapping: &mut Option<LineWrapping>,
encoded_buffer: &mut VecDeque<u8>,
output: &mut dyn Write,
is_cleanup: bool,
) -> io::Result<()> {
// Write all data in `encoded_buffer` to `output`
if let &mut Some(ref mut li) = line_wrapping_option {
if let &mut Some(ref mut li) = line_wrapping {
write_with_line_breaks(li, encoded_buffer, output, is_cleanup)?;
} else {
write_without_line_breaks(encoded_buffer, output, is_cleanup)?;
Expand All @@ -393,9 +393,9 @@ pub mod fast_encode {
}
// End of helper functions

pub fn fast_encode<R: Read, W: Write>(
input: &mut R,
mut output: W,
pub fn fast_encode(
input: &mut dyn Read,
output: &mut dyn Write,
supports_fast_decode_and_encode: &dyn SupportsFastDecodeAndEncode,
wrap: Option<usize>,
) -> UResult<()> {
Expand Down Expand Up @@ -475,14 +475,14 @@ pub mod fast_encode {
assert!(leftover_buffer.len() < encode_in_chunks_of_size);

// Write all data in `encoded_buffer` to `output`
write_to_output(&mut line_wrapping, &mut encoded_buffer, &mut output, false)?;
write_to_output(&mut line_wrapping, &mut encoded_buffer, output, false)?;
}
Err(er) => {
let kind = er.kind();

if kind == ErrorKind::Interrupted {
// TODO
// Retry reading?
// Retry reading
continue;
}

return Err(USimpleError::new(1, format_read_error(kind)));
Expand All @@ -499,7 +499,7 @@ pub mod fast_encode {

// Write all data in `encoded_buffer` to output
// `is_cleanup` triggers special cleanup-only logic
write_to_output(&mut line_wrapping, &mut encoded_buffer, &mut output, true)?;
write_to_output(&mut line_wrapping, &mut encoded_buffer, output, true)?;
}

Ok(())
Expand Down Expand Up @@ -606,9 +606,9 @@ pub mod fast_decode {
}
// End of helper functions

pub fn fast_decode<R: Read, W: Write>(
input: &mut R,
mut output: &mut W,
pub fn fast_decode(
input: &mut dyn Read,
output: &mut dyn Write,
supports_fast_decode_and_encode: &dyn SupportsFastDecodeAndEncode,
ignore_garbage: bool,
) -> UResult<()> {
Expand Down Expand Up @@ -711,14 +711,14 @@ pub mod fast_decode {
assert!(leftover_buffer.len() < decode_in_chunks_of_size);

// Write all data in `decoded_buffer` to `output`
write_to_output(&mut decoded_buffer, &mut output)?;
write_to_output(&mut decoded_buffer, output)?;
}
Err(er) => {
let kind = er.kind();

if kind == ErrorKind::Interrupted {
// TODO
// Retry reading?
// Retry reading
continue;
}

return Err(USimpleError::new(1, format_read_error(kind)));
Expand All @@ -734,7 +734,7 @@ pub mod fast_decode {
.decode_into_vec(&leftover_buffer, &mut decoded_buffer)?;

// Write all data in `decoded_buffer` to `output`
write_to_output(&mut decoded_buffer, &mut output)?;
write_to_output(&mut decoded_buffer, output)?;
}

Ok(())
Expand Down
10 changes: 5 additions & 5 deletions src/uu/paste/src/paste.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ fn parse_delimiters(delimiters: &str) -> UResult<Box<[Box<[u8]>]>> {
let mut add_single_char_delimiter = |vec: &mut Vec<Box<[u8]>>, ch: char| {
let delimiter_encoded = ch.encode_utf8(&mut buffer);

vec.push(Box::from(delimiter_encoded.as_bytes()));
vec.push(Box::<[u8]>::from(delimiter_encoded.as_bytes()));
};

let mut vec = Vec::<Box<[u8]>>::with_capacity(delimiters.len());
Expand Down Expand Up @@ -311,7 +311,7 @@ impl<'a> DelimiterState<'a> {
DelimiterState::MultipleDelimiters {
current_delimiter, ..
} => current_delimiter.len(),
_ => {
DelimiterState::NoDelimiters => {
return;
}
};
Expand Down Expand Up @@ -350,7 +350,7 @@ impl<'a> DelimiterState<'a> {

*current_delimiter = bo;
}
_ => {}
DelimiterState::NoDelimiters => {}
}
}
}
Expand All @@ -363,8 +363,8 @@ enum InputSource {
impl InputSource {
fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> UResult<usize> {
let us = match self {
Self::File(bu) => bu.read_until(byte, buf)?,
Self::StandardInput(rc) => rc
InputSource::File(bu) => bu.read_until(byte, buf)?,
InputSource::StandardInput(rc) => rc
.try_borrow()
.map_err(|bo| USimpleError::new(1, format!("{bo}")))?
.lock()
Expand Down
Loading