Skip to content

Commit 7531d74

Browse files
committed
Update fuzz Cargo.lock and fix locale-aware sorting
1 parent c90c2c1 commit 7531d74

File tree

3 files changed

+56
-64
lines changed

3 files changed

+56
-64
lines changed

fuzz/Cargo.lock

Lines changed: 47 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/sort/src/sort.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,10 @@ impl GlobalSettings {
355355

356356
/// Returns true when the fast lexicographic path can be used safely.
357357
fn can_use_fast_lexicographic(&self) -> bool {
358+
// Fast path can only be used when locale is C (byte-wise comparison is correct)
359+
if uucore::i18n::should_use_locale_collation() {
360+
return false;
361+
}
358362
self.mode == SortMode::Default
359363
&& !self.ignore_case
360364
&& !self.dictionary_order

src/uucore/src/lib/features/i18n/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ pub fn get_collating_locale() -> &'static (Locale, UEncoding) {
7070
COLLATING_LOCALE.get_or_init(|| get_locale_from_env("LC_COLLATE"))
7171
}
7272

73+
/// Check if locale-aware collation should be used (i.e., not C/POSIX locale)
74+
pub fn should_use_locale_collation() -> bool {
75+
get_collating_locale().0 != DEFAULT_LOCALE
76+
}
77+
7378
/// Get the numeric locale from the environment
7479
pub fn get_numeric_locale() -> &'static (Locale, UEncoding) {
7580
static NUMERIC_LOCALE: OnceLock<(Locale, UEncoding)> = OnceLock::new();

0 commit comments

Comments
 (0)