Skip to content

feat(df): add thousands separator support#9090

Open
naoNao89 wants to merge 4 commits intouutils:mainfrom
naoNao89:feature/thousands-separator-df
Open

feat(df): add thousands separator support#9090
naoNao89 wants to merge 4 commits intouutils:mainfrom
naoNao89:feature/thousands-separator-df

Conversation

@naoNao89
Copy link
Contributor

Adds GNU-compatible thousands separator formatting to ls, du, and df. Use a leading quote in --block-size to get readable output: --block-size="'1" shows 1,024,000 instead of 1024000.

Respects LC_NUMERIC locale (comma for en_US, period for European locales, none for C/POSIX). Works with environment variables too (LS_BLOCK_SIZE, DU_BLOCK_SIZE, DF_BLOCK_SIZE, etc.).

Core changes in uucore (parse_size.rs, human.rs) handle the parsing and formatting. Each utility integrates it with minimal changes. 12 new integration tests, all existing tests pass.

Closes #9084

@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch 3 times, most recently from 3ce60cf to 48f4bc1 Compare October 30, 2025 12:40
@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch 2 times, most recently from a8966af to ae09fec Compare October 30, 2025 14:15
@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@naoNao89 naoNao89 closed this by deleting the head repository Nov 6, 2025
@naoNao89 naoNao89 reopened this Nov 7, 2025
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)

@sylvestre
Copy link
Contributor

sylvestre commented Dec 26, 2025

could you please split this per program in different pr ? thanks
it is harder to review otherwise

Copy link
Contributor

Choose a reason for hiding this comment

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

Environment variable reads on every call is inefficient - consider caching the locale information

Copy link
Contributor

Choose a reason for hiding this comment

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

is it?
i don't like this hardcoded list. isn't something in icu to do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oki, replace with ICU's FixedDecimalFormatter

@github-actions
Copy link

GNU testsuite comparison:

Note: The gnu test tests/pr/pr-tests was skipped on 'main' but is now failing.

naoNao89 added a commit to naoNao89/coreutils that referenced this pull request Dec 26, 2025
naoNao89 added a commit to naoNao89/coreutils that referenced this pull request Dec 26, 2025
@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch from 8b92113 to fb15063 Compare December 26, 2025 02:35
naoNao89 added a commit to naoNao89/coreutils that referenced this pull request Dec 26, 2025
@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch from fb15063 to 13225ab Compare December 26, 2025 02:35
@github-actions
Copy link

GNU testsuite comparison:

Note: The gnu test tests/pr/pr-tests was skipped on 'main' but is now failing.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 26, 2025

Merging this PR will not alter performance

✅ 288 untouched benchmarks
⏩ 38 skipped benchmarks1


Comparing naoNao89:feature/thousands-separator-df (7179294) with main (b439534)

Open in CodSpeed

Footnotes

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

GNU testsuite comparison:

Note: The gnu test tests/pr/pr-tests was skipped on 'main' but is now failing.

@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch from 8aa4f8c to c6cb13e Compare December 26, 2025 10:39
@github-actions
Copy link

GNU testsuite comparison:

Note: The gnu test tests/pr/pr-tests was skipped on 'main' but is now failing.

1 similar comment
@github-actions
Copy link

GNU testsuite comparison:

Note: The gnu test tests/pr/pr-tests was skipped on 'main' but is now failing.

