Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 47 additions & 64 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/uu/sort/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ self_cell = { workspace = true }
tempfile = { workspace = true }
thiserror = { workspace = true }
unicode-width = { workspace = true }
uucore = { workspace = true, features = ["fs", "parser-size", "version-cmp"] }
uucore = { workspace = true, features = ["fs", "parser-size", "version-cmp", "i18n-collator"] }
fluent = { workspace = true }

[target.'cfg(unix)'.dependencies]
Expand Down
5 changes: 5 additions & 0 deletions src/uu/sort/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ sort-after-help = The key format is FIELD[.CHAR][OPTIONS][,FIELD[.CHAR]][OPTIONS

Valid options are: MbdfhnRrV. They override the global options for this key.

Locale-aware sorting:
The LC_ALL, LC_COLLATE, and LANG environment variables affect sorting order.
LC_ALL=C uses fast byte-wise comparison. Other locales use slower but correct Unicode collation.
For performance-critical scenarios with ASCII data, consider using LC_ALL=C.

# Error messages
sort-open-failed = open failed: {$path}: {$error}
sort-parse-key-error = failed to parse key {$key}: {$msg}
Expand Down
5 changes: 5 additions & 0 deletions src/uu/sort/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ sort-after-help = Le format de clé est CHAMP[.CAR][OPTIONS][,CHAMP[.CAR]][OPTIO

Les options valides sont : MbdfhnRrV. Elles remplacent les options globales pour cette clé.

Tri selon la locale :
Les variables d'environnement LC_ALL, LC_COLLATE et LANG affectent l'ordre de tri.
LC_ALL=C utilise une comparaison rapide par octets. D'autres locales utilisent une collation Unicode plus lente mais correcte.
Pour des scénarios critiques en performance avec des données ASCII, considérez l'utilisation de LC_ALL=C.

# Messages d'erreur
sort-open-failed = échec d'ouverture : {$path} : {$error}
sort-parse-key-error = échec d'analyse de la clé {$key} : {$msg}
Expand Down
5 changes: 3 additions & 2 deletions src/uu/sort/src/custom_str_cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//! The goal is to compare strings without transforming them first (i.e. not allocating new strings)

use std::cmp::Ordering;
use uucore::i18n::collator::locale_cmp;

fn filter_char(c: u8, ignore_non_printing: bool, ignore_non_dictionary: bool) -> bool {
if ignore_non_dictionary && !(c.is_ascii_alphanumeric() || c.is_ascii_whitespace()) {
Expand Down Expand Up @@ -35,8 +36,8 @@ pub fn custom_str_cmp(
ignore_case: bool,
) -> Ordering {
if !(ignore_case || ignore_non_dictionary || ignore_non_printing) {
// There are no custom settings. Fall back to the default strcmp, which is faster.
return a.cmp(b);
// There are no custom settings. Fall back to locale-aware comparison.
return locale_cmp(a, b);
}
let mut a_chars = a
.iter()
Expand Down
Loading
Loading