feat(df): add thousands separator support#9090
Conversation
3ce60cf to
48f4bc1
Compare
|
GNU testsuite comparison: |
a8966af to
ae09fec
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
could you please split this per program in different pr ? thanks |
There was a problem hiding this comment.
Environment variable reads on every call is inefficient - consider caching the locale information
There was a problem hiding this comment.
is it?
i don't like this hardcoded list. isn't something in icu to do that?
There was a problem hiding this comment.
oki, replace with ICU's FixedDecimalFormatter
|
GNU testsuite comparison: |
8b92113 to
fb15063
Compare
fb15063 to
13225ab
Compare
|
GNU testsuite comparison: |
Merging this PR will not alter performance
Comparing Footnotes
|
|
GNU testsuite comparison: |
8aa4f8c to
c6cb13e
Compare
|
GNU testsuite comparison: |
1 similar comment
|
GNU testsuite comparison: |
29d396b to
e85ae66
Compare
|
GNU testsuite comparison: |
e85ae66 to
714a5a2
Compare
|
GNU testsuite comparison: |
714a5a2 to
3be82c4
Compare
148c41f to
286ddf6
Compare
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).
286ddf6 to
d37b5cf
Compare
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).
d37b5cf to
22559c7
Compare
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).
22559c7 to
57ee387
Compare
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).
57ee387 to
2d6b9c1
Compare
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).
2d6b9c1 to
7d44f26
Compare
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).
7d44f26 to
ad54cdc
Compare
| /// // assert_eq!(format_with_thousands_separator(1234567), "1.234.567"); | ||
| /// ``` | ||
| pub fn format_with_thousands_separator(number: u64) -> String { |
There was a problem hiding this comment.
please write unit test for this function
|
GNU testsuite comparison: |
|
hmm, was hardcoded to 3 now uses ICU locale data: (3,3) for westernor (3,2) for indian locales |
|
GNU testsuite comparison: |
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).
ceecac6 to
bb1de9b
Compare
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
3ab5bc3 to
712de12
Compare
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)
712de12 to
7179294
Compare
|
GNU testsuite comparison: |
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