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

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Binary size comparison:

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

Total size of compared binaries: 155.48 MB (+68 KB, +0.04%)

Significant per-binary changes:
  seq     1.30 MB ->    1.37 MB  (+68 KB, +5.09%)

@codspeed

codspeed Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will regress 1 benchmark

1 warning, 1 note

⚠️ 123 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

ℹ️ 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

⚡ 12 improved benchmarks
❌ 1 regressed benchmark
✅ 400 untouched benchmarks
⏩ 70 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation seq_formatted 141.4 ms 148.1 ms -4.5%
⚡ CPU Simulation file_custom_format 15.8 ms 11.5 ms +38.18%
⚡ CPU Simulation file_iso_dates 17.7 ms 13.4 ms +32.31%
⚡ CPU Simulation file_localized_names 27.1 ms 22.7 ms +19.31%
⚡ CPU Simulation split_number_chunks_round_robin 32.8 ms 28.9 ms +13.4%
⚡ CPU Simulation file_tz_abbreviations 18.1 ms 16.8 ms +7.74%
⚡ CPU Simulation cksum_crc 34.5 ms 33.1 ms +4.11%
⚡ CPU Simulation cksum_raw_output 34.7 ms 33.3 ms +4.08%
⚡ CPU Simulation cksum_multiple_files 51.5 ms 49.5 ms +4.03%
⚡ CPU Simulation du_wide_tree[(5000, 500)] 15.7 ms 15.2 ms +3.33%
⚡ CPU Simulation dd_copy_with_skip 4.9 ms 4.8 ms +3.27%
⚡ CPU Simulation dd_copy_8k_blocks 1.9 ms 1.9 ms +3.2%
⚡ CPU Simulation dd_copy_with_seek 5 ms 4.9 ms +3.19%

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 (ab7520d) with main (9d6c862)2

Open in CodSpeed

Footnotes

  1. 70 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 (07b76df) during the generation of this report, so 9d6c862 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.

@sylvestre
sylvestre force-pushed the seq-locale-decimal-point branch from ab7520d to b40a993 Compare November 21, 2026 17:42
Copilot AI balanced review requested due to automatic review settings November 21, 2026 17:42

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