mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
numfmt: stop a clone
This commit is contained in:
Generated
+1
@@ -3779,6 +3779,7 @@ dependencies = [
|
||||
"clap",
|
||||
"codspeed-divan-compat",
|
||||
"fluent",
|
||||
"memchr",
|
||||
"thiserror 2.0.18",
|
||||
"uucore",
|
||||
]
|
||||
|
||||
@@ -23,6 +23,7 @@ clap = { workspace = true }
|
||||
uucore = { workspace = true, features = ["parser", "ranges"] }
|
||||
thiserror = { workspace = true }
|
||||
fluent = { workspace = true }
|
||||
memchr = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
divan = { workspace = true }
|
||||
|
||||
@@ -87,21 +87,19 @@ fn write_line<W: std::io::Write>(
|
||||
eol: Option<u8>,
|
||||
) -> UResult<()> {
|
||||
// Read lines only up to null byte (as GNU does)
|
||||
let line = input_line
|
||||
.iter()
|
||||
.take_while(|&&b| b != b'\0')
|
||||
.copied()
|
||||
.collect::<Vec<u8>>();
|
||||
|
||||
let line = match memchr::memchr(b'\0', input_line) {
|
||||
Some(i) => &input_line[..i],
|
||||
None => input_line,
|
||||
};
|
||||
let handled_line = if options.delimiter.is_some() {
|
||||
write_formatted_with_delimiter(writer, &line, options, eol)
|
||||
write_formatted_with_delimiter(writer, line, options, eol)
|
||||
} else {
|
||||
// Whitespace mode requires valid UTF-8
|
||||
match std::str::from_utf8(&line) {
|
||||
match std::str::from_utf8(line) {
|
||||
Ok(s) => write_formatted_with_whitespace(writer, s, options, eol),
|
||||
Err(_) => Err(
|
||||
translate!("numfmt-error-invalid-number", "input" => escape_line(&line).quote()),
|
||||
),
|
||||
Err(_) => {
|
||||
Err(translate!("numfmt-error-invalid-number", "input" => escape_line(line).quote()))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user