-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(df): add thousands separator support #9090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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 |
| /// - `','` for other locales (default, en_US style) | ||
| fn get_thousands_separator() -> char { | ||
| // Try to read LC_NUMERIC or LANG environment variable | ||
| if let Ok(locale) = std::env::var("LC_NUMERIC") |
There was a problem hiding this comment.
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
|
|
||
| // Simple heuristic: European locales use period, others use comma | ||
| // This covers common cases like de_DE, fr_FR, it_IT, es_ES, nl_NL, etc. | ||
| if locale.starts_with("de_") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
|
GNU testsuite comparison: |
8b92113 to
fb15063
Compare
fb15063 to
13225ab
Compare
|
GNU testsuite comparison: |
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
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
9216589 to
b854560
Compare
|
GNU testsuite comparison: |
|
@naoNao89 there seems to be changes unrelated to the PR, (dd, install), is that a rebase issue? |
33c107e to
b854560
Compare
|
GNU testsuite comparison: |
b854560 to
5fd30c4
Compare
|
GNU testsuite comparison: |
|
You'll need to use expect to get the conversion working |
5fd30c4 to
c12f49a
Compare
- Change get_decimal_separator() to accept &Locale instead of Locale - Eliminates problematic .clone() that caused stale thread stack memory - Fixes valgrind failures in tests/sort/sort-stale-thread-mem test - More efficient (avoids unnecessary clone operation)
c12f49a to
b660ccb
Compare
|
GNU testsuite comparison: |
b660ccb to
878e1de
Compare
|
GNU testsuite comparison: |
e24eba6 to
cdb13fd
Compare
|
GNU testsuite comparison: |
cdb13fd to
395806a
Compare
|
GNU testsuite comparison: |
87e4c6b to
6f5c5f1
Compare
|
GNU testsuite comparison: |
1 similar comment
|
GNU testsuite comparison: |
6f5c5f1 to
cb428a2
Compare
|
GNU testsuite comparison: |
…gile configurations Addresses PR uutils#9653 review feedback about 'fragile commands' by implementing fail-fast validation in Parser builder pattern. Changes: - Add ParserBuilderError enum with 8 validation error variants - Refactor builder methods to return Result<&mut Self, ParserBuilderError> - Implement comprehensive unit validation (57 valid units including k/m/g/t) - Add cross-validation between builder settings (default_unit vs allow_list) - Detect conflicts (b_byte_count with 'b' unit, '%' with size units) - Update all call sites (sort, du, df, od) to handle new error types - Fix invalid '%' unit in sort's parse_byte_count allow_list Benefits: - Configuration errors detected immediately (not during parsing) - Clear error messages listing invalid/conflicting settings - Maintains backward compatibility through explicit error reporting Files modified: - src/uucore/src/lib/features/parser/parse_size.rs (core implementation) - src/uu/sort/src/sort.rs (error handling + fix invalid '%') - src/uu/du/src/du.rs (error handling) - src/uu/df/src/df.rs (error handling) - src/uu/od/src/od.rs (error handling)
cb428a2 to
cda1f5e
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