ls: honor LC_TIME for --time-style=locale#11669
ls: honor LC_TIME for --time-style=locale#11669sylvestre wants to merge 4 commits intouutils:mainfrom
Conversation
|
GNU testsuite comparison: |
looking at this |
|
GNU testsuite comparison: |
e28448c to
c302650
Compare
|
GNU testsuite comparison: |
c302650 to
7856aaf
Compare
|
GNU testsuite comparison: |
7856aaf to
0a9df65
Compare
|
GNU testsuite comparison: |
|
You picked this issue up fast :D |
0a9df65 to
893c2ae
Compare
|
GNU testsuite comparison: |
|
@cakebaker |
tests/by-util/test_ls.rs
Outdated
| /// Substring that MUST appear in the (lossy UTF-8) stdout. Used for the | ||
| /// C-locale sanity case to pin the English output. | ||
| must_contain: Option<&'static str>, | ||
| /// Substring that must NOT appear in the (lossy UTF-8) stdout. Used to | ||
| /// guarantee non-C locales don't fall back to the English format. | ||
| must_not_contain: Option<&'static str>, |
There was a problem hiding this comment.
I'm not sure about those properties. You only introduce them because of the C-locale. It might make sense to separate the handling of the C-locale from the handling of the special cases, instead of using a "one size fits all" approach.
There was a problem hiding this comment.
The C locale is already handled separately (lines 2500-2522) with its own dedicated block and C_LOCALE_OUTPUT assertion. The must_contain/must_not_contain properties you were referring to have been removed — the remaining struct fields (script_range, require_high_byte, allow_gregorian_year) are all about differentiating between non-C locales (e.g. KOI8-R vs Persian vs Thai). I think this is addressed now?
|
I will finish the review of |
893c2ae to
36be3f5
Compare
|
GNU testsuite comparison: |
| struct CachedLocaleNames { | ||
| /// `%B` — full month names, raw | ||
| month_long: Option<[String; 12]>, | ||
| /// `%B` — full month names, padded to uniform display width | ||
| month_long_padded: Option<[String; 12]>, | ||
| /// `%b` / `%h` — abbreviated month names (trailing dots stripped), raw | ||
| month_abbrev: Option<[String; 12]>, | ||
| /// `%b` / `%h` — abbreviated month names, padded | ||
| month_abbrev_padded: Option<[String; 12]>, | ||
| /// `%A` — full weekday names, raw | ||
| weekday_long: Option<[String; 7]>, | ||
| /// `%A` — full weekday names, padded | ||
| weekday_long_padded: Option<[String; 7]>, | ||
| /// `%a` — abbreviated weekday names, raw | ||
| weekday_short: Option<[String; 7]>, | ||
| /// `%a` — abbreviated weekday names, padded | ||
| weekday_short_padded: Option<[String; 7]>, | ||
| } |
There was a problem hiding this comment.
This struct doesn't feel right. If I understand it correctly, only half of the properties are used, the others are set but never read.
I would remove the "padded" properties so that the remaining properties contain either the padded or raw data, depending on how the struct was filled.
There was a problem hiding this comment.
Both sets are actually read — localize_format_string() takes a NamePadding parameter and selects between _padded and raw variants at each substitution point (see lines 250-290). date calls with Raw, ls calls with Padded, so all 8 fields get used depending on the caller.
That said, I could avoid storing both by keeping only the raw names and applying pad_names() on-the-fly when Padded is requested. The padding cost is negligible (12 or 7 string scans). Would you prefer that approach?
|
Hm, it looks like one of my previous suggestions doesn't work on OpenBSD as |
Add format_system_time_locale_aware in uucore::time that runs the format string through i18n::datetime::localize_format_string when a non-C LC_TIME locale is active, and route ls's display_date through it. Fixes month names and alternate-calendar years (Persian, Buddhist, Ethiopian) matching GNU. Also generalize uutests' is_locale_available to derive the expected charmap from the locale suffix so non-UTF-8 locales work, and consolidate the ls locale tests into a single data-driven case.
The ls-specific column alignment padding (from abmon-align) was leaking into date output. Add a `pad` parameter to `localize_format_string` so ls gets padded names and date gets raw names.
36be3f5 to
4486cc1
Compare
|
GNU testsuite comparison: |
on my system