mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 07:12:44 +00:00
Merge pull request #4215 from sylvestre/busybox3
factor: trim the input to fix some busybox results
This commit is contained in:
commit
321866aae9
2 changed files with 12 additions and 8 deletions
|
@ -35,12 +35,16 @@ fn print_factors_str(
|
|||
w: &mut io::BufWriter<impl io::Write>,
|
||||
factors_buffer: &mut String,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
num_str.parse::<u64>().map_err(|e| e.into()).and_then(|x| {
|
||||
factors_buffer.clear();
|
||||
writeln!(factors_buffer, "{}:{}", x, factor(x))?;
|
||||
w.write_all(factors_buffer.as_bytes())?;
|
||||
Ok(())
|
||||
})
|
||||
num_str
|
||||
.trim()
|
||||
.parse::<u64>()
|
||||
.map_err(|e| e.into())
|
||||
.and_then(|x| {
|
||||
factors_buffer.clear();
|
||||
writeln!(factors_buffer, "{}:{}", x, factor(x))?;
|
||||
w.write_all(factors_buffer.as_bytes())?;
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
#[uucore::main]
|
||||
|
|
|
@ -108,10 +108,10 @@ fn test_cli_args() {
|
|||
new_ucmd!().args(&["3"]).succeeds().stdout_contains("3: 3");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["3", "6"])
|
||||
.args(&["3", "6", " +9"])
|
||||
.succeeds()
|
||||
.stdout_contains("3: 3")
|
||||
.stdout_contains("6: 2 3");
|
||||
.stdout_contains("9: 3 3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue