mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
fix clippy warnings and spelling
* add some missing LICENSE headers
This commit is contained in:
parent
130bf49e5d
commit
f8e96150f8
17 changed files with 71 additions and 19 deletions
|
@ -1,9 +1,9 @@
|
||||||
// This file is part of the uutils coreutils package.
|
// * This file is part of the uutils coreutils package.
|
||||||
//
|
// *
|
||||||
// (c) Derek Chiang <derekchiang93@gmail.com>
|
// * (c) Derek Chiang <derekchiang93@gmail.com>
|
||||||
//
|
// *
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// * For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// * file that was distributed with this source code.
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
@ -25,6 +25,8 @@ use std::os::unix::fs::MetadataExt;
|
||||||
use std::os::windows::fs::MetadataExt;
|
use std::os::windows::fs::MetadataExt;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use std::os::windows::io::AsRawHandle;
|
use std::os::windows::io::AsRawHandle;
|
||||||
|
#[cfg(windows)]
|
||||||
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::time::{Duration, UNIX_EPOCH};
|
use std::time::{Duration, UNIX_EPOCH};
|
||||||
use uucore::parse_size::{parse_size, ParseSizeError};
|
use uucore::parse_size::{parse_size, ParseSizeError};
|
||||||
|
@ -161,7 +163,7 @@ fn birth_u64(meta: &Metadata) -> Option<u64> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn get_size_on_disk(path: &PathBuf) -> u64 {
|
fn get_size_on_disk(path: &Path) -> u64 {
|
||||||
let mut size_on_disk = 0;
|
let mut size_on_disk = 0;
|
||||||
|
|
||||||
// bind file so it stays in scope until end of function
|
// bind file so it stays in scope until end of function
|
||||||
|
@ -193,7 +195,7 @@ fn get_size_on_disk(path: &PathBuf) -> u64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn get_file_info(path: &PathBuf) -> Option<FileInfo> {
|
fn get_file_info(path: &Path) -> Option<FileInfo> {
|
||||||
let mut result = None;
|
let mut result = None;
|
||||||
|
|
||||||
let file = match fs::File::open(path) {
|
let file = match fs::File::open(path) {
|
||||||
|
@ -709,7 +711,7 @@ Try '{} --help' for more information.",
|
||||||
fn format_error_message(error: ParseSizeError, s: &str, option: &str) -> String {
|
fn format_error_message(error: ParseSizeError, s: &str, option: &str) -> String {
|
||||||
// NOTE:
|
// NOTE:
|
||||||
// GNU's du echos affected flag, -B or --block-size (-t or --threshold), depending user's selection
|
// GNU's du echos affected flag, -B or --block-size (-t or --threshold), depending user's selection
|
||||||
// GNU's du distinguishs between "invalid (suffix in) argument"
|
// GNU's du does distinguish between "invalid (suffix in) argument"
|
||||||
match error {
|
match error {
|
||||||
ParseSizeError::ParseFailure(_) => format!("invalid --{} argument '{}'", option, s),
|
ParseSizeError::ParseFailure(_) => format!("invalid --{} argument '{}'", option, s),
|
||||||
ParseSizeError::SizeTooBig(_) => format!("--{} argument '{}' too large", option, s),
|
ParseSizeError::SizeTooBig(_) => format!("--{} argument '{}' too large", option, s),
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
// * This file is part of the uutils coreutils package.
|
||||||
|
// *
|
||||||
|
// * For the full copyright and license information, please view the LICENSE
|
||||||
|
// * file that was distributed with this source code.
|
||||||
|
|
||||||
// spell-checker:ignore (vars) zlines
|
// spell-checker:ignore (vars) zlines
|
||||||
|
|
||||||
use clap::{crate_version, App, Arg};
|
use clap::{crate_version, App, Arg};
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
// * This file is part of the uutils coreutils package.
|
||||||
|
// *
|
||||||
|
// * For the full copyright and license information, please view the LICENSE
|
||||||
|
// * file that was distributed with this source code.
|
||||||
|
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use uucore::parse_size::{parse_size, ParseSizeError};
|
use uucore::parse_size::{parse_size, ParseSizeError};
|
||||||
|
|
||||||
|
|
|
@ -643,7 +643,7 @@ fn open_input_peek_reader(
|
||||||
fn format_error_message(error: ParseSizeError, s: &str, option: &str) -> String {
|
fn format_error_message(error: ParseSizeError, s: &str, option: &str) -> String {
|
||||||
// NOTE:
|
// NOTE:
|
||||||
// GNU's od echos affected flag, -N or --read-bytes (-j or --skip-bytes, etc.), depending user's selection
|
// GNU's od echos affected flag, -N or --read-bytes (-j or --skip-bytes, etc.), depending user's selection
|
||||||
// GNU's od distinguishs between "invalid (suffix in) argument"
|
// GNU's od does distinguish between "invalid (suffix in) argument"
|
||||||
match error {
|
match error {
|
||||||
ParseSizeError::ParseFailure(_) => format!("invalid --{} argument '{}'", option, s),
|
ParseSizeError::ParseFailure(_) => format!("invalid --{} argument '{}'", option, s),
|
||||||
ParseSizeError::SizeTooBig(_) => format!("--{} argument '{}' too large", option, s),
|
ParseSizeError::SizeTooBig(_) => format!("--{} argument '{}' too large", option, s),
|
||||||
|
|
|
@ -71,7 +71,7 @@ pub fn parse_number_of_bytes(s: &str) -> Result<usize, ParseSizeError> {
|
||||||
};
|
};
|
||||||
factor
|
factor
|
||||||
.checked_mul(multiply)
|
.checked_mul(multiply)
|
||||||
.ok_or(ParseSizeError::SizeTooBig(s.to_string()))
|
.ok_or_else(|| ParseSizeError::SizeTooBig(s.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -80,12 +80,12 @@ fn test_parse_number_of_bytes() {
|
||||||
assert_eq!(8, parse_number_of_bytes("010").unwrap());
|
assert_eq!(8, parse_number_of_bytes("010").unwrap());
|
||||||
assert_eq!(8 * 512, parse_number_of_bytes("010b").unwrap());
|
assert_eq!(8 * 512, parse_number_of_bytes("010b").unwrap());
|
||||||
assert_eq!(8 * 1024, parse_number_of_bytes("010k").unwrap());
|
assert_eq!(8 * 1024, parse_number_of_bytes("010k").unwrap());
|
||||||
assert_eq!(8 * 1048576, parse_number_of_bytes("010m").unwrap());
|
assert_eq!(8 * 1_048_576, parse_number_of_bytes("010m").unwrap());
|
||||||
|
|
||||||
// hex input
|
// hex input
|
||||||
assert_eq!(15, parse_number_of_bytes("0xf").unwrap());
|
assert_eq!(15, parse_number_of_bytes("0xf").unwrap());
|
||||||
assert_eq!(15, parse_number_of_bytes("0XF").unwrap());
|
assert_eq!(15, parse_number_of_bytes("0XF").unwrap());
|
||||||
assert_eq!(27, parse_number_of_bytes("0x1b").unwrap());
|
assert_eq!(27, parse_number_of_bytes("0x1b").unwrap());
|
||||||
assert_eq!(16 * 1024, parse_number_of_bytes("0x10k").unwrap());
|
assert_eq!(16 * 1024, parse_number_of_bytes("0x10k").unwrap());
|
||||||
assert_eq!(16 * 1048576, parse_number_of_bytes("0x10m").unwrap());
|
assert_eq!(16 * 1_048_576, parse_number_of_bytes("0x10m").unwrap());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1567,7 +1567,7 @@ fn open(path: impl AsRef<OsStr>) -> Box<dyn Read + Send> {
|
||||||
fn format_error_message(error: ParseSizeError, s: &str, option: &str) -> String {
|
fn format_error_message(error: ParseSizeError, s: &str, option: &str) -> String {
|
||||||
// NOTE:
|
// NOTE:
|
||||||
// GNU's sort echos affected flag, -S or --buffer-size, depending user's selection
|
// GNU's sort echos affected flag, -S or --buffer-size, depending user's selection
|
||||||
// GNU's sort distinguishs between "invalid (suffix in) argument"
|
// GNU's sort does distinguish between "invalid (suffix in) argument"
|
||||||
match error {
|
match error {
|
||||||
ParseSizeError::ParseFailure(_) => format!("invalid --{} argument '{}'", option, s),
|
ParseSizeError::ParseFailure(_) => format!("invalid --{} argument '{}'", option, s),
|
||||||
ParseSizeError::SizeTooBig(_) => format!("--{} argument '{}' too large", option, s),
|
ParseSizeError::SizeTooBig(_) => format!("--{} argument '{}' too large", option, s),
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
// *
|
// *
|
||||||
// * For the full copyright and license information, please view the LICENSE
|
// * For the full copyright and license information, please view the LICENSE
|
||||||
// * file that was distributed with this source code.
|
// * file that was distributed with this source code.
|
||||||
// *
|
|
||||||
|
|
||||||
// spell-checker:ignore (ToDO) seekable seek'd tail'ing ringbuffer ringbuf
|
// spell-checker:ignore (ToDO) seekable seek'd tail'ing ringbuffer ringbuf
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
crash!(
|
crash!(
|
||||||
1,
|
1,
|
||||||
"cannot stat '{}': No such file or directory",
|
"cannot stat '{}': No such file or directory",
|
||||||
reference.unwrap_or("".to_string())
|
reference.unwrap_or_else(|| "".to_string())
|
||||||
); // TODO: fix '--no-create' see test_reference and test_truncate_bytes_size
|
); // TODO: fix '--no-create' see test_reference and test_truncate_bytes_size
|
||||||
}
|
}
|
||||||
_ => crash!(1, "{}", e.to_string()),
|
_ => crash!(1, "{}", e.to_string()),
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub extern crate winapi;
|
||||||
mod features; // feature-gated code modules
|
mod features; // feature-gated code modules
|
||||||
mod macros; // crate macros (macro_rules-type; exported to `crate::...`)
|
mod macros; // crate macros (macro_rules-type; exported to `crate::...`)
|
||||||
mod mods; // core cross-platform modules
|
mod mods; // core cross-platform modules
|
||||||
mod parser; // string parsing moduls
|
mod parser; // string parsing modules
|
||||||
|
|
||||||
// * cross-platform modules
|
// * cross-platform modules
|
||||||
pub use crate::mods::backup_control;
|
pub use crate::mods::backup_control;
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
// * For the full copyright and license information, please view the LICENSE
|
// * For the full copyright and license information, please view the LICENSE
|
||||||
// * file that was distributed with this source code.
|
// * file that was distributed with this source code.
|
||||||
|
|
||||||
|
// spell-checker:ignore (ToDO) hdsf ghead gtail
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -77,7 +79,7 @@ pub fn parse_size(size: &str) -> Result<usize, ParseSizeError> {
|
||||||
};
|
};
|
||||||
number
|
number
|
||||||
.checked_mul(factor)
|
.checked_mul(factor)
|
||||||
.ok_or(ParseSizeError::size_too_big(size))
|
.ok_or_else(|| ParseSizeError::size_too_big(size))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
// * This file is part of the uutils coreutils package.
|
||||||
|
// *
|
||||||
|
// * For the full copyright and license information, please view the LICENSE
|
||||||
|
// * file that was distributed with this source code.
|
||||||
|
|
||||||
// spell-checker:ignore (paths) sublink subwords
|
// spell-checker:ignore (paths) sublink subwords
|
||||||
|
|
||||||
use crate::common::util::*;
|
use crate::common::util::*;
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
// spell-checker:ignore (words) bogusfile emptyfile
|
// * This file is part of the uutils coreutils package.
|
||||||
|
// *
|
||||||
|
// * For the full copyright and license information, please view the LICENSE
|
||||||
|
// * file that was distributed with this source code.
|
||||||
|
|
||||||
|
// spell-checker:ignore (words) bogusfile emptyfile abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstu
|
||||||
|
|
||||||
use crate::common::util::*;
|
use crate::common::util::*;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
// * This file is part of the uutils coreutils package.
|
||||||
|
// *
|
||||||
|
// * For the full copyright and license information, please view the LICENSE
|
||||||
|
// * file that was distributed with this source code.
|
||||||
|
|
||||||
extern crate unindent;
|
extern crate unindent;
|
||||||
|
|
||||||
use self::unindent::*;
|
use self::unindent::*;
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
// * This file is part of the uutils coreutils package.
|
||||||
|
// *
|
||||||
|
// * For the full copyright and license information, please view the LICENSE
|
||||||
|
// * file that was distributed with this source code.
|
||||||
|
|
||||||
// spell-checker:ignore (words) ints
|
// spell-checker:ignore (words) ints
|
||||||
|
|
||||||
use crate::common::util::*;
|
use crate::common::util::*;
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
// * This file is part of the uutils coreutils package.
|
||||||
|
// *
|
||||||
|
// * For the full copyright and license information, please view the LICENSE
|
||||||
|
// * file that was distributed with this source code.
|
||||||
|
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
extern crate regex;
|
extern crate regex;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
// * This file is part of the uutils coreutils package.
|
||||||
|
// *
|
||||||
|
// * For the full copyright and license information, please view the LICENSE
|
||||||
|
// * file that was distributed with this source code.
|
||||||
|
|
||||||
|
// spell-checker:ignore (ToDO) abcdefghijklmnopqrstuvwxyz efghijklmnopqrstuvwxyz vwxyz emptyfile
|
||||||
|
|
||||||
extern crate tail;
|
extern crate tail;
|
||||||
|
|
||||||
use crate::common::util::*;
|
use crate::common::util::*;
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
// * This file is part of the uutils coreutils package.
|
||||||
|
// *
|
||||||
|
// * For the full copyright and license information, please view the LICENSE
|
||||||
|
// * file that was distributed with this source code.
|
||||||
|
|
||||||
|
// spell-checker:ignore (words) RFILE
|
||||||
|
|
||||||
use crate::common::util::*;
|
use crate::common::util::*;
|
||||||
use std::io::{Seek, SeekFrom, Write};
|
use std::io::{Seek, SeekFrom, Write};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue