Skip to content

numfmt: name the only conversion in a bad --format directive - #14001

Merged
sylvestre merged 1 commit into
uutils:mainfrom
sylvestre:numfmt
Aug 18, 2026
Merged

numfmt: name the only conversion in a bad --format directive#14001
sylvestre merged 1 commit into
uutils:mainfrom
sylvestre:numfmt

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

An invalid --format directive pointed at a single character, and said nothing about what numfmt would have accepted there. Label the caret with the one conversion numfmt has, since %d, %e and the other C conversions are commonly tried there -- but only where one was actually typed: a format that ends before its conversion, as in "%10", has none to name, and only the character standing in for the f is at fault, so a valid suffix after it stays out of the underline.

The caret a refused number gets is placed the same way, and now:

  • survives a whitespace-only operand, whose leading and trailing offsets crossed and panicked when sliced;
  • lands on the operand rather than on the detached value of an earlier option that happens to carry the same text, as in --suffix q --from si q;
  • keeps quiet about suffixes for an input holding no number at all, a lone sign being the start of one but not yet one.

A unit size loses the "must be at least 1" label when an unknown suffix, not the zero, is what it got wrong.

Copilot AI lite review requested due to automatic review settings August 18, 2026 11:54

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Only --format and --field pointed a caret at what they refused. Carry the
option name and the value as typed out of parsing, so --from, --to, --from-unit,
--to-unit, --padding and --header underline their value on the command line,
and so does a number operand that fails to convert. Each gets a help line
naming what the option takes, and a label where the help is not enough: auto
being a unit only --from can use, or a zero that parses fine and fails on
meaning.

A bad --format directive gains one too, naming the single conversion numfmt
has, since %d, %e and friends are commonly tried there -- but only where one
was typed: "%10" has none to name.

Placing the caret on an operand also fixes a panic on a whitespace-only one,
whose offsets crossed when sliced; puts it on the operand rather than on the
detached value of an earlier option holding the same text, as in
`--suffix q --from si q`; and drops the suffix advice for input with no number
at all.
@codspeed-hq

codspeed-hq Bot commented Aug 18, 2026

Copy link
Copy Markdown

Merging this PR will regress 2 benchmarks

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
❌ 2 regressed benchmarks
✅ 353 untouched benchmarks
⏩ 50 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory numfmt_stream_to_si_precision 128.5 KB 140.5 KB -8.55%
Simulation numfmt_large_numbers_si[10000] 93.2 ms 96.7 ms -3.71%
Simulation numfmt_stream_to_si_precision 390.9 ms 346.4 ms +12.86%
Simulation numfmt_stream_to_si 431.1 ms 414.1 ms +4.11%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing sylvestre:numfmt (0a3a7ba) with main (bfd7c63)

Open in CodSpeed

Footnotes

  1. 50 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

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/cp/link-heap is now passing!
Congrats! The gnu test tests/rm/many-dir-entries-vs-OOM is now passing!
Congrats! The gnu test tests/seq/seq-epipe is now passing!

@sylvestre
sylvestre merged commit 1a36740 into uutils:main Aug 18, 2026
169 of 170 checks passed
@sylvestre
sylvestre deleted the numfmt branch August 18, 2026 13:29
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.

2 participants