Skip to content

fix(numfmt): format output on error messages#11179

Merged
cakebaker merged 2 commits intouutils:mainfrom
FidelSch:numfmt-error-format
Mar 4, 2026
Merged

fix(numfmt): format output on error messages#11179
cakebaker merged 2 commits intouutils:mainfrom
FidelSch:numfmt-error-format

Conversation

@FidelSch
Copy link
Copy Markdown
Contributor

@FidelSch FidelSch commented Mar 2, 2026

fixes #11116

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/date/resolution (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/unexpand/bounded-memory is now being skipped but was previously passing.

pub(crate) fn escape_line(line: &[u8]) -> String {
line.iter()
.map(|&b| {
if b.is_ascii_graphic() || b.is_ascii_whitespace() {
Copy link
Copy Markdown
Contributor

@cakebaker cakebaker Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunately more complex because line also can contain valid UTF-8 multi-byte characters:

$ printf "10\n\xFF🦀" | cargo run -q numfmt
10
numfmt: invalid number: '\377\360\237\246\200'
$ printf "10\n\xFF🦀" | numfmt
10
numfmt: invalid number: ‘\377🦀’

I don't know if you want to address it in this PR, otherwise a TODO would be helpful.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch, will give it a shot

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 3, 2026

Merging this PR will not alter performance

✅ 302 untouched benchmarks
⏩ 42 skipped benchmarks1


Comparing FidelSch:numfmt-error-format (9570dd8) with main (e85d07d)

Open in CodSpeed

Footnotes

  1. 42 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 3, 2026

GNU testsuite comparison:

GNU test failed: tests/rm/isatty. tests/rm/isatty is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/tail/symlink (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)

/// Used to safely format invalid input in error messages.
pub(crate) fn escape_line(line: &[u8]) -> String {
let mut result = String::new();
for chunk in line.utf8_chunks() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I didn't know there is such a function in the std :)

@cakebaker cakebaker merged commit 79a076e into uutils:main Mar 4, 2026
162 of 163 checks passed
@cakebaker
Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

numfmt does not load numfmt-error-invalid-input from *.ftl

2 participants