File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -23,11 +23,22 @@ internal final class SwiftRegex: NSObject, BooleanType {
2323 var regex : NSRegularExpression
2424
2525 init ( target: String , pattern: String , options: NSRegularExpressionOptions ? ) {
26+ self . target = target
27+
2628 if dispatch_semaphore_wait ( lock, dispatch_time ( DISPATCH_TIME_NOW, Int64 ( 10 * NSEC_PER_MSEC) ) ) != 0 {
27- fatalError ( " This should never happen " )
29+ do {
30+ let regex = try NSRegularExpression ( pattern: pattern, options:
31+ NSRegularExpressionOptions . DotMatchesLineSeparators)
32+ self . regex = regex
33+ } catch let error as NSError {
34+ SwiftRegex . failure ( " Error in pattern: \( pattern) - \( error) " )
35+ self . regex = NSRegularExpression ( )
36+ }
37+
38+ super. init ( )
39+ return
2840 }
2941
30- self . target = target
3142 if let regex = swiftRegexCache [ pattern] {
3243 self . regex = regex
3344 } else {
You can’t perform that action at this time.
0 commit comments