Skip to content

seq: read and write numbers with the locale's decimal point - #16688

Open
Xnadir wants to merge 2 commits into
uutils:mainfrom
Xnadir:seq-locale-decimal-point
Open

Xnadir wants to merge 2 commits into
uutils:mainfrom
Xnadir:seq-locale-decimal-point

Conversation

@Xnadir

@Xnadir Xnadir commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

In a locale whose decimal point is not ., seq rejected operands such as 0,25 (invalid floating point argument) and -,75 (taken for an option). It also printed 0.25 where GNU prints 0,25.

  • seq now reads uucore::i18n::decimal::locale_decimal_separator() (enabling i18n-decimal for it). An operand's locale separator is turned into . before parsing, and . is still accepted. Error messages show the operand as given.
  • mark_first_operand treats - followed by the separator as a number, so seq -,75 1 works.
  • Output goes through a new Format::fmt_with_decimal_separator in uucore. It replaces the . of the formatted number only, so a . in the text of a -f format stays. With . as the separator it is the old fmt, and the integer fast path is unchanged.

This un-ignores test_locale_decimal_point_operands, added in #16493. That test skips itself where fr_FR.UTF-8 isn't installed, which includes this Windows machine, so I also ran the binary with LC_ALL=fr_FR.UTF-8: the three cases give the expected 0,25 0,50 0,75 1,00, -0,75 0,25 and 2,0 1,5 1,0; -w, -f %.3f and -f v%g. give 0,5 … 2,0, 1,000 … and v1,5.; the C locale is unchanged. All test_seq tests and the uucore format unit tests pass.

Closes #16506

AI disclosure: written with help from Claude Code.

Copilot AI balanced review requested due to automatic review settings November 18, 2026 15:31

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 insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Comment thread tests/by-util/test_seq.rs
@@ -1339,7 +1339,6 @@ fn test_stalled_value_stops(#[case] args: &[&str], #[case] expected: &str) {
#[case::comma_operands(&["0,25", "0,25", "1"], "0,25\n0,50\n0,75\n1,00\n")]
#[case::negative_comma_first(&["-,75", "1"], "-0,75\n0,25\n")]
#[case::negative_comma_increment(&["2", "-0,5", "1"], "2,0\n1,5\n1,0\n")]

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.

could you please add cases for -w, -f %.3f and -f v%g. (the literal . must stay)? you checked them by hand, they should be in the test


/// Like [`Self::fmt`], but writes `decimal_separator` in place of the `.`
/// of the formatted number. A `.` in the text around it is kept.
pub fn fmt_with_decimal_separator(

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.

please add a unit test for this one in the tests module below

if decimal_separator == "." {
return self.fmt(w, f);
}
let mut number = Vec::new();

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.

this allocates a Vec per number, could you reuse one buffer from the caller? seq calls it in a loop

@github-actions

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.31 MB (-76 KB, -0.05%)

Significant per-binary changes:
  env     1.20 MB ->    1.28 MB  (+80 KB, +6.51%)
  seq     1.30 MB ->    1.37 MB  (+72 KB, +5.41%)

@codspeed

codspeed Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 1.55%

3 warnings, 1 note

⚠️ 126 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 3 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 3 benchmarks with a significant change ran in a different software environment

Their base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the changes might come from this difference rather than from the code. Open an affected benchmark to see what changed.

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 3 improved benchmarks
❌ 2 regressed benchmarks
✅ 386 untouched benchmarks
⏩ 92 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation split_number_chunks_round_robin 28.9 ms 32.8 ms -11.82%
❌ CPU Simulation seq_formatted 141.4 ms 147.9 ms -4.39%
⚡ CPU Simulation dd_copy_with_skip 4.9 ms 4.8 ms +3.23%
⚡ CPU Simulation dd_copy_with_seek 5 ms 4.9 ms +3.17%
⚡ CPU Simulation dd_copy_8k_blocks 1.9 ms 1.9 ms +3.01%

Tip

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


Comparing Xnadir:seq-locale-decimal-point (df44c95) with main (e1b90fa)2

Open in CodSpeed

Footnotes

  1. 92 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. ↩

  2. No successful run was found on main (066f9d0) during the generation of this report, so e1b90fa was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Copilot AI balanced review requested due to automatic review settings November 19, 2026 22:59

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 insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

This branch has not been deployed

No deployments
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.

seq: locale decimal point not accepted

3 participants