Repository navigation
[FIX] Sort the capitalization and profanity lists with the C comparator, in the active locale - #2460
Deepak-negi11 wants to merge 1 commit into
Conversation
…or, in the active locale
CCExtractor CI platform finished running the test files on linux. 172/238 tests matched the approved output:
66 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.
Compared with the tip of master — test 9984, commit 24d1e0a:
Compared with the commit this branch was cut from: the same run as the tip of master (test 9984), so the comparison above already covers it. No test changes behaviour relative to the tip of master: every failure above fails there too, byte for byte. The approved output for those tests is out of date, which is a baseline to review rather than a regression in this branch. |
CCExtractor CI platform finished running the test files on windows. 172/238 tests matched the approved output:
66 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.
Compared with the tip of master — test 9985, commit 24d1e0a:
Compared with the commit this branch was cut from: the same run as the tip of master (test 9985), so the comparison above already covers it. No test changes behaviour relative to the tip of master: every failure above fails there too, byte for byte. The approved output for those tests is out of date, which is a baseline to review rather than a regression in this branch. |
In raising this pull request, I confirm the following (please check boxes):
Reason for this PR:
Sanity check:
Repro instructions:
Samples are attached:
ankara.scc(one caption, "ANKARA ON HALLOWEEN.") andcities.txt(one line:Ankara).Set up a Turkish locale on Linux (glibc). I used Docker:
Build ccextractor there (linux/build), then run:
What's wrong
#2397 sorts the word lists in Rust, with ASCII case folding. The C code searches them with
bsearchandstrcasecmp.main()callssetlocale(LC_ALL, ""), sostrcasecmpfollows the user's locale. Intr_TR.UTF-8, glibc does not lowercaseI. So "I", "I'd" and "Italy" sort before "April" in C, but after "Halloween" in the Rust list. With one extra word from--capfile,bsearchlands on one of those words and goes the wrong way. "Halloween" is then not found.What I changed
main()callsccx_encoders_helpers_perform_shellsort_words()right afterccxr_parse_parameters(). It sorts both lists with the same comparator thatbsearchuses, in the active locale. The C parser did this before [FEAT] Removed C code already ported to Rust #1738.strcasecmp.How I tested
--profanity-fileoutput is the same in all three locales.cargo test --lib(434 passed),cargo fmt --check,cargo clippy -- -D warnings, clang-format.