Skip to content

[Integration] main (1802158) -> swift/main #453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 28, 2022
Merged
2 changes: 1 addition & 1 deletion Sources/_RegexParser/Utility/TypeConstruction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public enum TypeConstruction {
flags |= 0x10000
}

let result = elementTypes.withContiguousStorageIfAvailable { elementTypesBuffer in
let result = elementTypes.withContiguousStorageIfAvailable { elementTypesBuffer -> (value: Any.Type, state: Int) in
if let labels = labels {
return labels.withCString { labelsPtr in
swift_getTupleTypeMetadata(
Expand Down
2 changes: 1 addition & 1 deletion Sources/_StringProcessing/PrintAsPattern.swift
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ extension PrettyPrinter {
extension String {
// TODO: Escaping?
fileprivate var _quoted: String {
"\"\(self._replacing("\"", with: "\\\""))\""
"\"\(self._replacing(#"\"#, with: #"\\"#)._replacing(#"""#, with: #"\""#))\""
}
}

Expand Down
8 changes: 8 additions & 0 deletions Tests/RegexTests/MatchTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,14 @@ extension RegexTests {
firstMatchTest(#"(?xx)[ \t]+"#, input: " \t \t", match: "\t")

firstMatchTest("(?xx)[ a && ab ]+", input: " aaba ", match: "aa")

// Preserve whitespace in quoted section inside extended syntax region
firstMatchTest(
#"(?x) a b \Q c d \E e f"#, input: "ab c d ef", match: "ab c d ef")
firstMatchTest(
#"(?x)[a b]+ _ [a\Q b\E]+"#, input: "aba_ a b a", match: "aba_ a b a")
firstMatchTest(
#"(?x)[a b]+ _ [a\Q b\E]+"#, input: "aba _ a b a", match: nil)
}

func testASCIIClasses() {
Expand Down
8 changes: 8 additions & 0 deletions Tests/RegexTests/RenderDSLTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,12 @@ extension RenderDSLTests {
""")
}
}

func testQuoting() throws {
try testConversion(#"\\"a""#, #"""
Regex {
"\\\"a\""
}
"""#)
}
}