mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #2699 from jfinkels/lint-fixes
ls,more,csplit,sort,od,dd: fix clippy complaints
This commit is contained in:
commit
20becf8166
6 changed files with 37 additions and 41 deletions
|
@ -320,18 +320,19 @@ impl<'a> SplitWriter<'a> {
|
||||||
let l = line?;
|
let l = line?;
|
||||||
match n.cmp(&(&ln + 1)) {
|
match n.cmp(&(&ln + 1)) {
|
||||||
Ordering::Less => {
|
Ordering::Less => {
|
||||||
if input_iter.add_line_to_buffer(ln, l).is_some() {
|
assert!(
|
||||||
panic!("the buffer is big enough to contain 1 line");
|
input_iter.add_line_to_buffer(ln, l).is_none(),
|
||||||
}
|
"the buffer is big enough to contain 1 line"
|
||||||
|
);
|
||||||
ret = Ok(());
|
ret = Ok(());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Ordering::Equal => {
|
Ordering::Equal => {
|
||||||
if !self.options.suppress_matched
|
assert!(
|
||||||
&& input_iter.add_line_to_buffer(ln, l).is_some()
|
self.options.suppress_matched
|
||||||
{
|
|| input_iter.add_line_to_buffer(ln, l).is_none(),
|
||||||
panic!("the buffer is big enough to contain 1 line");
|
"the buffer is big enough to contain 1 line"
|
||||||
}
|
);
|
||||||
ret = Ok(());
|
ret = Ok(());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -378,9 +379,10 @@ impl<'a> SplitWriter<'a> {
|
||||||
match (self.options.suppress_matched, offset) {
|
match (self.options.suppress_matched, offset) {
|
||||||
// no offset, add the line to the next split
|
// no offset, add the line to the next split
|
||||||
(false, 0) => {
|
(false, 0) => {
|
||||||
if input_iter.add_line_to_buffer(ln, l).is_some() {
|
assert!(
|
||||||
panic!("the buffer is big enough to contain 1 line");
|
input_iter.add_line_to_buffer(ln, l).is_none(),
|
||||||
}
|
"the buffer is big enough to contain 1 line"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// a positive offset, some more lines need to be added to the current split
|
// a positive offset, some more lines need to be added to the current split
|
||||||
(false, _) => self.writeln(l)?,
|
(false, _) => self.writeln(l)?,
|
||||||
|
@ -425,9 +427,10 @@ impl<'a> SplitWriter<'a> {
|
||||||
if !self.options.suppress_matched {
|
if !self.options.suppress_matched {
|
||||||
// add 1 to the buffer size to make place for the matched line
|
// add 1 to the buffer size to make place for the matched line
|
||||||
input_iter.set_size_of_buffer(offset_usize + 1);
|
input_iter.set_size_of_buffer(offset_usize + 1);
|
||||||
if input_iter.add_line_to_buffer(ln, l).is_some() {
|
assert!(
|
||||||
panic!("should be big enough to hold every lines");
|
input_iter.add_line_to_buffer(ln, l).is_none(),
|
||||||
}
|
"should be big enough to hold every lines"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
self.finish_split();
|
self.finish_split();
|
||||||
if input_iter.buffer_len() < offset_usize {
|
if input_iter.buffer_len() < offset_usize {
|
||||||
|
|
|
@ -35,12 +35,11 @@ fn unimplemented_flags_should_error_non_linux() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !succeeded.is_empty() {
|
assert!(
|
||||||
panic!(
|
succeeded.is_empty(),
|
||||||
"The following flags did not panic as expected: {:?}",
|
"The following flags did not panic as expected: {:?}",
|
||||||
succeeded
|
succeeded
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -64,12 +63,11 @@ fn unimplemented_flags_should_error() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !succeeded.is_empty() {
|
assert!(
|
||||||
panic!(
|
succeeded.is_empty(),
|
||||||
"The following flags did not panic as expected: {:?}",
|
"The following flags did not panic as expected: {:?}",
|
||||||
succeeded
|
succeeded
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -1967,11 +1967,7 @@ fn display_file_name(
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
if config.format != Format::Long && config.inode {
|
if config.format != Format::Long && config.inode {
|
||||||
name = path
|
name = path.md().map_or_else(|| "?".to_string(), get_inode) + " " + &name;
|
||||||
.md()
|
|
||||||
.map_or_else(|| "?".to_string(), |md| get_inode(md))
|
|
||||||
+ " "
|
|
||||||
+ &name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ fn reset_term(stdout: &mut std::io::Stdout) {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn reset_term(_: &mut usize) {}
|
fn reset_term(_: &mut usize) {}
|
||||||
|
|
||||||
fn more(buff: &str, mut stdout: &mut Stdout, next_file: Option<&str>, silent: bool) {
|
fn more(buff: &str, stdout: &mut Stdout, next_file: Option<&str>, silent: bool) {
|
||||||
let (cols, rows) = terminal::size().unwrap();
|
let (cols, rows) = terminal::size().unwrap();
|
||||||
let lines = break_buff(buff, usize::from(cols));
|
let lines = break_buff(buff, usize::from(cols));
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ fn more(buff: &str, mut stdout: &mut Stdout, next_file: Option<&str>, silent: bo
|
||||||
code: KeyCode::Char('c'),
|
code: KeyCode::Char('c'),
|
||||||
modifiers: KeyModifiers::CONTROL,
|
modifiers: KeyModifiers::CONTROL,
|
||||||
}) => {
|
}) => {
|
||||||
reset_term(&mut stdout);
|
reset_term(stdout);
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
Event::Key(KeyEvent {
|
Event::Key(KeyEvent {
|
||||||
|
|
|
@ -145,13 +145,12 @@ impl OutputInfo {
|
||||||
byte_size_block: usize,
|
byte_size_block: usize,
|
||||||
print_width_block: usize,
|
print_width_block: usize,
|
||||||
) -> [usize; MAX_BYTES_PER_UNIT] {
|
) -> [usize; MAX_BYTES_PER_UNIT] {
|
||||||
if byte_size_block > MAX_BYTES_PER_UNIT {
|
assert!(
|
||||||
panic!(
|
byte_size_block <= MAX_BYTES_PER_UNIT,
|
||||||
"{}-bits types are unsupported. Current max={}-bits.",
|
"{}-bits types are unsupported. Current max={}-bits.",
|
||||||
8 * byte_size_block,
|
8 * byte_size_block,
|
||||||
8 * MAX_BYTES_PER_UNIT
|
8 * MAX_BYTES_PER_UNIT
|
||||||
);
|
);
|
||||||
}
|
|
||||||
let mut spacing = [0; MAX_BYTES_PER_UNIT];
|
let mut spacing = [0; MAX_BYTES_PER_UNIT];
|
||||||
|
|
||||||
let mut byte_size = sf.byte_size();
|
let mut byte_size = sf.byte_size();
|
||||||
|
|
|
@ -825,7 +825,7 @@ impl FieldSelector {
|
||||||
fn parse(key: &str, global_settings: &GlobalSettings) -> UResult<Self> {
|
fn parse(key: &str, global_settings: &GlobalSettings) -> UResult<Self> {
|
||||||
let mut from_to = key.split(',');
|
let mut from_to = key.split(',');
|
||||||
let (from, from_options) = Self::split_key_options(from_to.next().unwrap());
|
let (from, from_options) = Self::split_key_options(from_to.next().unwrap());
|
||||||
let to = from_to.next().map(|to| Self::split_key_options(to));
|
let to = from_to.next().map(Self::split_key_options);
|
||||||
let options_are_empty = from_options.is_empty() && matches!(to, None | Some((_, "")));
|
let options_are_empty = from_options.is_empty() && matches!(to, None | Some((_, "")));
|
||||||
|
|
||||||
if options_are_empty {
|
if options_are_empty {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue