@@ -80,11 +80,7 @@ open class NSRegularExpression: NSObject, NSCopying, NSSecureCoding {
80
80
81
81
public init ( pattern: String , options: Options = [ ] ) throws {
82
82
var error : Unmanaged < CFError > ?
83
- #if os(macOS) || os(iOS)
84
83
let opt = _CFRegularExpressionOptions ( rawValue: options. rawValue)
85
- #else
86
- let opt = _CFRegularExpressionOptions ( options. rawValue)
87
- #endif
88
84
if let regex = _CFRegularExpressionCreate ( kCFAllocatorSystemDefault, pattern. _cfObject, opt, & error) {
89
85
_internal = regex
90
86
} else {
@@ -97,11 +93,7 @@ open class NSRegularExpression: NSObject, NSCopying, NSSecureCoding {
97
93
}
98
94
99
95
open var options : Options {
100
- #if os(macOS) || os(iOS)
101
96
let opt = _CFRegularExpressionGetOptions ( _internal) . rawValue
102
- #else
103
- let opt = _CFRegularExpressionGetOptions ( _internal)
104
- #endif
105
97
106
98
return Options ( rawValue: opt)
107
99
}
@@ -158,11 +150,7 @@ internal class _NSRegularExpressionMatcher {
158
150
159
151
internal func _NSRegularExpressionMatch( _ context: UnsafeMutableRawPointer ? , ranges: UnsafeMutablePointer < CFRange > ? , count: CFIndex , flags: _CFRegularExpressionMatchingFlags , stop: UnsafeMutablePointer < _DarwinCompatibleBoolean > ) -> Void {
160
152
let matcher = unsafeBitCast ( context, to: _NSRegularExpressionMatcher. self)
161
- #if os(macOS) || os(iOS)
162
153
let flags = NSRegularExpression . MatchingFlags ( rawValue: flags. rawValue)
163
- #else
164
- let flags = NSRegularExpression . MatchingFlags ( rawValue: flags)
165
- #endif
166
154
let result = ranges? . withMemoryRebound ( to: NSRange . self, capacity: count) { rangePtr in
167
155
NSTextCheckingResult . regularExpressionCheckingResult ( ranges: rangePtr, count: count, regularExpression: matcher. regex)
168
156
}
@@ -179,11 +167,7 @@ extension NSRegularExpression {
179
167
public func enumerateMatches( in string: String , options: NSRegularExpression . MatchingOptions = [ ] , range: NSRange , using block: @escaping ( NSTextCheckingResult ? , NSRegularExpression . MatchingFlags , UnsafeMutablePointer < ObjCBool > ) -> Swift . Void ) {
180
168
let matcher = _NSRegularExpressionMatcher ( regex: self , block: block)
181
169
withExtendedLifetime ( matcher) { ( m: _NSRegularExpressionMatcher ) -> Void in
182
- #if os(macOS) || os(iOS)
183
170
let opts = _CFRegularExpressionMatchingOptions ( rawValue: options. rawValue)
184
- #else
185
- let opts = _CFRegularExpressionMatchingOptions ( options. rawValue)
186
- #endif
187
171
_CFRegularExpressionEnumerateMatchesInString ( _internal, string. _cfObject, opts, CFRange ( range) , unsafeBitCast ( matcher, to: UnsafeMutableRawPointer . self) , _NSRegularExpressionMatch)
188
172
}
189
173
}
0 commit comments