date: fix handling of case-change flags in locale format specifiers#9897
date: fix handling of case-change flags in locale format specifiers#9897CrazyRoka wants to merge 2 commits intouutils:mainfrom
Conversation
230c85d to
3654036
Compare
|
GNU testsuite comparison: |
|
lot of jobs are failing |
bf1c296 to
f494fa5
Compare
|
GNU testsuite comparison: |
65b15f3 to
49f0f26
Compare
|
GNU testsuite comparison: |
49f0f26 to
0e2030a
Compare
|
Didn't realize there was already a PR for this when I was investigating the date gnu tests failures here: #10242 I ended up making a PR to Jiff to add support for these modifiers: BurntSushi/jiff#488 These are pre-made configs actually so theres nothing stopping us from making our own custom Config that has support for all of the modifiers and this way |
|
@CrazyRoka sorry, could you please rebase it ? |
- Add documentation for distribute_flag helper. - Add unit tests for flag distribution and locale expansion. - Add integration test for locale expansion with uppercase flag.
0e2030a to
f3ab2c5
Compare
Merging this PR will degrade performance by 3.91%
Performance Changes
Comparing Footnotes
|
|
GNU testsuite comparison: |
| "%a %b %e %X %Z %Y" | ||
| } | ||
|
|
||
| #[cfg(not(any( |
There was a problem hiding this comment.
I am following the pattern used elsewhere in the file. Do you suggest using #[cfg(unix)] instead?
| target_os = "openbsd", | ||
| target_os = "dragonfly" | ||
| )))] | ||
| pub fn expand_locale_format(format: &str) -> std::borrow::Cow<'_, str> { |
There was a problem hiding this comment.
This is for Windows (and other non-Unix platforms). nl_langinfo is a Unix-specific libc function. On Windows we fall back to doing nothing (no expansion).
|
It appears all of these locale formatters were implemented using jiff-icu and the modifiers were implemented in the following PR: #10940 |
Previously, applying flags like
'^'(uppercase) or'#'(swap case) to locale-dependent specifiers (like%c,%x,%X) failed to affect the output. This occurred because the implementation passed these specifiers directly to the underlying formatter, which treats%cas a single unit without inheriting flags for its expanded components.For example,
LC_ALL=C TZ=UTC cargo run --bin coreutils date -d 2024-01-01 +%^cproduced "2024 M01 1, Mon 00:00:00", whereas GNUdateproduces "MON JAN 1 00:00:00 2024".This change pre-processes the format string to expand
%c,%x, and%Xusingnl_langinfo.This aligns behavior with GNU coreutils and we are now passing
subfmt-up1edge case intests/date/date.pl