Skip to content

Commit e3a5c96

Browse files
authored
Merge pull request #498 from CodaFi/castform
Fix NSRegularExpression on OS X
2 parents a0a8da3 + 0ac8b4a commit e3a5c96

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Foundation/NSRegularExpression.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ internal func _NSRegularExpressionMatch(_ context: UnsafeMutableRawPointer?, ran
128128
#else
129129
let opts = options
130130
#endif
131-
matcher.block(nil, NSMatchingFlags(rawValue: opts), UnsafeMutablePointer<ObjCBool>(stop))
131+
stop.withMemoryRebound(to: ObjCBool.self, capacity: 1, {
132+
matcher.block(nil, NSMatchingFlags(rawValue: opts), $0)
133+
})
132134
} else {
133135
let result = ranges!.withMemoryRebound(to: NSRange.self, capacity: count) { rangePtr in
134136
TextCheckingResult.regularExpressionCheckingResultWithRanges(rangePtr, count: count, regularExpression: matcher.regex)
@@ -138,7 +140,9 @@ internal func _NSRegularExpressionMatch(_ context: UnsafeMutableRawPointer?, ran
138140
#else
139141
let flags = NSMatchingFlags(rawValue: options)
140142
#endif
141-
matcher.block(result, flags, UnsafeMutablePointer<ObjCBool>(stop))
143+
stop.withMemoryRebound(to: ObjCBool.self, capacity: 1, {
144+
matcher.block(result, flags, $0)
145+
})
142146
}
143147
}
144148

0 commit comments

Comments
 (0)