mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-07 08:27:46 +00:00
dd, printf, seq: update to new printf
This commit is contained in:
parent
a3e68d5bbd
commit
66eb64e41f
6 changed files with 10 additions and 19 deletions
|
@ -18,7 +18,7 @@ path = "src/dd.rs"
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
gcd = { workspace = true }
|
gcd = { workspace = true }
|
||||||
libc = { workspace = true }
|
libc = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["memo"] }
|
uucore = { workspace = true, features = ["format"] }
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "linux"))'.dependencies]
|
[target.'cfg(any(target_os = "linux"))'.dependencies]
|
||||||
nix = { workspace = true, features = ["fs"] }
|
nix = { workspace = true, features = ["fs"] }
|
||||||
|
|
|
@ -14,7 +14,7 @@ use std::sync::mpsc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use uucore::error::UResult;
|
use uucore::error::UResult;
|
||||||
use uucore::memo::sprintf;
|
use uucore::format::sprintf;
|
||||||
|
|
||||||
use crate::numbers::{to_magnitude_and_suffix, SuffixType};
|
use crate::numbers::{to_magnitude_and_suffix, SuffixType};
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ path = "src/printf.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["memo"] }
|
uucore = { workspace = true, features = ["format"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "printf"
|
name = "printf"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use clap::{crate_version, Arg, ArgAction, Command};
|
use clap::{crate_version, Arg, ArgAction, Command};
|
||||||
use uucore::error::{UResult, UUsageError};
|
use uucore::error::{UResult, UUsageError};
|
||||||
use uucore::memo::printf;
|
use uucore::format::printf;
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage};
|
use uucore::{format_usage, help_about, help_section, help_usage};
|
||||||
|
|
||||||
const VERSION: &str = "version";
|
const VERSION: &str = "version";
|
||||||
|
|
|
@ -20,7 +20,7 @@ bigdecimal = { workspace = true }
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
num-bigint = { workspace = true }
|
num-bigint = { workspace = true }
|
||||||
num-traits = { workspace = true }
|
num-traits = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["memo"] }
|
uucore = { workspace = true, features = ["format"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "seq"
|
name = "seq"
|
||||||
|
|
|
@ -4,15 +4,12 @@
|
||||||
// * file that was distributed with this source code.
|
// * file that was distributed with this source code.
|
||||||
// spell-checker:ignore (ToDO) istr chiter argptr ilen extendedbigdecimal extendedbigint numberparse
|
// spell-checker:ignore (ToDO) istr chiter argptr ilen extendedbigdecimal extendedbigint numberparse
|
||||||
use std::io::{stdout, ErrorKind, Write};
|
use std::io::{stdout, ErrorKind, Write};
|
||||||
use std::process::exit;
|
|
||||||
|
|
||||||
use clap::{crate_version, Arg, ArgAction, Command};
|
use clap::{crate_version, Arg, ArgAction, Command};
|
||||||
use num_traits::Zero;
|
use num_traits::Zero;
|
||||||
|
|
||||||
use uucore::error::FromIo;
|
|
||||||
use uucore::error::UResult;
|
use uucore::error::UResult;
|
||||||
use uucore::memo::printf;
|
use uucore::format::printf;
|
||||||
use uucore::show;
|
|
||||||
use uucore::{format_usage, help_about, help_usage};
|
use uucore::{format_usage, help_about, help_usage};
|
||||||
|
|
||||||
mod error;
|
mod error;
|
||||||
|
@ -251,7 +248,7 @@ fn print_seq(
|
||||||
pad: bool,
|
pad: bool,
|
||||||
padding: usize,
|
padding: usize,
|
||||||
format: Option<&str>,
|
format: Option<&str>,
|
||||||
) -> std::io::Result<()> {
|
) -> UResult<()> {
|
||||||
let stdout = stdout();
|
let stdout = stdout();
|
||||||
let mut stdout = stdout.lock();
|
let mut stdout = stdout.lock();
|
||||||
let (first, increment, last) = range;
|
let (first, increment, last) = range;
|
||||||
|
@ -277,10 +274,7 @@ fn print_seq(
|
||||||
match format {
|
match format {
|
||||||
Some(f) => {
|
Some(f) => {
|
||||||
let s = format!("{value}");
|
let s = format!("{value}");
|
||||||
if let Err(x) = printf(f, &[s]) {
|
printf(f, &[s])?;
|
||||||
show!(x);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => write_value_float(
|
None => write_value_float(
|
||||||
&mut stdout,
|
&mut stdout,
|
||||||
|
@ -322,7 +316,7 @@ fn print_seq_integers(
|
||||||
pad: bool,
|
pad: bool,
|
||||||
padding: usize,
|
padding: usize,
|
||||||
format: Option<&str>,
|
format: Option<&str>,
|
||||||
) -> std::io::Result<()> {
|
) -> UResult<()> {
|
||||||
let stdout = stdout();
|
let stdout = stdout();
|
||||||
let mut stdout = stdout.lock();
|
let mut stdout = stdout.lock();
|
||||||
let (first, increment, last) = range;
|
let (first, increment, last) = range;
|
||||||
|
@ -342,10 +336,7 @@ fn print_seq_integers(
|
||||||
match format {
|
match format {
|
||||||
Some(f) => {
|
Some(f) => {
|
||||||
let s = format!("{value}");
|
let s = format!("{value}");
|
||||||
if let Err(x) = printf(f, &[s]) {
|
printf(f, &[s])?;
|
||||||
show!(x);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => write_value_int(&mut stdout, &value, padding, pad, is_first_iteration)?,
|
None => write_value_int(&mut stdout, &value, padding, pad, is_first_iteration)?,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue