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 {
23
23
var regex : NSRegularExpression
24
24
25
25
init ( target: String , pattern: String , options: NSRegularExpressionOptions ? ) {
26
+ self . target = target
27
+
26
28
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
28
40
}
29
41
30
- self . target = target
31
42
if let regex = swiftRegexCache [ pattern] {
32
43
self . regex = regex
33
44
} else {
You can’t perform that action at this time.
0 commit comments