Skip to content

Commit

Permalink
syntax: \p{Lc} should map to \p{Cased_Letter}
Browse files Browse the repository at this point in the history
This is more similar to the \p{Cf} bug than the \p{Sc} bug, but
basically, 'lc' is an abbreviation for both 'Cased_Letter' and
'Lowercase_Mapping'. Since we don't support the latter (currently), we
make 'lc' map to 'Cased_Letter'.

If we do ever add 'Lowercase_Mapping' in the future, then we will just
require users to type out its full form.

Fixes #965
  • Loading branch information
BurntSushi committed Mar 15, 2023
1 parent 25866ae commit 7d04473
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion regex-syntax/src/unicode.rs
Expand Up @@ -248,7 +248,12 @@ impl<'a> ClassQuery<'a> {
// also the abbreviation for the 'Script' property. So we avoid calling
// 'canonical_prop' for it too, which would erroneously normalize it
// to 'Script'.
if norm != "cf" && norm != "sc" {
//
// Another case: 'lc' is an abbreviation for the 'Cased_Letter'
// general category, but is also an abbreviation for the 'Lowercase_Mapping'
// property. We don't currently support the latter, so as with 'cf'
// above, we treat 'lc' as 'Cased_Letter'.
if norm != "cf" && norm != "sc" && norm != "lc" {
if let Some(canon) = canonical_prop(&norm)? {
return Ok(CanonicalClassQuery::Binary(canon));
}
Expand Down
2 changes: 2 additions & 0 deletions tests/unicode.rs
Expand Up @@ -35,6 +35,8 @@ mat!(uni_not_boundary_ogham, r"\d\B", "6 ", None);
// We should test more, but there's a lot. Write a script to generate more of
// these tests.
mat!(uni_class_gencat_cased_letter, r"\p{Cased_Letter}", "A", Some((0, 3)));
mat!(uni_class_gencat_cased_letter2, r"\p{gc=LC}", "A", Some((0, 3)));
mat!(uni_class_gencat_cased_letter3, r"\p{LC}", "A", Some((0, 3)));
mat!(
uni_class_gencat_close_punctuation,
r"\p{Close_Punctuation}",
Expand Down

0 comments on commit 7d04473

Please sign in to comment.