Skip to content

PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust

Integration: #3765 name the case-only comparison in the doc comments (NFC/NFD not compared)

aiongg464dbd49e0fa
diff --git a/crates/automation/src/a11y.rs b/crates/automation/src/a11y.rs
index e1be76937..20243dcda 100644
--- a/crates/automation/src/a11y.rs
+++ b/crates/automation/src/a11y.rs
@@ -676,10 +676,10 @@ fn input_file_name(path: &str) -> String {
}
/// The output file names that two or more of `targets` share, each spelling listed once, in input
-/// order. Names are compared the way the default filesystem compares them: without regard to case
-/// on Windows and macOS and exactly elsewhere; on Windows a trailing dot or space is not part of
-/// the name (`scan.pdf.` is `scan.pdf`). The folder is the same for every target, so only the
-/// names are compared.
+/// order. Names are compared without regard to case on Windows and macOS and exactly elsewhere; on
+/// Windows a trailing dot or space is not part of the name (`scan.pdf.` is `scan.pdf`). Unicode
+/// normalization forms (NFC and NFD spellings of one name) are not compared, so such inputs are
+/// not caught. The folder is the same for every target, so only the names are compared.
fn shared_file_names(targets: &[std::path::PathBuf]) -> Vec<String> {
let mut groups: std::collections::BTreeMap<String, (usize, Vec<String>)> = std::collections::BTreeMap::new();
for target in targets {
@@ -687,6 +687,7 @@ fn shared_file_names(targets: &[std::path::PathBuf]) -> Vec<String> {
let key = if cfg!(windows) {
name.trim_end_matches(['.', ' ']).to_lowercase()
} else if cfg!(target_os = "macos") {
+ // Case only; NFC and NFD spellings of one name stay distinct here (a known limit).
name.to_lowercase()
} else {
name.clone()
diff --git a/crates/automation/tests/it/automation.rs b/crates/automation/tests/it/automation.rs
index 8bbc4dae9..dfd31b9ee 100644
--- a/crates/automation/tests/it/automation.rs
+++ b/crates/automation/tests/it/automation.rs
@@ -6230,9 +6230,9 @@ fn ocr_recognize_files_refuses_inputs_that_share_a_file_name() {
assert!(!dir.join("out").exists(), "nothing was started: the output folder was not created");
}
-/// File names are compared the way the default filesystem compares them: without regard to case
-/// on Windows and macOS (`scan.pdf` and `Scan.PDF` are one file there), and exactly elsewhere,
-/// where they are two files and the batch is not refused.
+/// File names are compared without regard to case on Windows and macOS (`scan.pdf` and `Scan.PDF`
+/// are one file there), and exactly elsewhere, where they are two files and the batch is not
+/// refused.
#[test]
fn ocr_recognize_files_compares_names_the_way_the_filesystem_does() {
let dir = workdir("ocr-files-case");