Skip to content

Commit 688f1d8

Browse files
committed
Change script property default to use Script Extension
Change the default script property behavior for an unqualified value e.g `\p{Greek}` from `\p{Script=Greek}` to `\p{Script_Extension=Greek}`. This is arguably the more intuitive behavior, and matches what Perl does.
1 parent 4dab8d8 commit 688f1d8

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

Sources/_MatchingEngine/Regex/Parse/CharacterPropertyClassification.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ extension Source {
381381
return .generalCategory(cat)
382382
}
383383
if let script = classifyScriptProperty(value) {
384-
return .script(script)
384+
return .scriptExtension(script)
385385
}
386386
if let posix = classifyPOSIX(value) {
387387
return .posix(posix)

Tests/RegexTests/MatchTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ extension RegexTests {
695695
firstMatchTest(#"\p{ISBAMUM}"#, input: "123ꚠꚡꚢxyz", match: "")
696696
firstMatchTest(#"\p{Script=Unknown}"#, input: "\u{10FFFF}", match: "\u{10FFFF}")
697697
firstMatchTest(#"\p{scx=Gujr}"#, input: "\u{a839}", match: "\u{a839}")
698+
firstMatchTest(#"\p{Gujr}"#, input: "\u{a839}", match: "\u{a839}")
698699

699700
firstMatchTest(#"\p{alpha}"#, input: "123abcXYZ", match: "a")
700701
firstMatchTest(#"\P{alpha}"#, input: "123abcXYZ", match: "1")

Tests/RegexTests/ParseTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,13 +1003,13 @@ extension RegexTests {
10031003

10041004
parseTest(#"\p{sc=grek}"#, prop(.script(.greek)))
10051005
parseTest(#"\p{sc=isGreek}"#, prop(.script(.greek)))
1006-
parseTest(#"\p{Greek}"#, prop(.script(.greek)))
1007-
parseTest(#"\p{isGreek}"#, prop(.script(.greek)))
1006+
parseTest(#"\p{Greek}"#, prop(.scriptExtension(.greek)))
1007+
parseTest(#"\p{isGreek}"#, prop(.scriptExtension(.greek)))
10081008
parseTest(#"\P{Script=Latn}"#, prop(.script(.latin), inverted: true))
10091009
parseTest(#"\p{script=zzzz}"#, prop(.script(.unknown)))
10101010
parseTest(#"\p{ISscript=iszzzz}"#, prop(.script(.unknown)))
10111011
parseTest(#"\p{scx=bamum}"#, prop(.scriptExtension(.bamum)))
1012-
parseTest(#"\p{ISBAMUM}"#, prop(.script(.bamum)))
1012+
parseTest(#"\p{ISBAMUM}"#, prop(.scriptExtension(.bamum)))
10131013

10141014
parseTest(#"\p{alpha}"#, prop(.binary(.alphabetic)))
10151015
parseTest(#"\p{DEP}"#, prop(.binary(.deprecated)))

0 commit comments

Comments
 (0)