mirror of
https://github.com/uutils/coreutils
synced 2024-07-03 07:58:37 +00:00
Compare commits
12 Commits
0fda5a56c2
...
76242042c0
Author | SHA1 | Date | |
---|---|---|---|
|
76242042c0 | ||
|
69b603bfe7 | ||
|
e4ec608781 | ||
|
371ba28db7 | ||
|
7d77a3730c | ||
|
4b0090b323 | ||
|
cc8a9f4c1b | ||
|
0ecc18fb5b | ||
|
11e8476456 | ||
|
2f0b37c7f4 | ||
|
3b607f1c7c | ||
|
b0716baeae |
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1493,9 +1493,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.5"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7"
|
||||
checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
|
||||
dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
|
|
|
@ -21,6 +21,9 @@ edition = "2021"
|
|||
|
||||
build = "build.rs"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
||||
[features]
|
||||
default = ["feat_common_core"]
|
||||
## OS feature shortcodes
|
||||
|
@ -30,6 +33,7 @@ windows = ["feat_os_windows"]
|
|||
## project-specific feature shortcodes
|
||||
nightly = []
|
||||
test_unimplemented = []
|
||||
expensive_tests = []
|
||||
# * only build `uudoc` when `--feature uudoc` is activated
|
||||
uudoc = ["zip", "dep:uuhelp_parser"]
|
||||
## features
|
||||
|
|
|
@ -227,11 +227,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
Box::new(iter)
|
||||
}
|
||||
DateSource::Human(relative_time) => {
|
||||
// Get the current DateTime<FixedOffset> for things like "1 year ago"
|
||||
let current_time = DateTime::<FixedOffset>::from(Local::now());
|
||||
// double check the result is overflow or not of the current_time + relative_time
|
||||
// Double check the result is overflow or not of the current_time + relative_time
|
||||
// it may cause a panic of chrono::datetime::DateTime add
|
||||
match current_time.checked_add_signed(relative_time) {
|
||||
match now.checked_add_signed(relative_time) {
|
||||
Some(date) => {
|
||||
let iter = std::iter::once(Ok(date));
|
||||
Box::new(iter)
|
||||
|
|
|
@ -207,16 +207,9 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
|
|||
binary_flag_default
|
||||
};
|
||||
let check = matches.get_flag("check");
|
||||
let tag = matches.get_flag("tag");
|
||||
let nonames = *matches
|
||||
.try_get_one("no-names")
|
||||
.unwrap_or(None)
|
||||
.unwrap_or(&false);
|
||||
let status = matches.get_flag("status");
|
||||
let quiet = matches.get_flag("quiet") || status;
|
||||
//let strict = matches.get_flag("strict");
|
||||
let warn = matches.get_flag("warn") && !status;
|
||||
let zero = matches.get_flag("zero");
|
||||
let ignore_missing = matches.get_flag("ignore-missing");
|
||||
|
||||
if ignore_missing && !check {
|
||||
|
@ -224,22 +217,6 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
|
|||
return Err(ChecksumError::IgnoreNotCheck.into());
|
||||
}
|
||||
|
||||
let opts = Options {
|
||||
algoname: algo.name,
|
||||
digest: (algo.create_fn)(),
|
||||
output_bits: algo.bits,
|
||||
binary,
|
||||
//check,
|
||||
tag,
|
||||
nonames,
|
||||
//status,
|
||||
//quiet,
|
||||
//strict,
|
||||
//warn,
|
||||
zero,
|
||||
//ignore_missing,
|
||||
};
|
||||
|
||||
if check {
|
||||
let text_flag = matches.get_flag("text");
|
||||
let binary_flag = matches.get_flag("binary");
|
||||
|
@ -270,6 +247,26 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
|
|||
);
|
||||
}
|
||||
|
||||
let nonames = *matches
|
||||
.try_get_one("no-names")
|
||||
.unwrap_or(None)
|
||||
.unwrap_or(&false);
|
||||
let zero = matches.get_flag("zero");
|
||||
|
||||
let opts = Options {
|
||||
algoname: algo.name,
|
||||
digest: (algo.create_fn)(),
|
||||
output_bits: algo.bits,
|
||||
binary,
|
||||
tag: matches.get_flag("tag"),
|
||||
nonames,
|
||||
//status,
|
||||
//quiet,
|
||||
//warn,
|
||||
zero,
|
||||
//ignore_missing,
|
||||
};
|
||||
|
||||
// Show the hashsum of the input
|
||||
match matches.get_many::<OsString>(options::FILE) {
|
||||
Some(files) => hashsum(opts, files.map(|f| f.as_os_str())),
|
||||
|
|
|
@ -502,7 +502,6 @@ where
|
|||
get_expected_checksum(filename_to_check, &caps, &chosen_regex)?;
|
||||
|
||||
// If the algo_name is provided, we use it, otherwise we try to detect it
|
||||
|
||||
let (algo_name, length) = if is_algo_based_format {
|
||||
identify_algo_name_and_length(
|
||||
&caps,
|
||||
|
@ -513,7 +512,15 @@ where
|
|||
.unwrap_or((String::new(), None))
|
||||
} else if let Some(a) = algo_name_input {
|
||||
// When a specific algorithm name is input, use it and use the provided bits
|
||||
(a.to_lowercase(), length_input)
|
||||
// except when dealing with blake2b, where we will detect the length
|
||||
if algo_name_input == Some(ALGORITHM_OPTIONS_BLAKE2B) {
|
||||
// division by 2 converts the length of the Blake2b checksum from hexadecimal
|
||||
// characters to bytes, as each byte is represented by two hexadecimal characters.
|
||||
let length = Some(expected_checksum.len() / 2);
|
||||
(ALGORITHM_OPTIONS_BLAKE2B.to_string(), length)
|
||||
} else {
|
||||
(a.to_lowercase(), length_input)
|
||||
}
|
||||
} else {
|
||||
// Default case if no algorithm is specified and non-algo based format is matched
|
||||
(String::new(), None)
|
||||
|
|
|
@ -141,6 +141,16 @@ fn test_date_utc() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_date_utc_issue_6495() {
|
||||
new_ucmd!()
|
||||
.arg("-u")
|
||||
.arg("-d")
|
||||
.arg("@0")
|
||||
.succeeds()
|
||||
.stdout_is("Thu Jan 1 00:00:00 1970\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_date_format_y() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
|
|
|
@ -890,3 +890,39 @@ fn test_star_to_start() {
|
|||
.succeeds()
|
||||
.stdout_only("f: OK\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_check_b2sum_strict_check() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
at.touch("f");
|
||||
|
||||
let checksums = [
|
||||
"2e f\n",
|
||||
"e4a6a0577479b2b4 f\n",
|
||||
"cae66941d9efbd404e4d88758ea67670 f\n",
|
||||
"246c0442cd564aced8145b8b60f1370aa7 f\n",
|
||||
"0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8 f\n",
|
||||
"4ded8c5fc8b12f3273f877ca585a44ad6503249a2b345d6d9c0e67d85bcb700db4178c0303e93b8f4ad758b8e2c9fd8b3d0c28e585f1928334bb77d36782e8 f\n",
|
||||
"786a02f742015903c6c6fd852552d272912f4740e15847618a86e217f71f5419d25e1031afee585313896444934eb04b903a685b1448b755d56f701afe9be2ce f\n",
|
||||
];
|
||||
|
||||
at.write("ck", &checksums.join(""));
|
||||
|
||||
let output = "f: OK\n".to_string().repeat(checksums.len());
|
||||
|
||||
scene
|
||||
.ccmd("b2sum")
|
||||
.arg("-c")
|
||||
.arg(at.subdir.join("ck"))
|
||||
.succeeds()
|
||||
.stdout_only(&output);
|
||||
|
||||
scene
|
||||
.ccmd("b2sum")
|
||||
.arg("--strict")
|
||||
.arg("-c")
|
||||
.arg(at.subdir.join("ck"))
|
||||
.succeeds()
|
||||
.stdout_only(&output);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user