Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cre4ture committed Apr 27, 2024
1 parent e977134 commit fcafe66
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
12 changes: 9 additions & 3 deletions src/uu/dd/src/dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ impl Source {
fn stdin_as_file() -> Self {
let fd = io::stdin().as_raw_fd();
let f = unsafe { File::from_raw_fd(fd) };
Self{ variant: SourceVariant::StdinFile(f) }
Self {
variant: SourceVariant::StdinFile(f),
}
}

/// The length of the data source in number of bytes.
Expand Down Expand Up @@ -404,7 +406,9 @@ impl<'a> Input<'a> {
.map_err_context(|| format!("failed to open {}", filename.quote()))?
};

let mut src = Source{ variant: SourceVariant::File(src) };
let mut src = Source {
variant: SourceVariant::File(src),
};
if settings.skip > 0 {
src.skip(settings.skip)?;
}
Expand All @@ -418,7 +422,9 @@ impl<'a> Input<'a> {
opts.read(true);
#[cfg(any(target_os = "linux", target_os = "android"))]
opts.custom_flags(make_linux_iflags(&settings.iflags).unwrap_or(0));
let mut src = Source{ variant: SourceVariant::Fifo(opts.open(filename)?) };
let mut src = Source {
variant: SourceVariant::Fifo(opts.open(filename)?),
};
if settings.skip > 0 {
src.skip(settings.skip)?;
}
Expand Down
2 changes: 1 addition & 1 deletion src/uu/head/src/head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// spell-checker:ignore (vars) BUFWRITER seekable

use clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
use uucore::fs::{get_seeking_strategy, SeekingStrategy};
use std::ffi::OsString;
use std::io::{self, BufWriter, ErrorKind, Read, Seek, SeekFrom, Write};
use uucore::display::Quotable;
use uucore::error::{FromIo, UResult, USimpleError};
use uucore::fs::{get_seeking_strategy, SeekingStrategy};
use uucore::line_ending::LineEnding;
use uucore::lines::lines;
use uucore::{format_usage, help_about, help_usage, show};
Expand Down
5 changes: 3 additions & 2 deletions src/uu/tail/src/tail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ use chunks::ReverseChunks;
use follow::Observer;
use paths::{HeaderPrinter, Input, InputKind, MetadataExtTail};
use same_file::Handle;
use uucore::fs::FileExtSeekable;
use std::cmp::Ordering;
use std::fs::File;
use std::io::{self, stdin, stdout, BufRead, BufReader, BufWriter, Read, Seek, SeekFrom, Write};
use std::path::{Path, PathBuf};
use uucore::display::Quotable;
use uucore::error::{get_exit_code, set_exit_code, FromIo, UResult, USimpleError};
use uucore::fs::FileExtSeekable;
use uucore::{show, show_error};

#[uucore::main]
Expand Down Expand Up @@ -145,7 +145,8 @@ fn tail_file(
header_printer.print_input(input);
let mut reader;
if !settings.presume_input_pipe
&& file.is_seekable() && file.seek(SeekFrom::Start(offset)).is_ok()
&& file.is_seekable()
&& file.seek(SeekFrom::Start(offset)).is_ok()
&& metadata.as_ref().unwrap().get_block_size() > 0
{
bounded_tail(&mut file, settings);
Expand Down
1 change: 0 additions & 1 deletion src/uucore/src/lib/features/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,6 @@ pub fn get_seeking_strategy(input: &mut std::fs::File) -> std::io::Result<Seekin
}
}


/// Extracts the filename component from the given `file` path and returns it as an `Option<&str>`.
///
/// If the `file` path contains a filename, this function returns `Some(filename)` where `filename` is
Expand Down
11 changes: 6 additions & 5 deletions tests/by-util/test_ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,11 +1425,12 @@ fn test_ls_long_total_size() {
at.touch(at.plus_as_string("test-long2"));
at.append("test-long2", "2");

let (total_long_vanilla, total_long_human, total_long_si) = match get_allocated_size_variant(&scene, &scene.fixtures.subdir) {
AllocatedSizeVariant::Android10Plus => (16, "16.0K", "16.4k"),
AllocatedSizeVariant::F2fs4100 => (8, "8.0K", "8.2k"),
AllocatedSizeVariant::Default4096 => (8, "8.0K", "8.2k"),
};
let (total_long_vanilla, total_long_human, total_long_si) =
match get_allocated_size_variant(&scene, &scene.fixtures.subdir) {
AllocatedSizeVariant::Android10Plus => (16, "16.0K", "16.4k"),
AllocatedSizeVariant::F2fs4100 => (8, "8.0K", "8.2k"),
AllocatedSizeVariant::Default4096 => (8, "8.0K", "8.2k"),
};

let expected_prints: HashMap<_, _> = if cfg!(unix) {
[
Expand Down

0 comments on commit fcafe66

Please sign in to comment.