Repository navigation
Conversation
| /// C and POSIX use the default collation. Only a codeset following `.` can | ||
| /// select UTF-8; a modifier following `@` is never an encoding. | ||
| /// Unrecognized locale names use the default locale; unrecognized codesets use ASCII. | ||
| pub fn parse_posix_locale(value: &str) -> (Locale, UEncoding) { |
There was a problem hiding this comment.
why pub? if it's meant to be shared, is_c_locale in uniq could use it, no?
| /// select UTF-8; a modifier following `@` is never an encoding. | ||
| /// Unrecognized locale names use the default locale; unrecognized codesets use ASCII. | ||
| pub fn parse_posix_locale(value: &str) -> (Locale, UEncoding) { | ||
| let name_and_codeset = value.split('@').next().unwrap_or_default(); |
There was a problem hiding this comment.
value.split_once('@').map_or(value, |(n, _)| n) would avoid the unwrap_or_default()
| let (name, codeset) = name_and_codeset | ||
| .split_once('.') | ||
| .unwrap_or((name_and_codeset, "")); | ||
| let locale = if matches!(name, "C" | "POSIX") { |
There was a problem hiding this comment.
POSIX used to parse as a real "posix" locale, so this is a second fix. please mention it in the commit message
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod posix_locale_tests { |
There was a problem hiding this comment.
could you please move these into the existing mod tests? no need for a second test module
97c083b to
d077d2a
Compare
|
GNU testsuite comparison: |
Merging this PR will degrade performance by 19.94%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | cp_recursive_deep_tree[(120, 4)] |
532.6 KB | 699.2 KB | -23.82% |
| ❌ | Simulation | true_consecutive_calls |
294.7 ns | 350.2 ns | -15.86% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing limadog9:fix/i18n-parse-posix-locale-components-12291 (c48bc70) with main (6f60c70)2
Footnotes
-
70 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. ↩
-
No successful run was found on
main(48f2a33) during the generation of this report, so 6f60c70 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
|
thanks for the PR! |
|
|
||
| at.truncate(source, "x\n"); | ||
| p.delay(delay); | ||
| // Wait for tail to observe the write before terminating it on slow CI hosts. |
There was a problem hiding this comment.
unrelated to the locale parsing, could you please move this tail fix into a separate pr?
Parse locale names, codesets and modifiers separately. Treat POSIX as the default C locale rather than a language named posix. Reuse the parser in uniq when choosing the C-locale comparison path. Closes uutils#12291.
d077d2a to
c48bc70
Compare
Factor POSIX locale parsing into a shared helper and recognize encoding only before the modifier. This fixes en_US@utf-8.dict being treated as UTF-8 and adds an expr regression.
Refs #12291.