@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch from 29d396b to e85ae66 Compare December 26, 2025 11:40
@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch from e85ae66 to 714a5a2 Compare December 26, 2025 15:25
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch from 714a5a2 to 3be82c4 Compare December 26, 2025 18:36
@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch from 148c41f to 286ddf6 Compare February 17, 2026 08:08
naoNao89 added a commit to naoNao89/coreutils that referenced this pull request Feb 17, 2026
Implement thousands separator support for df using GNU coreutils-compatible
leading single quote syntax (--block-size='1K).

Includes:
- extract_thousands_separator_flag() in parse_size.rs
- format_with_thousands_separator() in human.rs with locale support
- BlockSizeConfig struct in df/blocks.rs
- 4 integration tests

Also includes ParserBuilderError for better block size validation
(restored from PR uutils#9090).
@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch from 286ddf6 to d37b5cf Compare February 17, 2026 08:10
naoNao89 added a commit to naoNao89/coreutils that referenced this pull request Feb 17, 2026
Implement thousands separator support for df using GNU coreutils-compatible
leading single quote syntax (--block-size='1K).

Includes:
- extract_thousands_separator_flag() in parse_size.rs
- format_with_thousands_separator() in human.rs with ICU locale support
- BlockSizeConfig struct in df/blocks.rs
- 4 integration tests

Also includes ParserBuilderError for better block size validation
(restored from PR uutils#9090).
@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch from d37b5cf to 22559c7 Compare February 17, 2026 08:11
naoNao89 added a commit to naoNao89/coreutils that referenced this pull request Feb 17, 2026
Implement thousands separator support for df using GNU coreutils-compatible
leading single quote syntax (--block-size='1K).

Includes:
- extract_thousands_separator_flag() in parse_size.rs
- format_with_thousands_separator() in human.rs with ICU locale support
- BlockSizeConfig struct in df/blocks.rs
- 4 integration tests

Also includes ParserBuilderError for better block size validation
(restored from PR uutils#9090).
@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch from 22559c7 to 57ee387 Compare February 17, 2026 08:13
naoNao89 added a commit to naoNao89/coreutils that referenced this pull request Feb 17, 2026
Implement thousands separator support for df using GNU coreutils-compatible
leading single quote syntax (--block-size='1K).

Includes:
- extract_thousands_separator_flag() in parse_size.rs
- format_with_thousands_separator() in human.rs with ICU locale support
- BlockSizeConfig struct in df/blocks.rs
- 4 integration tests

Also includes ParserBuilderError for better block size validation
(restored from PR uutils#9090).
@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch from 57ee387 to 2d6b9c1 Compare February 17, 2026 08:15
naoNao89 added a commit to naoNao89/coreutils that referenced this pull request Feb 17, 2026
Implement thousands separator support for df using GNU coreutils-compatible
leading single quote syntax (--block-size='1K).

Includes:
- extract_thousands_separator_flag() in parse_size.rs
- format_with_thousands_separator() in human.rs with ICU locale support
- BlockSizeConfig struct in df/blocks.rs
- 4 integration tests

Also includes ParserBuilderError for better block size validation
(restored from PR uutils#9090).
@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch from 2d6b9c1 to 7d44f26 Compare February 17, 2026 08:15
naoNao89 added a commit to naoNao89/coreutils that referenced this pull request Feb 17, 2026
Implement thousands separator support for df using GNU coreutils-compatible
leading single quote syntax (--block-size='1K).

Includes:
- extract_thousands_separator_flag() in parse_size.rs
- format_with_thousands_separator() in human.rs with ICU locale support
- BlockSizeConfig struct in df/blocks.rs
- 4 integration tests

Also includes ParserBuilderError for better block size validation
(restored from PR uutils#9090).
@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch from 7d44f26 to ad54cdc Compare February 17, 2026 08:17
Comment on lines +93 to +95
/// // assert_eq!(format_with_thousands_separator(1234567), "1.234.567");
/// ```
pub fn format_with_thousands_separator(number: u64) -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

please write unit test for this function

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/date/date-locale-hour is no longer failing!

@naoNao89
Copy link
Contributor Author

hmm, was hardcoded to 3 now uses ICU locale data: (3,3) for westernor (3,2) for indian locales

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/dd/no-allocate is now passing!
Congrats! The gnu test tests/seq/seq-epipe is now passing!

naoNao89 added a commit to naoNao89/coreutils that referenced this pull request Feb 17, 2026
Implement thousands separator support for df using GNU coreutils-compatible
leading single quote syntax (--block-size='1K).

Includes:
- extract_thousands_separator_flag() in parse_size.rs
- format_with_thousands_separator() in human.rs with ICU locale support
- BlockSizeConfig struct in df/blocks.rs
- 4 integration tests

Also includes ParserBuilderError for better block size validation
(restored from PR uutils#9090).
@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch 3 times, most recently from ceecac6 to bb1de9b Compare February 17, 2026 09:11
Implement thousands separator support for df using GNU coreutils-compatible
leading single quote syntax (--block-size='1K).

Includes:
- extract_thousands_separator_flag() in parse_size.rs
- format_with_thousands_separator() in human.rs with ICU locale support
- BlockSizeConfig struct in df/blocks.rs
- 4 integration tests

Also includes ParserBuilderError for better block size validation
(restored from PR uutils#9090).
Fix build error when i18n-decimal feature is not enabled by:
- Wrapping ICU imports in #[cfg(feature = "i18n-decimal")]
- Providing fallback implementation that returns comma separator
Add support for Indian numbering system (hi_IN) and other locales
with non-standard grouping:

- Add locale_grouping_sizes() to decimal.rs returning (primary, secondary)
- Update format_with_thousands_separator() to use locale-aware groups
- Most locales: (3, 3) -> 1,234,567
- Indian locales: (3, 2) -> 12,34,567
- Add conditional compilation for i18n-decimal feature
@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch 2 times, most recently from 3ab5bc3 to 712de12 Compare February 17, 2026 09:13
Add tests for:
- test_format_with_thousands_separator: basic functionality
- test_format_with_grouping_sizes: tests (3,3) and (3,2) grouping

Tests verify both Western format (1,234,567) and Indian format (12,34,567)
@naoNao89 naoNao89 force-pushed the feature/thousands-separator-df branch from 712de12 to 7179294 Compare February 17, 2026 09:19
@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/date/date-locale-hour. tests/date/date-locale-hour is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/misc/io-errors. tests/misc/io-errors is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/rm/isatty. tests/rm/isatty is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/dd/no-allocate is now passing!
Congrats! The gnu test tests/seq/seq-epipe is now passing!

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.

ls (and du) block size specification with thousands separator fails

3 participants

Comments