mirror of
https://github.com/uutils/coreutils.git
synced 2025-07-07 21:45:01 +00:00
Run cargo fmt on the tree
This commit is contained in:
parent
36dd968c9a
commit
a85539f530
189 changed files with 841 additions and 782 deletions
2
build.rs
2
build.rs
|
@ -34,7 +34,7 @@ pub fn main() {
|
|||
match krate.as_ref() {
|
||||
"default" | "macos" | "unix" | "windows" | "selinux" | "zip" => continue, // common/standard feature names
|
||||
"nightly" | "test_unimplemented" | "expensive_tests" | "test_risky_names" => {
|
||||
continue
|
||||
continue;
|
||||
} // crate-local custom features
|
||||
"uudoc" => continue, // is not a utility
|
||||
"test" => continue, // over-ridden with 'uu_test' to avoid collision with rust core crate 'test'
|
||||
|
|
|
@ -23,7 +23,9 @@ fn main() -> io::Result<()> {
|
|||
|
||||
if tldr_zip.is_none() {
|
||||
println!("Warning: No tldr archive found, so the documentation will not include examples.");
|
||||
println!("To include examples in the documentation, download the tldr archive and put it in the docs/ folder.");
|
||||
println!(
|
||||
"To include examples in the documentation, download the tldr archive and put it in the docs/ folder."
|
||||
);
|
||||
println!();
|
||||
println!(" curl https://tldr.sh/assets/tldr.zip -o docs/tldr.zip");
|
||||
println!();
|
||||
|
|
|
@ -11,8 +11,8 @@ use std::io::{self, ErrorKind, Read, Seek, SeekFrom};
|
|||
use std::path::{Path, PathBuf};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::encoding::{
|
||||
for_base_common::{BASE32, BASE32HEX, BASE64, BASE64URL, BASE64_NOPAD, HEXUPPER_PERMISSIVE},
|
||||
Format, Z85Wrapper, BASE2LSBF, BASE2MSBF,
|
||||
BASE2LSBF, BASE2MSBF, Format, Z85Wrapper,
|
||||
for_base_common::{BASE32, BASE32HEX, BASE64, BASE64_NOPAD, BASE64URL, HEXUPPER_PERMISSIVE},
|
||||
};
|
||||
use uucore::encoding::{EncodingWrapper, SupportsFastDecodeAndEncode};
|
||||
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
|
||||
|
@ -291,7 +291,7 @@ pub fn get_supports_fast_decode_and_encode(
|
|||
}
|
||||
|
||||
pub mod fast_encode {
|
||||
use crate::base_common::{format_read_error, WRAP_DEFAULT};
|
||||
use crate::base_common::{WRAP_DEFAULT, format_read_error};
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
io::{self, ErrorKind, Read, Write},
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
// spell-checker:ignore (ToDO) fullname
|
||||
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use std::path::{is_separator, PathBuf};
|
||||
use std::path::{PathBuf, is_separator};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{UResult, UUsageError};
|
||||
use uucore::line_ending::LineEnding;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
// spell-checker:ignore lsbf msbf
|
||||
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use uu_base32::base_common::{self, Config, BASE_CMD_PARSE_ERROR};
|
||||
use uu_base32::base_common::{self, BASE_CMD_PARSE_ERROR, Config};
|
||||
use uucore::error::UClapError;
|
||||
use uucore::{
|
||||
encoding::Format,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// file that was distributed with this source code.
|
||||
|
||||
// spell-checker:ignore (ToDO) nonprint nonblank nonprinting ELOOP
|
||||
use std::fs::{metadata, File};
|
||||
use std::fs::{File, metadata};
|
||||
use std::io::{self, BufWriter, IsTerminal, Read, Write};
|
||||
/// Unix domain socket support
|
||||
#[cfg(unix)]
|
||||
|
@ -18,7 +18,7 @@ use std::os::unix::net::UnixStream;
|
|||
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
#[cfg(unix)]
|
||||
use nix::fcntl::{fcntl, FcntlArg};
|
||||
use nix::fcntl::{FcntlArg, fcntl};
|
||||
use thiserror::Error;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::UResult;
|
||||
|
@ -83,19 +83,11 @@ struct OutputOptions {
|
|||
|
||||
impl OutputOptions {
|
||||
fn tab(&self) -> &'static str {
|
||||
if self.show_tabs {
|
||||
"^I"
|
||||
} else {
|
||||
"\t"
|
||||
}
|
||||
if self.show_tabs { "^I" } else { "\t" }
|
||||
}
|
||||
|
||||
fn end_of_line(&self) -> &'static str {
|
||||
if self.show_ends {
|
||||
"$\n"
|
||||
} else {
|
||||
"\n"
|
||||
}
|
||||
if self.show_ends { "$\n" } else { "\n" }
|
||||
}
|
||||
|
||||
/// We can write fast if we can simply copy the contents of the file to
|
||||
|
@ -694,7 +686,7 @@ fn write_end_of_line<W: Write>(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::io::{stdout, BufWriter};
|
||||
use std::io::{BufWriter, stdout};
|
||||
|
||||
#[test]
|
||||
fn test_write_nonprint_to_end_new_line() {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
use uucore::display::Quotable;
|
||||
pub use uucore::entries;
|
||||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
use uucore::perms::{chown_base, options, GidUidOwnerFilter, IfFrom};
|
||||
use uucore::perms::{GidUidOwnerFilter, IfFrom, chown_base, options};
|
||||
use uucore::{format_usage, help_about, help_usage};
|
||||
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
|
@ -76,7 +76,7 @@ fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
|
|||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("invalid user: '{}'", from_group),
|
||||
))
|
||||
));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -11,12 +11,12 @@ use std::fs;
|
|||
use std::os::unix::fs::{MetadataExt, PermissionsExt};
|
||||
use std::path::Path;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, ExitCode, UResult, USimpleError, UUsageError};
|
||||
use uucore::error::{ExitCode, UResult, USimpleError, UUsageError, set_exit_code};
|
||||
use uucore::fs::display_permissions_unix;
|
||||
use uucore::libc::mode_t;
|
||||
#[cfg(not(windows))]
|
||||
use uucore::mode;
|
||||
use uucore::perms::{configure_symlink_and_recursion, TraverseSymlinks};
|
||||
use uucore::perms::{TraverseSymlinks, configure_symlink_and_recursion};
|
||||
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error};
|
||||
|
||||
const ABOUT: &str = help_about!("chmod.md");
|
||||
|
@ -107,7 +107,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("cannot stat attributes of {}: {}", fref.quote(), err),
|
||||
))
|
||||
));
|
||||
}
|
||||
},
|
||||
None => None,
|
||||
|
@ -298,7 +298,7 @@ impl Chmoder {
|
|||
format!(
|
||||
"it is dangerous to operate recursively on {}\nchmod: use --no-preserve-root to override this failsafe",
|
||||
filename.quote()
|
||||
)
|
||||
),
|
||||
));
|
||||
}
|
||||
if self.recursive {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
use uucore::display::Quotable;
|
||||
pub use uucore::entries::{self, Group, Locate, Passwd};
|
||||
use uucore::perms::{chown_base, options, GidUidOwnerFilter, IfFrom};
|
||||
use uucore::perms::{GidUidOwnerFilter, IfFrom, chown_base, options};
|
||||
use uucore::{format_usage, help_about, help_usage};
|
||||
|
||||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
|
|
|
@ -13,9 +13,9 @@ use std::io::Error;
|
|||
use std::os::unix::prelude::OsStrExt;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process;
|
||||
use uucore::entries::{grp2gid, usr2uid, Locate, Passwd};
|
||||
use uucore::error::{set_exit_code, UClapError, UResult, UUsageError};
|
||||
use uucore::fs::{canonicalize, MissingHandling, ResolveMode};
|
||||
use uucore::entries::{Locate, Passwd, grp2gid, usr2uid};
|
||||
use uucore::error::{UClapError, UResult, UUsageError, set_exit_code};
|
||||
use uucore::fs::{MissingHandling, ResolveMode, canonicalize};
|
||||
use uucore::libc::{self, chroot, setgid, setgroups, setuid};
|
||||
use uucore::{format_usage, help_about, help_usage, show};
|
||||
|
||||
|
@ -224,7 +224,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
} else {
|
||||
ChrootError::CommandFailed(command[0].to_string(), e)
|
||||
}
|
||||
.into())
|
||||
.into());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
|
||||
// spell-checker:ignore (ToDO) fname, algo
|
||||
use clap::builder::ValueParser;
|
||||
use clap::{value_parser, Arg, ArgAction, Command};
|
||||
use clap::{Arg, ArgAction, Command, value_parser};
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::fs::File;
|
||||
use std::io::{self, stdin, stdout, BufReader, Read, Write};
|
||||
use std::io::{self, BufReader, Read, Write, stdin, stdout};
|
||||
use std::iter;
|
||||
use std::path::Path;
|
||||
use uucore::checksum::{
|
||||
calculate_blake2b_length, detect_algo, digest_reader, perform_checksum_validation,
|
||||
ChecksumError, ChecksumOptions, ChecksumVerbose, ALGORITHM_OPTIONS_BLAKE2B,
|
||||
ALGORITHM_OPTIONS_BSD, ALGORITHM_OPTIONS_CRC, ALGORITHM_OPTIONS_CRC32B, ALGORITHM_OPTIONS_SYSV,
|
||||
SUPPORTED_ALGORITHMS,
|
||||
ALGORITHM_OPTIONS_BLAKE2B, ALGORITHM_OPTIONS_BSD, ALGORITHM_OPTIONS_CRC,
|
||||
ALGORITHM_OPTIONS_CRC32B, ALGORITHM_OPTIONS_SYSV, ChecksumError, ChecksumOptions,
|
||||
ChecksumVerbose, SUPPORTED_ALGORITHMS, calculate_blake2b_length, detect_algo, digest_reader,
|
||||
perform_checksum_validation,
|
||||
};
|
||||
use uucore::{
|
||||
encoding,
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
// spell-checker:ignore (ToDO) delim mkdelim pairable
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::fs::{metadata, File};
|
||||
use std::io::{self, stdin, BufRead, BufReader, Read, Stdin};
|
||||
use std::fs::{File, metadata};
|
||||
use std::io::{self, BufRead, BufReader, Read, Stdin, stdin};
|
||||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
use uucore::fs::paths_refer_to_same_file;
|
||||
use uucore::line_ending::LineEnding;
|
||||
|
|
|
@ -18,7 +18,7 @@ use indicatif::ProgressBar;
|
|||
use uucore::display::Quotable;
|
||||
use uucore::error::UIoError;
|
||||
use uucore::fs::{
|
||||
canonicalize, path_ends_with_terminator, FileInformation, MissingHandling, ResolveMode,
|
||||
FileInformation, MissingHandling, ResolveMode, canonicalize, path_ends_with_terminator,
|
||||
};
|
||||
use uucore::show;
|
||||
use uucore::show_error;
|
||||
|
@ -26,8 +26,8 @@ use uucore::uio_error;
|
|||
use walkdir::{DirEntry, WalkDir};
|
||||
|
||||
use crate::{
|
||||
aligned_ancestors, context_for, copy_attributes, copy_file, copy_link, CopyResult, Error,
|
||||
Options,
|
||||
CopyResult, Error, Options, aligned_ancestors, context_for, copy_attributes, copy_file,
|
||||
copy_link,
|
||||
};
|
||||
|
||||
/// Ensure a Windows path starts with a `\\?`.
|
||||
|
|
|
@ -20,7 +20,7 @@ use std::path::{Path, PathBuf, StripPrefixError};
|
|||
#[cfg(all(unix, not(target_os = "android")))]
|
||||
use uucore::fsxattr::copy_xattrs;
|
||||
|
||||
use clap::{builder::ValueParser, Arg, ArgAction, ArgMatches, Command};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command, builder::ValueParser};
|
||||
use filetime::FileTime;
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
#[cfg(unix)]
|
||||
|
@ -29,11 +29,11 @@ use quick_error::ResultExt;
|
|||
|
||||
use platform::copy_on_write;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, UClapError, UError, UResult, UUsageError};
|
||||
use uucore::error::{UClapError, UError, UResult, UUsageError, set_exit_code};
|
||||
use uucore::fs::{
|
||||
are_hardlinks_to_same_file, canonicalize, get_filename, is_symlink_loop, normalize_path,
|
||||
path_ends_with_terminator, paths_refer_to_same_file, FileInformation, MissingHandling,
|
||||
ResolveMode,
|
||||
FileInformation, MissingHandling, ResolveMode, are_hardlinks_to_same_file, canonicalize,
|
||||
get_filename, is_symlink_loop, normalize_path, path_ends_with_terminator,
|
||||
paths_refer_to_same_file,
|
||||
};
|
||||
use uucore::{backup_control, update_control};
|
||||
// These are exposed for projects (e.g. nushell) that want to create an `Options` value, which
|
||||
|
@ -1498,7 +1498,7 @@ fn file_mode_for_interactive_overwrite(
|
|||
{
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use libc::{mode_t, S_IWUSR};
|
||||
use libc::{S_IWUSR, mode_t};
|
||||
use std::os::unix::prelude::MetadataExt;
|
||||
|
||||
match path.metadata() {
|
||||
|
@ -1631,9 +1631,9 @@ pub(crate) fn copy_attributes(
|
|||
#[cfg(unix)]
|
||||
handle_preserve(&attributes.ownership, || -> CopyResult<()> {
|
||||
use std::os::unix::prelude::MetadataExt;
|
||||
use uucore::perms::wrap_chown;
|
||||
use uucore::perms::Verbosity;
|
||||
use uucore::perms::VerbosityLevel;
|
||||
use uucore::perms::wrap_chown;
|
||||
|
||||
let dest_uid = source_metadata.uid();
|
||||
let dest_gid = source_metadata.gid();
|
||||
|
@ -2627,7 +2627,7 @@ fn disk_usage_directory(p: &Path) -> io::Result<u64> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use crate::{aligned_ancestors, localize_to_target, Attributes, Preserve};
|
||||
use crate::{Attributes, Preserve, aligned_ancestors, localize_to_target};
|
||||
use std::path::Path;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -340,7 +340,7 @@ pub(crate) fn copy_on_write(
|
|||
}
|
||||
(ReflinkMode::Auto, SparseMode::Always) => {
|
||||
copy_debug.sparse_detection = SparseDebug::Zeros; // Default SparseDebug val for
|
||||
// SparseMode::Always
|
||||
// SparseMode::Always
|
||||
if source_is_stream {
|
||||
copy_debug.offload = OffloadReflinkDebug::Avoided;
|
||||
copy_stream(source, dest, source_is_fifo).map(|_| ())
|
||||
|
@ -401,7 +401,7 @@ pub(crate) fn copy_on_write(
|
|||
clone(source, dest, CloneFallback::Error)
|
||||
}
|
||||
(ReflinkMode::Always, _) => {
|
||||
return Err("`--reflink=always` can be used only with --sparse=auto".into())
|
||||
return Err("`--reflink=always` can be used only with --sparse=auto".into());
|
||||
}
|
||||
};
|
||||
result.context(context)?;
|
||||
|
@ -524,7 +524,7 @@ fn handle_reflink_auto_sparse_auto(
|
|||
} else {
|
||||
copy_method = CopyMethod::SparseCopyWithoutHole;
|
||||
} // Since sparse_flag is true, sparse_detection shall be SeekHole for any non virtual
|
||||
// regular sparse file and the file will be sparsely copied
|
||||
// regular sparse file and the file will be sparsely copied
|
||||
copy_debug.sparse_detection = SparseDebug::SeekHole;
|
||||
}
|
||||
|
||||
|
@ -557,7 +557,7 @@ fn handle_reflink_never_sparse_auto(
|
|||
if sparse_flag {
|
||||
if blocks == 0 && data_flag {
|
||||
copy_method = CopyMethod::FSCopy; // Handles virtual files which have size > 0 but no
|
||||
// disk allocation
|
||||
// disk allocation
|
||||
} else {
|
||||
copy_method = CopyMethod::SparseCopyWithoutHole; // Handles regular sparse-files
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ pub(crate) fn copy_on_write(
|
|||
// support COW).
|
||||
match reflink_mode {
|
||||
ReflinkMode::Always => {
|
||||
return Err(format!("failed to clone {source:?} from {dest:?}: {error}").into())
|
||||
return Err(format!("failed to clone {source:?} from {dest:?}: {error}").into());
|
||||
}
|
||||
_ => {
|
||||
copy_debug.reflink = OffloadReflinkDebug::Yes;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
use std::cmp::Ordering;
|
||||
use std::io::{self, BufReader};
|
||||
use std::{
|
||||
fs::{remove_file, File},
|
||||
fs::{File, remove_file},
|
||||
io::{BufRead, BufWriter, Write},
|
||||
};
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (regex) diuox
|
||||
|
||||
use uucore::format::{num_format::UnsignedInt, Format, FormatError};
|
||||
use uucore::format::{Format, FormatError, num_format::UnsignedInt};
|
||||
|
||||
use crate::csplit_error::CsplitError;
|
||||
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
// spell-checker:ignore (ToDO) delim sourcefiles
|
||||
|
||||
use bstr::io::BufReadExt;
|
||||
use clap::{builder::ValueParser, Arg, ArgAction, ArgMatches, Command};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command, builder::ValueParser};
|
||||
use std::ffi::OsString;
|
||||
use std::fs::File;
|
||||
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, IsTerminal, Read, Write};
|
||||
use std::io::{BufRead, BufReader, BufWriter, IsTerminal, Read, Write, stdin, stdout};
|
||||
use std::path::Path;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, FromIo, UResult, USimpleError};
|
||||
use uucore::error::{FromIo, UResult, USimpleError, set_exit_code};
|
||||
use uucore::line_ending::LineEnding;
|
||||
use uucore::os_str_as_bytes;
|
||||
|
||||
|
@ -370,16 +370,18 @@ fn cut_files(mut filenames: Vec<String>, mode: &Mode) {
|
|||
continue;
|
||||
}
|
||||
|
||||
show_if_err!(File::open(path)
|
||||
.map_err_context(|| filename.maybe_quote().to_string())
|
||||
.and_then(|file| {
|
||||
match &mode {
|
||||
Mode::Bytes(ranges, opts) | Mode::Characters(ranges, opts) => {
|
||||
cut_bytes(file, ranges, opts)
|
||||
show_if_err!(
|
||||
File::open(path)
|
||||
.map_err_context(|| filename.maybe_quote().to_string())
|
||||
.and_then(|file| {
|
||||
match &mode {
|
||||
Mode::Bytes(ranges, opts) | Mode::Characters(ranges, opts) => {
|
||||
cut_bytes(file, ranges, opts)
|
||||
}
|
||||
Mode::Fields(ranges, opts) => cut_fields(file, ranges, opts),
|
||||
}
|
||||
Mode::Fields(ranges, opts) => cut_fields(file, ranges, opts),
|
||||
}
|
||||
}));
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use chrono::{DateTime, FixedOffset, Local, Offset, TimeDelta, Utc};
|
|||
use chrono::{Datelike, Timelike};
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
|
||||
use libc::{clock_settime, timespec, CLOCK_REALTIME};
|
||||
use libc::{CLOCK_REALTIME, clock_settime, timespec};
|
||||
use std::fs::File;
|
||||
use std::io::{BufRead, BufReader};
|
||||
use std::path::PathBuf;
|
||||
|
|
|
@ -22,7 +22,7 @@ use nix::fcntl::FcntlArg::F_SETFL;
|
|||
use nix::fcntl::OFlag;
|
||||
use parseargs::Parser;
|
||||
use progress::ProgUpdateType;
|
||||
use progress::{gen_prog_updater, ProgUpdate, ReadStat, StatusLevel, WriteStat};
|
||||
use progress::{ProgUpdate, ReadStat, StatusLevel, WriteStat, gen_prog_updater};
|
||||
use uucore::io::OwnedFileDescriptorOrHandle;
|
||||
|
||||
use std::cmp;
|
||||
|
@ -41,7 +41,7 @@ use std::os::unix::{
|
|||
use std::os::windows::{fs::MetadataExt, io::AsHandle};
|
||||
use std::path::Path;
|
||||
use std::sync::atomic::AtomicU8;
|
||||
use std::sync::{atomic::Ordering::Relaxed, mpsc, Arc};
|
||||
use std::sync::{Arc, atomic::Ordering::Relaxed, mpsc};
|
||||
use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
|
@ -50,12 +50,12 @@ use gcd::Gcd;
|
|||
#[cfg(target_os = "linux")]
|
||||
use nix::{
|
||||
errno::Errno,
|
||||
fcntl::{posix_fadvise, PosixFadviseAdvice},
|
||||
fcntl::{PosixFadviseAdvice, posix_fadvise},
|
||||
};
|
||||
use uucore::display::Quotable;
|
||||
#[cfg(unix)]
|
||||
use uucore::error::{set_exit_code, USimpleError};
|
||||
use uucore::error::{FromIo, UResult};
|
||||
#[cfg(unix)]
|
||||
use uucore::error::{USimpleError, set_exit_code};
|
||||
#[cfg(target_os = "linux")]
|
||||
use uucore::show_if_err;
|
||||
use uucore::{format_usage, help_about, help_section, help_usage, show_error};
|
||||
|
@ -417,11 +417,7 @@ fn make_linux_iflags(iflags: &IFlags) -> Option<libc::c_int> {
|
|||
flag |= libc::O_SYNC;
|
||||
}
|
||||
|
||||
if flag == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(flag)
|
||||
}
|
||||
if flag == 0 { None } else { Some(flag) }
|
||||
}
|
||||
|
||||
impl Read for Input<'_> {
|
||||
|
@ -832,10 +828,9 @@ impl<'a> Output<'a> {
|
|||
fn discard_cache(&self, offset: libc::off_t, len: libc::off_t) {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
show_if_err!(self
|
||||
.dst
|
||||
.discard_cache(offset, len)
|
||||
.map_err_context(|| "failed to discard cache for: 'standard output'".to_string()));
|
||||
show_if_err!(self.dst.discard_cache(offset, len).map_err_context(|| {
|
||||
"failed to discard cache for: 'standard output'".to_string()
|
||||
}));
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
|
@ -1241,11 +1236,7 @@ fn make_linux_oflags(oflags: &OFlags) -> Option<libc::c_int> {
|
|||
flag |= libc::O_SYNC;
|
||||
}
|
||||
|
||||
if flag == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(flag)
|
||||
}
|
||||
if flag == 0 { None } else { Some(flag) }
|
||||
}
|
||||
|
||||
/// Read from an input (that is, a source of bytes) into the given buffer.
|
||||
|
@ -1441,7 +1432,7 @@ pub fn uu_app() -> Command {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{calc_bsize, Output, Parser};
|
||||
use crate::{Output, Parser, calc_bsize};
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ pub(crate) fn to_magnitude_and_suffix(n: u128, suffix_type: SuffixType) -> Strin
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use crate::numbers::{to_magnitude_and_suffix, SuffixType};
|
||||
use crate::numbers::{SuffixType, to_magnitude_and_suffix};
|
||||
|
||||
#[test]
|
||||
fn test_to_magnitude_and_suffix_powers_of_1024() {
|
||||
|
|
|
@ -630,8 +630,8 @@ fn conversion_mode(
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use crate::parseargs::{parse_bytes_with_opt_multiplier, Parser};
|
||||
use crate::Num;
|
||||
use crate::parseargs::{Parser, parse_bytes_with_opt_multiplier};
|
||||
use std::matches;
|
||||
const BIG: &str = "9999999999999999999999999999999999999999999999999999999999999";
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
use super::*;
|
||||
|
||||
use crate::StatusLevel;
|
||||
use crate::conversion_tables::{
|
||||
ASCII_TO_EBCDIC_UCASE_TO_LCASE, ASCII_TO_IBM, EBCDIC_TO_ASCII_LCASE_TO_UCASE,
|
||||
};
|
||||
use crate::parseargs::Parser;
|
||||
use crate::StatusLevel;
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||
#[allow(clippy::useless_vec)]
|
||||
|
@ -341,7 +341,9 @@ fn parse_icf_tokens_elu() {
|
|||
|
||||
#[test]
|
||||
fn parse_icf_tokens_remaining() {
|
||||
let args = &["conv=ascii,ucase,block,sparse,swab,sync,noerror,excl,nocreat,notrunc,noerror,fdatasync,fsync"];
|
||||
let args = &[
|
||||
"conv=ascii,ucase,block,sparse,swab,sync,noerror,excl,nocreat,notrunc,noerror,fdatasync,fsync",
|
||||
];
|
||||
assert_eq!(
|
||||
Parser::new().read(args),
|
||||
Ok(Parser {
|
||||
|
|
|
@ -22,7 +22,7 @@ use uucore::{
|
|||
format::num_format::{FloatVariant, Formatter},
|
||||
};
|
||||
|
||||
use crate::numbers::{to_magnitude_and_suffix, SuffixType};
|
||||
use crate::numbers::{SuffixType, to_magnitude_and_suffix};
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub(crate) enum ProgUpdateType {
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::{env, fmt};
|
|||
|
||||
use uucore::{
|
||||
display::Quotable,
|
||||
parse_size::{parse_size_u64, ParseSizeError},
|
||||
parse_size::{ParseSizeError, parse_size_u64},
|
||||
};
|
||||
|
||||
/// The first ten powers of 1024.
|
||||
|
@ -216,7 +216,7 @@ mod tests {
|
|||
|
||||
use std::env;
|
||||
|
||||
use crate::blocks::{to_magnitude_and_suffix, BlockSize, SuffixType};
|
||||
use crate::blocks::{BlockSize, SuffixType, to_magnitude_and_suffix};
|
||||
|
||||
#[test]
|
||||
fn test_to_magnitude_and_suffix_powers_of_1024() {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore itotal iused iavail ipcent pcent squashfs
|
||||
use crate::{OPT_INODES, OPT_OUTPUT, OPT_PRINT_TYPE};
|
||||
use clap::{parser::ValueSource, ArgMatches};
|
||||
use clap::{ArgMatches, parser::ValueSource};
|
||||
|
||||
/// The columns in the output table produced by `df`.
|
||||
///
|
||||
|
|
|
@ -13,18 +13,18 @@ use clap::builder::ValueParser;
|
|||
use table::HeaderMode;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{UError, UResult, USimpleError};
|
||||
use uucore::fsext::{read_fs_list, MountInfo};
|
||||
use uucore::fsext::{MountInfo, read_fs_list};
|
||||
use uucore::parse_size::ParseSizeError;
|
||||
use uucore::{format_usage, help_about, help_section, help_usage, show};
|
||||
|
||||
use clap::{parser::ValueSource, Arg, ArgAction, ArgMatches, Command};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command, parser::ValueSource};
|
||||
|
||||
use std::error::Error;
|
||||
use std::ffi::OsString;
|
||||
use std::fmt;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::blocks::{read_block_size, BlockSize};
|
||||
use crate::blocks::{BlockSize, read_block_size};
|
||||
use crate::columns::{Column, ColumnError};
|
||||
use crate::filesystem::Filesystem;
|
||||
use crate::filesystem::FsError;
|
||||
|
@ -749,7 +749,7 @@ mod tests {
|
|||
|
||||
mod is_included {
|
||||
|
||||
use crate::{is_included, Options};
|
||||
use crate::{Options, is_included};
|
||||
use uucore::fsext::MountInfo;
|
||||
|
||||
/// Instantiate a [`MountInfo`] with the given fields.
|
||||
|
@ -886,7 +886,7 @@ mod tests {
|
|||
|
||||
mod filter_mount_list {
|
||||
|
||||
use crate::{filter_mount_list, Options};
|
||||
use crate::{Options, filter_mount_list};
|
||||
|
||||
#[test]
|
||||
fn test_empty() {
|
||||
|
|
|
@ -207,7 +207,7 @@ mod tests {
|
|||
|
||||
use uucore::fsext::MountInfo;
|
||||
|
||||
use crate::filesystem::{mount_info_from_path, FsError};
|
||||
use crate::filesystem::{FsError, mount_info_from_path};
|
||||
|
||||
// Create a fake `MountInfo` with the given directory name.
|
||||
fn mount_info(mount_dir: &str) -> MountInfo {
|
||||
|
@ -312,7 +312,7 @@ mod tests {
|
|||
|
||||
#[cfg(not(windows))]
|
||||
mod over_mount {
|
||||
use crate::filesystem::{is_over_mounted, Filesystem, FsError};
|
||||
use crate::filesystem::{Filesystem, FsError, is_over_mounted};
|
||||
use uucore::fsext::MountInfo;
|
||||
|
||||
fn mount_info_with_dev_name(mount_dir: &str, dev_name: Option<&str>) -> MountInfo {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
//! collection of data rows ([`Row`]), one per filesystem.
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use crate::blocks::{to_magnitude_and_suffix, SuffixType};
|
||||
use crate::blocks::{SuffixType, to_magnitude_and_suffix};
|
||||
use crate::columns::{Alignment, Column};
|
||||
use crate::filesystem::Filesystem;
|
||||
use crate::{BlockSize, Options};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
use clap::Command;
|
||||
use std::ffi::OsString;
|
||||
use std::path::Path;
|
||||
use uu_ls::{options, Config, Format};
|
||||
use uu_ls::{Config, Format, options};
|
||||
use uucore::error::UResult;
|
||||
use uucore::quoting_style::{Quotes, QuotingStyle};
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// file that was distributed with this source code.
|
||||
|
||||
use chrono::{DateTime, Local};
|
||||
use clap::{builder::PossibleValue, Arg, ArgAction, ArgMatches, Command};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command, builder::PossibleValue};
|
||||
use glob::Pattern;
|
||||
use std::collections::HashSet;
|
||||
use std::env;
|
||||
|
@ -24,19 +24,19 @@ use std::sync::mpsc;
|
|||
use std::thread;
|
||||
use std::time::{Duration, UNIX_EPOCH};
|
||||
use thiserror::Error;
|
||||
use uucore::display::{print_verbatim, Quotable};
|
||||
use uucore::error::{set_exit_code, FromIo, UError, UResult, USimpleError};
|
||||
use uucore::display::{Quotable, print_verbatim};
|
||||
use uucore::error::{FromIo, UError, UResult, USimpleError, set_exit_code};
|
||||
use uucore::line_ending::LineEnding;
|
||||
use uucore::parse_glob;
|
||||
use uucore::parse_size::{parse_size_u64, ParseSizeError};
|
||||
use uucore::parse_size::{ParseSizeError, parse_size_u64};
|
||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
||||
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error, show_warning};
|
||||
#[cfg(windows)]
|
||||
use windows_sys::Win32::Foundation::HANDLE;
|
||||
#[cfg(windows)]
|
||||
use windows_sys::Win32::Storage::FileSystem::{
|
||||
FileIdInfo, FileStandardInfo, GetFileInformationByHandleEx, FILE_ID_128, FILE_ID_INFO,
|
||||
FILE_STANDARD_INFO,
|
||||
FILE_ID_128, FILE_ID_INFO, FILE_STANDARD_INFO, FileIdInfo, FileStandardInfo,
|
||||
GetFileInformationByHandleEx,
|
||||
};
|
||||
|
||||
mod options {
|
||||
|
@ -593,7 +593,7 @@ fn read_files_from(file_name: &str) -> Result<Vec<PathBuf>, std::io::Error> {
|
|||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
format!("cannot open '{file_name}' for reading: No such file or directory"),
|
||||
))
|
||||
));
|
||||
}
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::env;
|
|||
use std::ffi::{OsStr, OsString};
|
||||
use std::io::{self, StdoutLock, Write};
|
||||
use uucore::error::{UResult, USimpleError};
|
||||
use uucore::format::{parse_escape_only, EscapedChar, FormatChar, OctalParsing};
|
||||
use uucore::format::{EscapedChar, FormatChar, OctalParsing, parse_escape_only};
|
||||
use uucore::{format_usage, help_about, help_section, help_usage};
|
||||
|
||||
const ABOUT: &str = help_about!("echo.md");
|
||||
|
|
6
src/uu/env/src/env.rs
vendored
6
src/uu/env/src/env.rs
vendored
|
@ -13,14 +13,14 @@ pub mod string_parser;
|
|||
pub mod variable_parser;
|
||||
|
||||
use clap::builder::ValueParser;
|
||||
use clap::{crate_name, Arg, ArgAction, Command};
|
||||
use clap::{Arg, ArgAction, Command, crate_name};
|
||||
use ini::Ini;
|
||||
use native_int_str::{
|
||||
from_native_int_representation_owned, Convert, NCvt, NativeIntStr, NativeIntString, NativeStr,
|
||||
Convert, NCvt, NativeIntStr, NativeIntString, NativeStr, from_native_int_representation_owned,
|
||||
};
|
||||
#[cfg(unix)]
|
||||
use nix::sys::signal::{
|
||||
raise, sigaction, signal, SaFlags, SigAction, SigHandler, SigHandler::SigIgn, SigSet, Signal,
|
||||
SaFlags, SigAction, SigHandler, SigHandler::SigIgn, SigSet, Signal, raise, sigaction, signal,
|
||||
};
|
||||
use std::borrow::Cow;
|
||||
use std::env;
|
||||
|
|
16
src/uu/env/src/native_int_str.rs
vendored
16
src/uu/env/src/native_int_str.rs
vendored
|
@ -19,10 +19,10 @@ use std::os::unix::ffi::{OsStrExt, OsStringExt};
|
|||
use std::os::windows::prelude::*;
|
||||
use std::{borrow::Cow, ffi::OsStr};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use u16 as NativeIntCharU;
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
use u8 as NativeIntCharU;
|
||||
#[cfg(target_os = "windows")]
|
||||
use u16 as NativeIntCharU;
|
||||
|
||||
pub type NativeCharInt = NativeIntCharU;
|
||||
pub type NativeIntStr = [NativeCharInt];
|
||||
|
@ -178,22 +178,14 @@ pub fn get_single_native_int_value(c: &char) -> Option<NativeCharInt> {
|
|||
{
|
||||
let mut buf = [0u16, 0];
|
||||
let s = c.encode_utf16(&mut buf);
|
||||
if s.len() == 1 {
|
||||
Some(buf[0])
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if s.len() == 1 { Some(buf[0]) } else { None }
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
{
|
||||
let mut buf = [0u8, 0, 0, 0];
|
||||
let s = c.encode_utf8(&mut buf);
|
||||
if s.len() == 1 {
|
||||
Some(buf[0])
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if s.len() == 1 { Some(buf[0]) } else { None }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
6
src/uu/env/src/split_iterator.rs
vendored
6
src/uu/env/src/split_iterator.rs
vendored
|
@ -20,10 +20,10 @@
|
|||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::native_int_str::from_native_int_representation;
|
||||
use crate::native_int_str::NativeCharInt;
|
||||
use crate::native_int_str::NativeIntStr;
|
||||
use crate::native_int_str::NativeIntString;
|
||||
use crate::native_int_str::from_native_int_representation;
|
||||
use crate::parse_error::ParseError;
|
||||
use crate::string_expander::StringExpander;
|
||||
use crate::string_parser::StringParser;
|
||||
|
@ -256,7 +256,7 @@ impl<'a> SplitIterator<'a> {
|
|||
return Err(ParseError::MissingClosingQuote {
|
||||
pos: self.get_parser().get_peek_position(),
|
||||
c: '\'',
|
||||
})
|
||||
});
|
||||
}
|
||||
Some(SINGLE_QUOTES) => {
|
||||
self.skip_one()?;
|
||||
|
@ -306,7 +306,7 @@ impl<'a> SplitIterator<'a> {
|
|||
return Err(ParseError::MissingClosingQuote {
|
||||
pos: self.get_parser().get_peek_position(),
|
||||
c: '"',
|
||||
})
|
||||
});
|
||||
}
|
||||
Some(DOLLAR) => {
|
||||
self.substitute_variable()?;
|
||||
|
|
2
src/uu/env/src/string_expander.rs
vendored
2
src/uu/env/src/string_expander.rs
vendored
|
@ -10,7 +10,7 @@ use std::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
native_int_str::{to_native_int_representation, NativeCharInt, NativeIntStr},
|
||||
native_int_str::{NativeCharInt, NativeIntStr, to_native_int_representation},
|
||||
string_parser::{Chunk, Error, StringParser},
|
||||
};
|
||||
|
||||
|
|
4
src/uu/env/src/string_parser.rs
vendored
4
src/uu/env/src/string_parser.rs
vendored
|
@ -9,8 +9,8 @@
|
|||
use std::{borrow::Cow, ffi::OsStr};
|
||||
|
||||
use crate::native_int_str::{
|
||||
from_native_int_representation, get_char_from_native_int, get_single_native_int_value,
|
||||
NativeCharInt, NativeIntStr,
|
||||
NativeCharInt, NativeIntStr, from_native_int_representation, get_char_from_native_int,
|
||||
get_single_native_int_value,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
|
|
36
src/uu/env/src/variable_parser.rs
vendored
36
src/uu/env/src/variable_parser.rs
vendored
|
@ -21,7 +21,10 @@ impl<'a> VariableParser<'a, '_> {
|
|||
if c.is_ascii_digit() {
|
||||
return Err(ParseError::ParsingOfVariableNameFailed {
|
||||
pos: self.parser.get_peek_position(),
|
||||
msg: format!("Unexpected character: '{c}', expected variable name must not start with 0..9") });
|
||||
msg: format!(
|
||||
"Unexpected character: '{c}', expected variable name must not start with 0..9"
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -44,8 +47,10 @@ impl<'a> VariableParser<'a, '_> {
|
|||
match self.get_current_char() {
|
||||
None => {
|
||||
return Err(ParseError::ParsingOfVariableNameFailed {
|
||||
pos: self.parser.get_peek_position(), msg: "Missing closing brace".into() })
|
||||
},
|
||||
pos: self.parser.get_peek_position(),
|
||||
msg: "Missing closing brace".into(),
|
||||
});
|
||||
}
|
||||
Some(c) if !c.is_ascii() || c.is_ascii_alphanumeric() || c == '_' => {
|
||||
self.skip_one()?;
|
||||
}
|
||||
|
@ -56,32 +61,35 @@ impl<'a> VariableParser<'a, '_> {
|
|||
None => {
|
||||
return Err(ParseError::ParsingOfVariableNameFailed {
|
||||
pos: self.parser.get_peek_position(),
|
||||
msg: "Missing closing brace after default value".into() })
|
||||
},
|
||||
msg: "Missing closing brace after default value".into(),
|
||||
});
|
||||
}
|
||||
Some('}') => {
|
||||
default_end = Some(self.parser.get_peek_position());
|
||||
self.skip_one()?;
|
||||
break
|
||||
},
|
||||
break;
|
||||
}
|
||||
Some(_) => {
|
||||
self.skip_one()?;
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
},
|
||||
}
|
||||
Some('}') => {
|
||||
varname_end = self.parser.get_peek_position();
|
||||
default_end = None;
|
||||
self.skip_one()?;
|
||||
break;
|
||||
},
|
||||
}
|
||||
Some(c) => {
|
||||
return Err(ParseError::ParsingOfVariableNameFailed {
|
||||
pos: self.parser.get_peek_position(),
|
||||
msg: format!("Unexpected character: '{c}', expected a closing brace ('}}') or colon (':')")
|
||||
})
|
||||
},
|
||||
msg: format!(
|
||||
"Unexpected character: '{c}', expected a closing brace ('}}') or colon (':')"
|
||||
),
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -144,7 +152,7 @@ impl<'a> VariableParser<'a, '_> {
|
|||
return Err(ParseError::ParsingOfVariableNameFailed {
|
||||
pos: self.parser.get_peek_position(),
|
||||
msg: "missing variable name".into(),
|
||||
})
|
||||
});
|
||||
}
|
||||
Some('{') => {
|
||||
self.skip_one()?;
|
||||
|
|
|
@ -10,13 +10,13 @@ use std::error::Error;
|
|||
use std::ffi::OsString;
|
||||
use std::fmt;
|
||||
use std::fs::File;
|
||||
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write};
|
||||
use std::io::{BufRead, BufReader, BufWriter, Read, Write, stdin, stdout};
|
||||
use std::num::IntErrorKind;
|
||||
use std::path::Path;
|
||||
use std::str::from_utf8;
|
||||
use unicode_width::UnicodeWidthChar;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, FromIo, UError, UResult};
|
||||
use uucore::error::{FromIo, UError, UResult, set_exit_code};
|
||||
use uucore::{format_usage, help_about, help_usage, show_error};
|
||||
|
||||
const ABOUT: &str = help_about!("expand.md");
|
||||
|
@ -496,8 +496,8 @@ fn expand(options: &Options) -> UResult<()> {
|
|||
mod tests {
|
||||
use crate::is_digit_or_comma;
|
||||
|
||||
use super::next_tabstop;
|
||||
use super::RemainingMode;
|
||||
use super::next_tabstop;
|
||||
|
||||
#[test]
|
||||
fn test_next_tabstop_remaining_mode_none() {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// file that was distributed with this source code.
|
||||
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use syntax_tree::{is_truthy, AstNode};
|
||||
use syntax_tree::{AstNode, is_truthy};
|
||||
use thiserror::Error;
|
||||
use uucore::{
|
||||
display::Quotable,
|
||||
|
|
|
@ -87,11 +87,7 @@ impl RelationOp {
|
|||
Self::Geq => a >= b,
|
||||
}
|
||||
};
|
||||
if b {
|
||||
Ok(1.into())
|
||||
} else {
|
||||
Ok(0.into())
|
||||
}
|
||||
if b { Ok(1.into()) } else { Ok(0.into()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -697,8 +693,8 @@ mod test {
|
|||
use crate::ExprError::InvalidBracketContent;
|
||||
|
||||
use super::{
|
||||
check_posix_regex_errors, get_next_id, AstNode, AstNodeInner, BinOp, NumericOp, RelationOp,
|
||||
StringOp,
|
||||
AstNode, AstNodeInner, BinOp, NumericOp, RelationOp, StringOp, check_posix_regex_errors,
|
||||
get_next_id,
|
||||
};
|
||||
|
||||
impl PartialEq for AstNode {
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
|
||||
use std::collections::BTreeMap;
|
||||
use std::io::BufRead;
|
||||
use std::io::{self, stdin, stdout, Write};
|
||||
use std::io::{self, Write, stdin, stdout};
|
||||
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use num_bigint::BigUint;
|
||||
use num_traits::FromPrimitive;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, FromIo, UResult, USimpleError};
|
||||
use uucore::error::{FromIo, UResult, USimpleError, set_exit_code};
|
||||
use uucore::{format_usage, help_about, help_usage, show_error, show_warning};
|
||||
|
||||
const ABOUT: &str = help_about!("factor.md");
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// file that was distributed with this source code.
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use std::{ffi::OsString, io::Write};
|
||||
use uucore::error::{set_exit_code, UResult};
|
||||
use uucore::error::{UResult, set_exit_code};
|
||||
use uucore::help_about;
|
||||
|
||||
const ABOUT: &str = help_about!("false.md");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use std::fs::File;
|
||||
use std::io::{stdin, stdout, BufReader, BufWriter, Read, Stdout, Write};
|
||||
use std::io::{BufReader, BufWriter, Read, Stdout, Write, stdin, stdout};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
|
||||
use uucore::{format_usage, help_about, help_usage};
|
||||
|
@ -124,7 +124,10 @@ impl FmtOptions {
|
|||
}
|
||||
(None, None) => (DEFAULT_WIDTH, DEFAULT_GOAL),
|
||||
};
|
||||
debug_assert!(width >= goal, "GOAL {goal} should not be greater than WIDTH {width} when given {width_opt:?} and {goal_opt:?}.");
|
||||
debug_assert!(
|
||||
width >= goal,
|
||||
"GOAL {goal} should not be greater than WIDTH {width} when given {width_opt:?} and {goal_opt:?}."
|
||||
);
|
||||
|
||||
if width > MAX_WIDTH {
|
||||
return Err(USimpleError::new(
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
use std::io::{BufWriter, Stdout, Write};
|
||||
use std::{cmp, mem};
|
||||
|
||||
use crate::parasplit::{ParaWords, Paragraph, WordInfo};
|
||||
use crate::FmtOptions;
|
||||
use crate::parasplit::{ParaWords, Paragraph, WordInfo};
|
||||
|
||||
struct BreakArgs<'a> {
|
||||
opts: &'a FmtOptions,
|
||||
|
@ -465,11 +465,7 @@ fn restart_active_breaks<'a>(
|
|||
// Number of spaces to add before a word, based on mode, newline, sentence start.
|
||||
fn compute_slen(uniform: bool, newline: bool, start: bool, punct: bool) -> usize {
|
||||
if uniform || newline {
|
||||
if start || (newline && punct) {
|
||||
2
|
||||
} else {
|
||||
1
|
||||
}
|
||||
if start || (newline && punct) { 2 } else { 1 }
|
||||
} else {
|
||||
0
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use std::fs::File;
|
||||
use std::io::{stdin, BufRead, BufReader, Read};
|
||||
use std::io::{BufRead, BufReader, Read, stdin};
|
||||
use std::path::Path;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
use thiserror::Error;
|
||||
use uucore::{
|
||||
display::Quotable,
|
||||
entries::{get_groups_gnu, gid2grp, Locate, Passwd},
|
||||
entries::{Locate, Passwd, get_groups_gnu, gid2grp},
|
||||
error::{UError, UResult},
|
||||
format_usage, help_about, help_usage, show,
|
||||
};
|
||||
|
|
|
@ -5,26 +5,26 @@
|
|||
|
||||
// spell-checker:ignore (ToDO) algo, algoname, regexes, nread, nonames
|
||||
|
||||
use clap::ArgAction;
|
||||
use clap::builder::ValueParser;
|
||||
use clap::value_parser;
|
||||
use clap::ArgAction;
|
||||
use clap::{Arg, ArgMatches, Command};
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::fs::File;
|
||||
use std::io::{stdin, BufReader, Read};
|
||||
use std::io::{BufReader, Read, stdin};
|
||||
use std::iter;
|
||||
use std::num::ParseIntError;
|
||||
use std::path::Path;
|
||||
use uucore::checksum::ChecksumError;
|
||||
use uucore::checksum::ChecksumOptions;
|
||||
use uucore::checksum::ChecksumVerbose;
|
||||
use uucore::checksum::HashAlgorithm;
|
||||
use uucore::checksum::calculate_blake2b_length;
|
||||
use uucore::checksum::create_sha3;
|
||||
use uucore::checksum::detect_algo;
|
||||
use uucore::checksum::digest_reader;
|
||||
use uucore::checksum::escape_filename;
|
||||
use uucore::checksum::perform_checksum_validation;
|
||||
use uucore::checksum::ChecksumError;
|
||||
use uucore::checksum::ChecksumOptions;
|
||||
use uucore::checksum::ChecksumVerbose;
|
||||
use uucore::checksum::HashAlgorithm;
|
||||
use uucore::error::{FromIo, UResult};
|
||||
use uucore::sum::{Digest, Sha3_224, Sha3_256, Sha3_384, Sha3_512, Shake128, Shake256};
|
||||
use uucore::{format_usage, help_about, help_usage};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// file that was distributed with this source code.
|
||||
|
||||
use std::ffi::OsString;
|
||||
use uucore::parse_size::{parse_size_u64, ParseSizeError};
|
||||
use uucore::parse_size::{ParseSizeError, parse_size_u64};
|
||||
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub enum ParseError {
|
||||
|
|
|
@ -362,7 +362,7 @@ mod tests {
|
|||
use std::io::{BufRead, BufReader};
|
||||
|
||||
use crate::take::{
|
||||
copy_all_but_n_bytes, copy_all_but_n_lines, take_lines, TakeAllBuffer, TakeAllLinesBuffer,
|
||||
TakeAllBuffer, TakeAllLinesBuffer, copy_all_but_n_bytes, copy_all_but_n_lines, take_lines,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -34,7 +34,7 @@ static OPT_HOST: &str = "host";
|
|||
mod wsa {
|
||||
use std::io;
|
||||
|
||||
use windows_sys::Win32::Networking::WinSock::{WSACleanup, WSAStartup, WSADATA};
|
||||
use windows_sys::Win32::Networking::WinSock::{WSACleanup, WSADATA, WSAStartup};
|
||||
|
||||
pub(super) struct WsaHandle(());
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ use std::ffi::CStr;
|
|||
use uucore::display::Quotable;
|
||||
use uucore::entries::{self, Group, Locate, Passwd};
|
||||
use uucore::error::UResult;
|
||||
use uucore::error::{set_exit_code, USimpleError};
|
||||
use uucore::error::{USimpleError, set_exit_code};
|
||||
pub use uucore::libc;
|
||||
use uucore::libc::{getlogin, uid_t};
|
||||
use uucore::line_ending::LineEnding;
|
||||
|
|
|
@ -9,11 +9,11 @@ mod mode;
|
|||
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use file_diff::diff;
|
||||
use filetime::{set_file_times, FileTime};
|
||||
use filetime::{FileTime, set_file_times};
|
||||
use std::fmt::Debug;
|
||||
use std::fs::File;
|
||||
use std::fs::{self, metadata};
|
||||
use std::path::{Path, PathBuf, MAIN_SEPARATOR};
|
||||
use std::path::{MAIN_SEPARATOR, Path, PathBuf};
|
||||
use std::process;
|
||||
use thiserror::Error;
|
||||
use uucore::backup_control::{self, BackupMode};
|
||||
|
@ -23,7 +23,7 @@ use uucore::entries::{grp2gid, usr2uid};
|
|||
use uucore::error::{FromIo, UError, UResult, UUsageError};
|
||||
use uucore::fs::dir_strip_dot_for_creation;
|
||||
use uucore::mode::get_umask;
|
||||
use uucore::perms::{wrap_chown, Verbosity, VerbosityLevel};
|
||||
use uucore::perms::{Verbosity, VerbosityLevel, wrap_chown};
|
||||
use uucore::process::{getegid, geteuid};
|
||||
use uucore::{format_usage, help_about, help_usage, show, show_error, show_if_err};
|
||||
|
||||
|
|
|
@ -7,17 +7,17 @@
|
|||
|
||||
use clap::builder::ValueParser;
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use memchr::{memchr_iter, memmem::Finder, Memchr3};
|
||||
use memchr::{Memchr3, memchr_iter, memmem::Finder};
|
||||
use std::cmp::Ordering;
|
||||
use std::ffi::OsString;
|
||||
use std::fs::File;
|
||||
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Split, Stdin, Write};
|
||||
use std::io::{BufRead, BufReader, BufWriter, Split, Stdin, Write, stdin, stdout};
|
||||
use std::num::IntErrorKind;
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
use thiserror::Error;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, FromIo, UError, UResult, USimpleError};
|
||||
use uucore::error::{FromIo, UError, UResult, USimpleError, set_exit_code};
|
||||
use uucore::line_ending::LineEnding;
|
||||
use uucore::{format_usage, help_about, help_usage};
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ use nix::unistd::Pid;
|
|||
use std::io::Error;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
use uucore::signals::{signal_by_name_or_value, signal_name_by_value, ALL_SIGNALS};
|
||||
use uucore::signals::{ALL_SIGNALS, signal_by_name_or_value, signal_name_by_value};
|
||||
use uucore::{format_usage, help_about, help_usage, show};
|
||||
|
||||
static ABOUT: &str = help_about!("kill.md");
|
||||
|
@ -239,8 +239,10 @@ fn parse_pids(pids: &[String]) -> UResult<Vec<i32>> {
|
|||
fn kill(sig: Option<Signal>, pids: &[i32]) {
|
||||
for &pid in pids {
|
||||
if let Err(e) = signal::kill(Pid::from_raw(pid), sig) {
|
||||
show!(Error::from_raw_os_error(e as i32)
|
||||
.map_err_context(|| format!("sending signal to {pid} failed")));
|
||||
show!(
|
||||
Error::from_raw_os_error(e as i32)
|
||||
.map_err_context(|| format!("sending signal to {pid} failed"))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ use std::os::unix::fs::symlink;
|
|||
use std::os::windows::fs::{symlink_dir, symlink_file};
|
||||
use std::path::{Path, PathBuf};
|
||||
use uucore::backup_control::{self, BackupMode};
|
||||
use uucore::fs::{canonicalize, MissingHandling, ResolveMode};
|
||||
use uucore::fs::{MissingHandling, ResolveMode, canonicalize};
|
||||
|
||||
pub struct Settings {
|
||||
overwrite: OverwriteMode,
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
use super::get_metadata_with_deref_opt;
|
||||
use super::PathData;
|
||||
use super::get_metadata_with_deref_opt;
|
||||
use lscolors::{Indicator, LsColors, Style};
|
||||
use std::ffi::OsString;
|
||||
use std::fs::{DirEntry, Metadata};
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::{
|
|||
ffi::{OsStr, OsString},
|
||||
fmt::Write as FmtWrite,
|
||||
fs::{self, DirEntry, FileType, Metadata, ReadDir},
|
||||
io::{stdout, BufWriter, ErrorKind, Stdout, Write},
|
||||
io::{BufWriter, ErrorKind, Stdout, Write, stdout},
|
||||
path::{Path, PathBuf},
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
@ -28,17 +28,19 @@ use std::{collections::HashSet, io::IsTerminal};
|
|||
use ansi_width::ansi_width;
|
||||
use chrono::{DateTime, Local, TimeDelta};
|
||||
use clap::{
|
||||
builder::{NonEmptyStringValueParser, PossibleValue, ValueParser},
|
||||
Arg, ArgAction, Command,
|
||||
builder::{NonEmptyStringValueParser, PossibleValue, ValueParser},
|
||||
};
|
||||
use glob::{MatchOptions, Pattern};
|
||||
use lscolors::LsColors;
|
||||
use term_grid::{Direction, Filling, Grid, GridOptions};
|
||||
use thiserror::Error;
|
||||
use uucore::error::USimpleError;
|
||||
use uucore::format::human::{human_readable, SizeFormat};
|
||||
use uucore::format::human::{SizeFormat, human_readable};
|
||||
#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
|
||||
use uucore::fsxattr::has_acl;
|
||||
#[cfg(unix)]
|
||||
use uucore::libc::{S_IXGRP, S_IXOTH, S_IXUSR};
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "macos",
|
||||
|
@ -52,14 +54,12 @@ use uucore::fsxattr::has_acl;
|
|||
target_os = "solaris"
|
||||
))]
|
||||
use uucore::libc::{dev_t, major, minor};
|
||||
#[cfg(unix)]
|
||||
use uucore::libc::{S_IXGRP, S_IXOTH, S_IXUSR};
|
||||
use uucore::line_ending::LineEnding;
|
||||
use uucore::quoting_style::{self, escape_name, QuotingStyle};
|
||||
use uucore::quoting_style::{self, QuotingStyle, escape_name};
|
||||
use uucore::{
|
||||
custom_tz_fmt,
|
||||
display::Quotable,
|
||||
error::{set_exit_code, UError, UResult},
|
||||
error::{UError, UResult, set_exit_code},
|
||||
format_usage,
|
||||
fs::display_permissions,
|
||||
os_str_as_bytes_lossy,
|
||||
|
@ -70,9 +70,9 @@ use uucore::{
|
|||
use uucore::{help_about, help_section, help_usage, parse_glob, show, show_error, show_warning};
|
||||
|
||||
mod dired;
|
||||
use dired::{is_dired_arg_present, DiredOutput};
|
||||
use dired::{DiredOutput, is_dired_arg_present};
|
||||
mod colors;
|
||||
use colors::{color_name, StyleManager};
|
||||
use colors::{StyleManager, color_name};
|
||||
|
||||
#[cfg(not(feature = "selinux"))]
|
||||
static CONTEXT_HELP_TEXT: &str = "print any security context of each file (not enabled)";
|
||||
|
@ -2187,11 +2187,7 @@ fn sort_entries(entries: &mut [PathData], config: &Config, out: &mut BufWriter<S
|
|||
let md = {
|
||||
// We will always try to deref symlinks to group directories, so PathData.md
|
||||
// is not always useful.
|
||||
if p.must_dereference {
|
||||
p.md.get()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if p.must_dereference { p.md.get() } else { None }
|
||||
};
|
||||
|
||||
!match md {
|
||||
|
@ -3119,11 +3115,7 @@ fn display_len_or_rdev(metadata: &Metadata, config: &Config) -> SizeOrDeviceId {
|
|||
let len_adjusted = {
|
||||
let d = metadata.len() / config.file_size_block_size;
|
||||
let r = metadata.len() % config.file_size_block_size;
|
||||
if r == 0 {
|
||||
d
|
||||
} else {
|
||||
d + 1
|
||||
}
|
||||
if r == 0 { d } else { d + 1 }
|
||||
};
|
||||
SizeOrDeviceId::Size(display_size(len_adjusted, config))
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ pub fn mkdir(path: &Path, recursive: bool, mode: u32, verbose: bool) -> UResult<
|
|||
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
fn chmod(path: &Path, mode: u32) -> UResult<()> {
|
||||
use std::fs::{set_permissions, Permissions};
|
||||
use std::fs::{Permissions, set_permissions};
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let mode = Permissions::from_mode(mode);
|
||||
set_permissions(path, mode)
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
|
||||
// spell-checker:ignore (ToDO) parsemode makedev sysmacros perror IFBLK IFCHR IFIFO
|
||||
|
||||
use clap::{value_parser, Arg, ArgMatches, Command};
|
||||
use libc::{dev_t, mode_t};
|
||||
use clap::{Arg, ArgMatches, Command, value_parser};
|
||||
use libc::{S_IFBLK, S_IFCHR, S_IFIFO, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR};
|
||||
use libc::{dev_t, mode_t};
|
||||
use std::ffi::CString;
|
||||
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, UResult, USimpleError, UUsageError};
|
||||
use uucore::error::{UResult, USimpleError, UUsageError, set_exit_code};
|
||||
use uucore::{format_usage, help_about, help_section, help_usage};
|
||||
|
||||
const ABOUT: &str = help_about!("mknod.md");
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
// spell-checker:ignore (paths) GPGHome findxs
|
||||
|
||||
use clap::{builder::ValueParser, Arg, ArgAction, ArgMatches, Command};
|
||||
use uucore::display::{println_verbatim, Quotable};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command, builder::ValueParser};
|
||||
use uucore::display::{Quotable, println_verbatim};
|
||||
use uucore::error::{FromIo, UError, UResult, UUsageError};
|
||||
use uucore::{format_usage, help_about, help_usage};
|
||||
|
||||
|
@ -14,7 +14,7 @@ use std::env;
|
|||
use std::ffi::OsStr;
|
||||
use std::io::ErrorKind;
|
||||
use std::iter;
|
||||
use std::path::{Path, PathBuf, MAIN_SEPARATOR};
|
||||
use std::path::{MAIN_SEPARATOR, Path, PathBuf};
|
||||
|
||||
#[cfg(unix)]
|
||||
use std::fs;
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{stdin, stdout, BufReader, Read, Stdout, Write},
|
||||
io::{BufReader, Read, Stdout, Write, stdin, stdout},
|
||||
panic::set_hook,
|
||||
path::Path,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use clap::{value_parser, Arg, ArgAction, ArgMatches, Command};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command, value_parser};
|
||||
use crossterm::event::KeyEventKind;
|
||||
use crossterm::{
|
||||
cursor::{MoveTo, MoveUp},
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
mod error;
|
||||
|
||||
use clap::builder::ValueParser;
|
||||
use clap::{error::ErrorKind, Arg, ArgAction, ArgMatches, Command};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command, error::ErrorKind};
|
||||
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
|
||||
use std::collections::HashSet;
|
||||
use std::env;
|
||||
|
@ -19,13 +19,13 @@ use std::io;
|
|||
use std::os::unix;
|
||||
#[cfg(windows)]
|
||||
use std::os::windows;
|
||||
use std::path::{absolute, Path, PathBuf};
|
||||
use std::path::{Path, PathBuf, absolute};
|
||||
use uucore::backup_control::{self, source_is_target_backup};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, FromIo, UResult, USimpleError, UUsageError};
|
||||
use uucore::error::{FromIo, UResult, USimpleError, UUsageError, set_exit_code};
|
||||
use uucore::fs::{
|
||||
are_hardlinks_or_one_way_symlink_to_same_file, are_hardlinks_to_same_file, canonicalize,
|
||||
path_ends_with_terminator, MissingHandling, ResolveMode,
|
||||
MissingHandling, ResolveMode, are_hardlinks_or_one_way_symlink_to_same_file,
|
||||
are_hardlinks_to_same_file, canonicalize, path_ends_with_terminator,
|
||||
};
|
||||
#[cfg(all(unix, not(any(target_os = "macos", target_os = "redox"))))]
|
||||
use uucore::fsxattr;
|
||||
|
@ -37,8 +37,8 @@ pub use uucore::{backup_control::BackupMode, update_control::UpdateMode};
|
|||
use uucore::{format_usage, help_about, help_section, help_usage, prompt_yes, show};
|
||||
|
||||
use fs_extra::dir::{
|
||||
get_size as dir_get_size, move_dir, move_dir_with_progress, CopyOptions as DirCopyOptions,
|
||||
TransitProcess, TransitProcessResult,
|
||||
CopyOptions as DirCopyOptions, TransitProcess, TransitProcessResult, get_size as dir_get_size,
|
||||
move_dir, move_dir_with_progress,
|
||||
};
|
||||
|
||||
use crate::error::MvError;
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
|
||||
// spell-checker:ignore (ToDO) getpriority execvp setpriority nstr PRIO cstrs ENOENT
|
||||
|
||||
use libc::{c_char, c_int, execvp, PRIO_PROCESS};
|
||||
use libc::{PRIO_PROCESS, c_char, c_int, execvp};
|
||||
use std::ffi::{CString, OsString};
|
||||
use std::io::{Error, Write};
|
||||
use std::ptr;
|
||||
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use uucore::{
|
||||
error::{set_exit_code, UClapError, UResult, USimpleError, UUsageError},
|
||||
error::{UClapError, UResult, USimpleError, UUsageError, set_exit_code},
|
||||
format_usage, help_about, help_usage, show_error,
|
||||
};
|
||||
|
||||
|
@ -132,7 +132,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
return Err(USimpleError::new(
|
||||
125,
|
||||
format!("\"{nstr}\" is not a valid number: {e}"),
|
||||
))
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use std::fs::File;
|
||||
use std::io::{stdin, BufRead, BufReader, Read};
|
||||
use std::io::{BufRead, BufReader, Read, stdin};
|
||||
use std::path::Path;
|
||||
use uucore::error::{set_exit_code, FromIo, UResult, USimpleError};
|
||||
use uucore::error::{FromIo, UResult, USimpleError, set_exit_code};
|
||||
use uucore::{format_usage, help_about, help_section, help_usage, show_error};
|
||||
|
||||
mod helper;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
// spell-checker:ignore (ToDO) execvp SIGHUP cproc vprocmgr cstrs homeout
|
||||
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use libc::{SIG_IGN, SIGHUP};
|
||||
use libc::{c_char, dup2, execvp, signal};
|
||||
use libc::{SIGHUP, SIG_IGN};
|
||||
use std::env;
|
||||
use std::ffi::CString;
|
||||
use std::fs::{File, OpenOptions};
|
||||
|
@ -16,7 +16,7 @@ use std::os::unix::prelude::*;
|
|||
use std::path::{Path, PathBuf};
|
||||
use thiserror::Error;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, UClapError, UError, UResult};
|
||||
use uucore::error::{UClapError, UError, UResult, set_exit_code};
|
||||
use uucore::{format_usage, help_about, help_section, help_usage, show_error};
|
||||
|
||||
const ABOUT: &str = help_about!("nohup.md");
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
use uucore::display::Quotable;
|
||||
|
||||
use crate::options::{NumfmtOptions, RoundMethod, TransformOptions};
|
||||
use crate::units::{DisplayableSuffix, RawSuffix, Result, Suffix, Unit, IEC_BASES, SI_BASES};
|
||||
use crate::units::{DisplayableSuffix, IEC_BASES, RawSuffix, Result, SI_BASES, Suffix, Unit};
|
||||
|
||||
/// Iterate over a line's fields, where each field is a contiguous sequence of
|
||||
/// non-whitespace, optionally prefixed with one or more characters of leading
|
||||
|
@ -156,11 +156,7 @@ fn transform_from(s: &str, opts: &TransformOptions) -> Result<f64> {
|
|||
remove_suffix(i, suffix, &opts.from).map(|n| {
|
||||
// GNU numfmt doesn't round values if no --from argument is provided by the user
|
||||
if opts.from == Unit::None {
|
||||
if n == -0.0 {
|
||||
0.0
|
||||
} else {
|
||||
n
|
||||
}
|
||||
if n == -0.0 { 0.0 } else { n }
|
||||
} else if n < 0.0 {
|
||||
-n.abs().ceil()
|
||||
} else {
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::errors::*;
|
|||
use crate::format::format_and_print;
|
||||
use crate::options::*;
|
||||
use crate::units::{Result, Unit};
|
||||
use clap::{parser::ValueSource, Arg, ArgAction, ArgMatches, Command};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command, parser::ValueSource};
|
||||
use std::io::{BufRead, Write};
|
||||
use std::str::FromStr;
|
||||
|
||||
|
@ -378,8 +378,8 @@ mod tests {
|
|||
use uucore::error::get_exit_code;
|
||||
|
||||
use super::{
|
||||
handle_args, handle_buffer, parse_unit_size, parse_unit_size_suffix, FormatOptions,
|
||||
InvalidModes, NumfmtOptions, Range, RoundMethod, TransformOptions, Unit,
|
||||
FormatOptions, InvalidModes, NumfmtOptions, Range, RoundMethod, TransformOptions, Unit,
|
||||
handle_args, handle_buffer, parse_unit_size, parse_unit_size_suffix,
|
||||
};
|
||||
use std::io::{BufReader, Error, ErrorKind, Read};
|
||||
struct MockBuffer {}
|
||||
|
|
|
@ -167,7 +167,7 @@ impl FromStr for FormatOptions {
|
|||
_ => {
|
||||
return Err(format!(
|
||||
"invalid format '{s}', directive must be %[0]['][-][N][.][N]f"
|
||||
))
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,14 +33,14 @@ use crate::inputdecoder::{InputDecoder, MemoryDecoder};
|
|||
use crate::inputoffset::{InputOffset, Radix};
|
||||
use crate::multifilereader::{HasError, InputSource, MultifileReader};
|
||||
use crate::output_info::OutputInfo;
|
||||
use crate::parse_formats::{parse_format_flags, ParsedFormatterItemInfo};
|
||||
use crate::parse_inputs::{parse_inputs, CommandLineInputs};
|
||||
use crate::parse_formats::{ParsedFormatterItemInfo, parse_format_flags};
|
||||
use crate::parse_inputs::{CommandLineInputs, parse_inputs};
|
||||
use crate::parse_nrofbytes::parse_number_of_bytes;
|
||||
use crate::partialreader::PartialReader;
|
||||
use crate::peekreader::{PeekRead, PeekReader};
|
||||
use crate::prn_char::format_ascii_dump;
|
||||
use clap::ArgAction;
|
||||
use clap::{parser::ValueSource, Arg, ArgMatches, Command};
|
||||
use clap::{Arg, ArgMatches, Command, parser::ValueSource};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{UResult, USimpleError};
|
||||
use uucore::parse_size::ParseSizeError;
|
||||
|
@ -89,7 +89,7 @@ impl OdOptions {
|
|||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("Invalid argument --endian={s}"),
|
||||
))
|
||||
));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -104,7 +104,7 @@ impl OdOptions {
|
|||
return Err(USimpleError::new(
|
||||
1,
|
||||
format_error_message(&e, s, options::SKIP_BYTES),
|
||||
))
|
||||
));
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -135,7 +135,7 @@ impl OdOptions {
|
|||
return Err(USimpleError::new(
|
||||
1,
|
||||
format_error_message(&e, s, options::WIDTH),
|
||||
))
|
||||
));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -162,7 +162,7 @@ impl OdOptions {
|
|||
return Err(USimpleError::new(
|
||||
1,
|
||||
format_error_message(&e, s, options::READ_BYTES),
|
||||
))
|
||||
));
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -585,7 +585,7 @@ fn print_bytes(prefix: &str, input_decoder: &MemoryDecoder, output_info: &Output
|
|||
|
||||
if first {
|
||||
print!("{prefix}"); // print offset
|
||||
// if printing in multiple formats offset is printed only once
|
||||
// if printing in multiple formats offset is printed only once
|
||||
first = false;
|
||||
} else {
|
||||
// this takes the space of the file offset on subsequent
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
use uucore::parse_size::{parse_size_u64, ParseSizeError};
|
||||
use uucore::parse_size::{ParseSizeError, parse_size_u64};
|
||||
|
||||
pub fn parse_number_of_bytes(s: &str) -> Result<u64, ParseSizeError> {
|
||||
let mut start = 0;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
use clap::{Arg, ArgAction, Command};
|
||||
use std::cell::{OnceCell, RefCell};
|
||||
use std::fs::File;
|
||||
use std::io::{stdin, stdout, BufRead, BufReader, Stdin, Write};
|
||||
use std::io::{BufRead, BufReader, Stdin, Write, stdin, stdout};
|
||||
use std::iter::Cycle;
|
||||
use std::rc::Rc;
|
||||
use std::slice::Iter;
|
||||
|
|
|
@ -9,7 +9,7 @@ use clap::{Arg, ArgAction, Command};
|
|||
use std::fs;
|
||||
use std::io::{ErrorKind, Write};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, UResult, UUsageError};
|
||||
use uucore::error::{UResult, UUsageError, set_exit_code};
|
||||
use uucore::{format_usage, help_about, help_usage};
|
||||
|
||||
// operating mode
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
|
||||
// spell-checker:ignore (ToDO) BUFSIZE gecos fullname, mesg iobuf
|
||||
|
||||
use crate::Capitalize;
|
||||
use crate::options;
|
||||
use crate::uu_app;
|
||||
use crate::Capitalize;
|
||||
|
||||
use uucore::entries::{Locate, Passwd};
|
||||
use uucore::error::{FromIo, UResult};
|
||||
use uucore::libc::S_IWGRP;
|
||||
use uucore::utmpx::{self, time, Utmpx};
|
||||
use uucore::utmpx::{self, Utmpx, time};
|
||||
|
||||
use std::io::prelude::*;
|
||||
use std::io::BufReader;
|
||||
use std::io::prelude::*;
|
||||
|
||||
use std::fs::File;
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
|
|
|
@ -11,8 +11,8 @@ use clap::{Arg, ArgAction, ArgMatches, Command};
|
|||
use itertools::Itertools;
|
||||
use quick_error::ResultExt;
|
||||
use regex::Regex;
|
||||
use std::fs::{metadata, File};
|
||||
use std::io::{stdin, stdout, BufRead, BufReader, Lines, Read, Write};
|
||||
use std::fs::{File, metadata};
|
||||
use std::io::{BufRead, BufReader, Lines, Read, Write, stdin, stdout};
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::fs::FileTypeExt;
|
||||
|
||||
|
|
|
@ -50,11 +50,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
}
|
||||
}
|
||||
|
||||
if error_found {
|
||||
Err(1.into())
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
if error_found { Err(1.into()) } else { Ok(()) }
|
||||
}
|
||||
|
||||
pub fn uu_app() -> Command {
|
||||
|
|
|
@ -6,7 +6,7 @@ use clap::{Arg, ArgAction, Command};
|
|||
use std::io::stdout;
|
||||
use std::ops::ControlFlow;
|
||||
use uucore::error::{UResult, UUsageError};
|
||||
use uucore::format::{parse_spec_and_escape, FormatArgument, FormatItem};
|
||||
use uucore::format::{FormatArgument, FormatItem, parse_spec_and_escape};
|
||||
use uucore::{format_usage, help_about, help_section, help_usage, show_warning};
|
||||
|
||||
const VERSION: &str = "version";
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::collections::{BTreeSet, HashMap, HashSet};
|
|||
use std::error::Error;
|
||||
use std::fmt::{Display, Formatter, Write as FmtWrite};
|
||||
use std::fs::File;
|
||||
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write};
|
||||
use std::io::{BufRead, BufReader, BufWriter, Read, Write, stdin, stdout};
|
||||
use std::num::ParseIntError;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UError, UResult, UUsageError};
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use std::fs;
|
||||
use std::io::{stdout, Write};
|
||||
use std::io::{Write, stdout};
|
||||
use std::path::{Path, PathBuf};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
|
||||
use uucore::fs::{canonicalize, MissingHandling, ResolveMode};
|
||||
use uucore::fs::{MissingHandling, ResolveMode, canonicalize};
|
||||
use uucore::line_ending::LineEnding;
|
||||
use uucore::{format_usage, help_about, help_usage, show_error};
|
||||
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
|
||||
// spell-checker:ignore (ToDO) retcode
|
||||
|
||||
use clap::{builder::NonEmptyStringValueParser, Arg, ArgAction, ArgMatches, Command};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command, builder::NonEmptyStringValueParser};
|
||||
use std::{
|
||||
io::{stdout, Write},
|
||||
io::{Write, stdout},
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
use uucore::fs::make_path_relative_to;
|
||||
use uucore::{
|
||||
display::{print_verbatim, Quotable},
|
||||
display::{Quotable, print_verbatim},
|
||||
error::{FromIo, UClapError, UResult},
|
||||
format_usage,
|
||||
fs::{canonicalize, MissingHandling, ResolveMode},
|
||||
fs::{MissingHandling, ResolveMode, canonicalize},
|
||||
help_about, help_usage,
|
||||
line_ending::LineEnding,
|
||||
show_if_err,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
// spell-checker:ignore (path) eacces inacc rm-r4
|
||||
|
||||
use clap::{builder::ValueParser, parser::ValueSource, Arg, ArgAction, Command};
|
||||
use clap::{Arg, ArgAction, Command, builder::ValueParser, parser::ValueSource};
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::fs::{self, Metadata};
|
||||
use std::ops::BitOr;
|
||||
|
@ -133,7 +133,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("Invalid argument to interactive ({val})"),
|
||||
))
|
||||
));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::fs::{read_dir, remove_dir};
|
|||
use std::io;
|
||||
use std::path::Path;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, strip_errno, UResult};
|
||||
use uucore::error::{UResult, set_exit_code, strip_errno};
|
||||
|
||||
use uucore::{format_usage, help_about, help_usage, show_error, util_name};
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ fn parse_exponent_part(s: &str) -> Result<(Option<i32>, &str), ParseNumberError>
|
|||
mod tests {
|
||||
|
||||
use super::{parse_number, parse_precision};
|
||||
use crate::{numberparse::ParseNumberError, ExtendedBigDecimal};
|
||||
use crate::{ExtendedBigDecimal, numberparse::ParseNumberError};
|
||||
use bigdecimal::BigDecimal;
|
||||
use num_traits::ToPrimitive;
|
||||
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (ToDO) bigdecimal extendedbigdecimal numberparse hexadecimalfloat
|
||||
use std::ffi::OsString;
|
||||
use std::io::{stdout, BufWriter, ErrorKind, Write};
|
||||
use std::io::{BufWriter, ErrorKind, Write, stdout};
|
||||
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use num_traits::Zero;
|
||||
|
||||
use uucore::error::{FromIo, UResult};
|
||||
use uucore::format::num_format::FloatVariant;
|
||||
use uucore::format::{num_format, ExtendedBigDecimal, Format};
|
||||
use uucore::format::{ExtendedBigDecimal, Format, num_format};
|
||||
use uucore::{format_usage, help_about, help_usage};
|
||||
|
||||
mod error;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
use clap::{Arg, ArgAction, Command};
|
||||
#[cfg(unix)]
|
||||
use libc::S_IWUSR;
|
||||
use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng};
|
||||
use rand::{Rng, SeedableRng, rngs::StdRng, seq::SliceRandom};
|
||||
use std::fs::{self, File, OpenOptions};
|
||||
use std::io::{self, Seek, Write};
|
||||
#[cfg(unix)]
|
||||
|
@ -229,7 +229,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("invalid number of passes: {}", s.quote()),
|
||||
))
|
||||
));
|
||||
}
|
||||
},
|
||||
None => unreachable!(),
|
||||
|
@ -456,7 +456,7 @@ fn wipe_file(
|
|||
pass_sequence.shuffle(&mut rng); // randomize the order of application
|
||||
|
||||
let n_random = 3 + n_passes / 10; // Minimum 3 random passes; ratio of 10 after
|
||||
// Evenly space random passes; ensures one at the beginning and end
|
||||
// Evenly space random passes; ensures one at the beginning and end
|
||||
for i in 0..n_random {
|
||||
pass_sequence[i * (n_passes - 1) / (n_random - 1)] = PassType::Random;
|
||||
}
|
||||
|
@ -493,8 +493,10 @@ fn wipe_file(
|
|||
}
|
||||
// size is an optional argument for exactly how many bytes we want to shred
|
||||
// Ignore failed writes; just keep trying
|
||||
show_if_err!(do_pass(&mut file, &pass_type, exact, size)
|
||||
.map_err_context(|| format!("{}: File write pass failed", path.maybe_quote())));
|
||||
show_if_err!(
|
||||
do_pass(&mut file, &pass_type, exact, size)
|
||||
.map_err_context(|| format!("{}: File write pass failed", path.maybe_quote()))
|
||||
);
|
||||
}
|
||||
|
||||
if remove_method != RemoveMethod::None {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
use std::fmt;
|
||||
use std::io::Read;
|
||||
|
||||
use rand_core::{impls, RngCore};
|
||||
use rand_core::{RngCore, impls};
|
||||
|
||||
/// An RNG that reads random bytes straight from any type supporting
|
||||
/// [`std::io::Read`], for example files.
|
||||
|
|
|
@ -13,7 +13,7 @@ use rand::{Rng, RngCore};
|
|||
use std::collections::HashSet;
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::fs::File;
|
||||
use std::io::{stdin, stdout, BufWriter, Error, Read, Write};
|
||||
use std::io::{BufWriter, Error, Read, Write, stdin, stdout};
|
||||
use std::ops::RangeInclusive;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::str::FromStr;
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
//! Check if a file is ordered
|
||||
|
||||
use crate::{
|
||||
GlobalSettings, SortError,
|
||||
chunks::{self, Chunk, RecycledChunk},
|
||||
compare_by, open, GlobalSettings, SortError,
|
||||
compare_by, open,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use std::{
|
||||
|
@ -15,7 +16,7 @@ use std::{
|
|||
ffi::OsStr,
|
||||
io::Read,
|
||||
iter,
|
||||
sync::mpsc::{sync_channel, Receiver, SyncSender},
|
||||
sync::mpsc::{Receiver, SyncSender, sync_channel},
|
||||
thread,
|
||||
};
|
||||
use uucore::error::UResult;
|
||||
|
|
|
@ -17,7 +17,7 @@ use memchr::memchr_iter;
|
|||
use self_cell::self_cell;
|
||||
use uucore::error::{UResult, USimpleError};
|
||||
|
||||
use crate::{numeric_str_cmp::NumInfo, GeneralF64ParseResult, GlobalSettings, Line, SortError};
|
||||
use crate::{GeneralF64ParseResult, GlobalSettings, Line, SortError, numeric_str_cmp::NumInfo};
|
||||
|
||||
self_cell!(
|
||||
/// The chunk that is passed around between threads.
|
||||
|
|
|
@ -22,18 +22,19 @@ use std::{
|
|||
use itertools::Itertools;
|
||||
use uucore::error::UResult;
|
||||
|
||||
use crate::Output;
|
||||
use crate::chunks::RecycledChunk;
|
||||
use crate::merge::ClosedTmpFile;
|
||||
use crate::merge::WriteableCompressedTmpFile;
|
||||
use crate::merge::WriteablePlainTmpFile;
|
||||
use crate::merge::WriteableTmpFile;
|
||||
use crate::tmp_dir::TmpDirWrapper;
|
||||
use crate::Output;
|
||||
use crate::{
|
||||
GlobalSettings,
|
||||
chunks::{self, Chunk},
|
||||
compare_by, merge, sort_by, GlobalSettings,
|
||||
compare_by, merge, sort_by,
|
||||
};
|
||||
use crate::{print_sorted, Line};
|
||||
use crate::{Line, print_sorted};
|
||||
|
||||
const START_BUFFER_SIZE: usize = 8_000;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ use std::{
|
|||
path::{Path, PathBuf},
|
||||
process::{Child, ChildStdin, ChildStdout, Command, Stdio},
|
||||
rc::Rc,
|
||||
sync::mpsc::{channel, sync_channel, Receiver, Sender, SyncSender},
|
||||
sync::mpsc::{Receiver, Sender, SyncSender, channel, sync_channel},
|
||||
thread::{self, JoinHandle},
|
||||
};
|
||||
|
||||
|
@ -28,10 +28,10 @@ use compare::Compare;
|
|||
use uucore::error::UResult;
|
||||
|
||||
use crate::{
|
||||
GlobalSettings, Output, SortError,
|
||||
chunks::{self, Chunk, RecycledChunk},
|
||||
compare_by, open,
|
||||
tmp_dir::TmpDirWrapper,
|
||||
GlobalSettings, Output, SortError,
|
||||
};
|
||||
|
||||
/// If the output file occurs in the input files as well, copy the contents of the output file
|
||||
|
|
|
@ -238,14 +238,14 @@ pub fn numeric_str_cmp((a, a_info): (&str, &NumInfo), (b, b_info): (&str, &NumIn
|
|||
Ordering::Equal
|
||||
} else {
|
||||
Ordering::Greater
|
||||
}
|
||||
};
|
||||
}
|
||||
(None, Some(c)) => {
|
||||
break if c == '0' && b_chars.all(|c| c == '0') {
|
||||
Ordering::Equal
|
||||
} else {
|
||||
Ordering::Less
|
||||
}
|
||||
};
|
||||
}
|
||||
(Some(a_char), Some(b_char)) => {
|
||||
let ord = a_char.cmp(&b_char);
|
||||
|
|
|
@ -24,16 +24,16 @@ use custom_str_cmp::custom_str_cmp;
|
|||
use ext_sort::ext_sort;
|
||||
use fnv::FnvHasher;
|
||||
#[cfg(target_os = "linux")]
|
||||
use nix::libc::{getrlimit, rlimit, RLIMIT_NOFILE};
|
||||
use numeric_str_cmp::{human_numeric_str_cmp, numeric_str_cmp, NumInfo, NumInfoParseSettings};
|
||||
use rand::{rng, Rng};
|
||||
use nix::libc::{RLIMIT_NOFILE, getrlimit, rlimit};
|
||||
use numeric_str_cmp::{NumInfo, NumInfoParseSettings, human_numeric_str_cmp, numeric_str_cmp};
|
||||
use rand::{Rng, rng};
|
||||
use rayon::prelude::*;
|
||||
use std::cmp::Ordering;
|
||||
use std::env;
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write};
|
||||
use std::io::{BufRead, BufReader, BufWriter, Read, Write, stdin, stdout};
|
||||
use std::num::IntErrorKind;
|
||||
use std::ops::Range;
|
||||
use std::path::Path;
|
||||
|
@ -43,7 +43,7 @@ use thiserror::Error;
|
|||
use unicode_width::UnicodeWidthStr;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::strip_errno;
|
||||
use uucore::error::{set_exit_code, UError, UResult, USimpleError, UUsageError};
|
||||
use uucore::error::{UError, UResult, USimpleError, UUsageError, set_exit_code};
|
||||
use uucore::line_ending::LineEnding;
|
||||
use uucore::parse_size::{ParseSizeError, Parser};
|
||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
||||
|
@ -668,9 +668,9 @@ fn tokenize_default(line: &str, token_buffer: &mut Vec<Field>) {
|
|||
/// Split between separators. These separators are not included in fields.
|
||||
/// The result is stored into `token_buffer`.
|
||||
fn tokenize_with_separator(line: &str, separator: char, token_buffer: &mut Vec<Field>) {
|
||||
let separator_indices =
|
||||
line.char_indices()
|
||||
.filter_map(|(i, c)| if c == separator { Some(i) } else { None });
|
||||
let separator_indices = line
|
||||
.char_indices()
|
||||
.filter_map(|(i, c)| if c == separator { Some(i) } else { None });
|
||||
let mut start = 0;
|
||||
for sep_idx in separator_indices {
|
||||
token_buffer.push(start..sep_idx);
|
||||
|
@ -707,7 +707,7 @@ impl KeyPosition {
|
|||
"failed to parse field index {} {}",
|
||||
field.quote(),
|
||||
e
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
if field == 0 {
|
||||
|
@ -971,7 +971,9 @@ impl FieldSelector {
|
|||
range
|
||||
}
|
||||
Resolution::TooLow | Resolution::EndOfChar(_) => {
|
||||
unreachable!("This should only happen if the field start index is 0, but that should already have caused an error.")
|
||||
unreachable!(
|
||||
"This should only happen if the field start index is 0, but that should already have caused an error."
|
||||
)
|
||||
}
|
||||
// While for comparisons it's only important that this is an empty slice,
|
||||
// to produce accurate debug output we need to match an empty slice at the end of the line.
|
||||
|
|
|
@ -12,13 +12,13 @@ mod strategy;
|
|||
|
||||
use crate::filenames::{FilenameIterator, Suffix, SuffixError};
|
||||
use crate::strategy::{NumberType, Strategy, StrategyError};
|
||||
use clap::{parser::ValueSource, Arg, ArgAction, ArgMatches, Command, ValueHint};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command, ValueHint, parser::ValueSource};
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
use std::fmt;
|
||||
use std::fs::{metadata, File};
|
||||
use std::fs::{File, metadata};
|
||||
use std::io;
|
||||
use std::io::{stdin, BufRead, BufReader, BufWriter, ErrorKind, Read, Seek, SeekFrom, Write};
|
||||
use std::io::{BufRead, BufReader, BufWriter, ErrorKind, Read, Seek, SeekFrom, Write, stdin};
|
||||
use std::path::Path;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UIoError, UResult, USimpleError, UUsageError};
|
||||
|
@ -1041,7 +1041,9 @@ impl ManageOutFiles for OutFiles {
|
|||
}
|
||||
|
||||
// If this fails - give up and propagate the error
|
||||
uucore::show_error!("at file descriptor limit, but no file descriptor left to close. Closed {count} writers before.");
|
||||
uucore::show_error!(
|
||||
"at file descriptor limit, but no file descriptor left to close. Closed {count} writers before."
|
||||
);
|
||||
return Err(maybe_writer.err().unwrap().into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
//! Determine the strategy for breaking up the input (file or stdin) into chunks
|
||||
//! based on the command line options
|
||||
|
||||
use crate::{OPT_BYTES, OPT_LINES, OPT_LINE_BYTES, OPT_NUMBER};
|
||||
use clap::{parser::ValueSource, ArgMatches};
|
||||
use crate::{OPT_BYTES, OPT_LINE_BYTES, OPT_LINES, OPT_NUMBER};
|
||||
use clap::{ArgMatches, parser::ValueSource};
|
||||
use std::fmt;
|
||||
use uucore::{
|
||||
display::Quotable,
|
||||
parse_size::{parse_size_u64, parse_size_u64_max, ParseSizeError},
|
||||
parse_size::{ParseSizeError, parse_size_u64, parse_size_u64_max},
|
||||
};
|
||||
|
||||
/// Sub-strategy of the [`Strategy::Number`]
|
||||
|
|
|
@ -10,7 +10,7 @@ use clap::builder::ValueParser;
|
|||
use uucore::display::Quotable;
|
||||
use uucore::fs::display_permissions;
|
||||
use uucore::fsext::{
|
||||
pretty_filetype, pretty_fstype, read_fs_list, statfs, BirthTime, FsMeta, StatFs,
|
||||
BirthTime, FsMeta, StatFs, pretty_filetype, pretty_fstype, read_fs_list, statfs,
|
||||
};
|
||||
use uucore::libc::mode_t;
|
||||
use uucore::{
|
||||
|
@ -1197,7 +1197,7 @@ fn pretty_time(sec: i64, nsec: i64) -> String {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{group_num, precision_trunc, Flags, Precision, ScanUtil, Stater, Token};
|
||||
use super::{Flags, Precision, ScanUtil, Stater, Token, group_num, precision_trunc};
|
||||
|
||||
#[test]
|
||||
fn test_scanners() {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// spell-checker:ignore (ToDO) IOFBF IOLBF IONBF cstdio setvbuf
|
||||
|
||||
use cpp::cpp;
|
||||
use libc::{c_char, c_int, fileno, size_t, FILE, _IOFBF, _IOLBF, _IONBF};
|
||||
use libc::{_IOFBF, _IOLBF, _IONBF, FILE, c_char, c_int, fileno, size_t};
|
||||
use std::env;
|
||||
use std::ptr;
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ use std::io::Write;
|
|||
use std::os::unix::process::ExitStatusExt;
|
||||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
use tempfile::tempdir;
|
||||
use tempfile::TempDir;
|
||||
use tempfile::tempdir;
|
||||
use uucore::error::{FromIo, UClapError, UResult, USimpleError, UUsageError};
|
||||
use uucore::parse_size::parse_size_u64;
|
||||
use uucore::{format_usage, help_about, help_section, help_usage};
|
||||
|
@ -171,7 +171,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
format!("{EXEC_ERROR} No such file or directory"),
|
||||
)),
|
||||
_ => Err(USimpleError::new(1, format!("{EXEC_ERROR} {}", e))),
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
mod flags;
|
||||
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use nix::libc::{c_ushort, O_NONBLOCK, TIOCGWINSZ, TIOCSWINSZ};
|
||||
use nix::libc::{O_NONBLOCK, TIOCGWINSZ, TIOCSWINSZ, c_ushort};
|
||||
use nix::sys::termios::{
|
||||
cfgetospeed, cfsetospeed, tcgetattr, tcsetattr, ControlFlags, InputFlags, LocalFlags,
|
||||
OutputFlags, SpecialCharacterIndices, Termios,
|
||||
ControlFlags, InputFlags, LocalFlags, OutputFlags, SpecialCharacterIndices, Termios,
|
||||
cfgetospeed, cfsetospeed, tcgetattr, tcsetattr,
|
||||
};
|
||||
use nix::{ioctl_read_bad, ioctl_write_ptr_bad};
|
||||
use std::fs::File;
|
||||
use std::io::{self, stdout, Stdout};
|
||||
use std::io::{self, Stdout, stdout};
|
||||
use std::ops::ControlFlow;
|
||||
use std::os::fd::{AsFd, BorrowedFd};
|
||||
use std::os::unix::fs::OpenOptionsExt;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue