Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .vscode/cspell.dictionaries/workspace.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ exacl
filetime
formatteriteminfo
fsext
fundu
getopts
getrandom
globset
Expand Down
16 changes: 0 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coreutils (uutils)
# * see the repository LICENSE, README, and CONTRIBUTING files for more information

# spell-checker:ignore (libs) bigdecimal datetime serde bincode fundu gethostid kqueue libselinux mangen memmap procfs uuhelp startswith constness expl
# spell-checker:ignore (libs) bigdecimal datetime serde bincode gethostid kqueue libselinux mangen memmap procfs uuhelp startswith constness expl

[package]
name = "coreutils"
Expand Down Expand Up @@ -301,7 +301,6 @@ filetime = "0.2.23"
fnv = "1.0.7"
fs_extra = "1.3.0"
fts-sys = "0.2.16"
fundu = "2.0.0"
gcd = "2.3"
glob = "0.3.1"
half = "2.4.1"
Expand Down
3 changes: 2 additions & 1 deletion fuzz/fuzz_targets/fuzz_parse_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use uucore::parser::parse_time;

fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
_ = parse_time::from_str(s);
_ = parse_time::from_str(s, true);
_ = parse_time::from_str(s, false);
}
});
2 changes: 1 addition & 1 deletion src/uu/sleep/src/sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn sleep(args: &[&str]) -> UResult<()> {

let sleep_dur = args
.iter()
.filter_map(|input| match parse_time::from_str(input) {
.filter_map(|input| match parse_time::from_str(input, true) {
Ok(duration) => Some(duration),
Err(error) => {
arg_error = true;
Expand Down
3 changes: 1 addition & 2 deletions src/uu/tail/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# spell-checker:ignore (libs) kqueue fundu
# spell-checker:ignore (libs) kqueue
[package]
name = "uu_tail"
description = "tail ~ (uutils) display the last lines of input"
Expand All @@ -25,7 +25,6 @@ memchr = { workspace = true }
notify = { workspace = true }
uucore = { workspace = true, features = ["parser"] }
same-file = { workspace = true }
fundu = { workspace = true }

[target.'cfg(windows)'.dependencies]
windows-sys = { workspace = true, features = [
Expand Down
23 changes: 5 additions & 18 deletions src/uu/tail/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

// spell-checker:ignore (ToDO) kqueue Signum fundu
// spell-checker:ignore (ToDO) kqueue Signum

use crate::paths::Input;
use crate::{Quotable, parse, platform};
use clap::{Arg, ArgAction, ArgMatches, Command, value_parser};
use fundu::{DurationParser, SaturatingInto};
use same_file::Handle;
use std::ffi::OsString;
use std::io::IsTerminal;
use std::time::Duration;
use uucore::error::{UResult, USimpleError, UUsageError};
use uucore::parser::parse_size::{ParseSizeError, parse_size_u64};
use uucore::parser::parse_time;
use uucore::parser::shortcut_value_parser::ShortcutValueParser;
use uucore::{format_usage, help_about, help_usage, show_warning};

Expand Down Expand Up @@ -228,22 +228,9 @@ impl Settings {
};

if let Some(source) = matches.get_one::<String>(options::SLEEP_INT) {
// Advantage of `fundu` over `Duration::(try_)from_secs_f64(source.parse().unwrap())`:
// * doesn't panic on errors like `Duration::from_secs_f64` would.
// * no precision loss, rounding errors or other floating point problems.
// * evaluates to `Duration::MAX` if the parsed number would have exceeded
// `DURATION::MAX` or `infinity` was given
// * not applied here but it supports customizable time units and provides better error
// messages
settings.sleep_sec = match DurationParser::without_time_units().parse(source) {
Ok(duration) => SaturatingInto::<Duration>::saturating_into(duration),
Err(_) => {
return Err(UUsageError::new(
1,
format!("invalid number of seconds: '{source}'"),
));
}
}
settings.sleep_sec = parse_time::from_str(source, false).map_err(|_| {
UUsageError::new(1, format!("invalid number of seconds: '{source}'"))
})?;
}

if let Some(s) = matches.get_one::<String>(options::MAX_UNCHANGED_STATS) {
Expand Down
8 changes: 3 additions & 5 deletions src/uu/timeout/src/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,15 @@ impl Config {

let kill_after = match options.get_one::<String>(options::KILL_AFTER) {
None => None,
Some(kill_after) => match parse_time::from_str(kill_after) {
Some(kill_after) => match parse_time::from_str(kill_after, true) {
Ok(k) => Some(k),
Err(err) => return Err(UUsageError::new(ExitStatus::TimeoutFailed.into(), err)),
},
};

let duration =
match parse_time::from_str(options.get_one::<String>(options::DURATION).unwrap()) {
Ok(duration) => duration,
Err(err) => return Err(UUsageError::new(ExitStatus::TimeoutFailed.into(), err)),
};
parse_time::from_str(options.get_one::<String>(options::DURATION).unwrap(), true)
.map_err(|err| UUsageError::new(ExitStatus::TimeoutFailed.into(), err))?;

let preserve_status: bool = options.get_flag(options::PRESERVE_STATUS);
let foreground = options.get_flag(options::FOREGROUND);
Expand Down
Loading
Loading