mirror of
https://github.com/apple/swift-http-structured-headers
synced 2026-11-27 05:04:20 +00:00
Fix the build on Linux
Motivation: A number of the changes in the code for running on Linux were not validated ahead of time, and broke the build. Modifications: - Correct the spelling of Glibc - Modified string initialization on non-Darwin platforms Results: Builds and passes tests on Linux
This commit is contained in:
1 parent
97fd7b6bbc
commit
6a2b13e370
2 files changed
+20
-9
No files matched your search
@@ -522,14 +522,25 @@ extension String {
|
||||
// We assume the string is previously validated, so the escapes are easily removed. See the doc comment for
|
||||
// `StrippingStringEscapesCollection` for more details on what we're doing here.
|
||||
let unescapedBytes = StrippingStringEscapesCollection(bytes, escapes: escapes)
|
||||
if #available(macOS 10.16, macCatalyst 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *) {
|
||||
return String(unsafeUninitializedCapacity: unescapedBytes.count) { innerPtr in
|
||||
let (_, endIndex) = innerPtr.initialize(from: unescapedBytes)
|
||||
return endIndex
|
||||
#if canImport(Darwin)
|
||||
if #available(macOS 10.16, macCatalyst 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *) {
|
||||
return String(unsafeUninitializedCapacity: unescapedBytes.count) { innerPtr in
|
||||
let (_, endIndex) = innerPtr.initialize(from: unescapedBytes)
|
||||
return endIndex
|
||||
}
|
||||
} else {
|
||||
return String(decoding: unescapedBytes, as: UTF8.self)
|
||||
}
|
||||
} else {
|
||||
return String(decoding: unescapedBytes, as: UTF8.self)
|
||||
}
|
||||
#else
|
||||
#if compiler(>=5.3)
|
||||
return String(unsafeUninitializedCapacity: unescapedBytes.count) { innerPtr in
|
||||
let (_, endIndex) = innerPtr.initialize(from: unescapedBytes)
|
||||
return endIndex
|
||||
}
|
||||
#else
|
||||
return String(decoding: unescapedBytes, as: UTF8.self)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
#if canImport(Darwin)
|
||||
import Darwin
|
||||
#elseif canImport(GLibc)
|
||||
import GLibc
|
||||
#elseif canImport(Glibc)
|
||||
import Glibc
|
||||
#else
|
||||
#error("Unsupported OS")
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user