Fix incorrect check

pcre_study can return nil and still succeed
The indicator of failure is a non-nil error message
This commit is contained in:
Flaviu Tamas
2015-01-10 20:54:36 -05:00
parent fb51221aa8
commit 6fe0de0639

View File

@@ -249,7 +249,7 @@ proc initRegex*(pattern: string, options = "Sx"): Regex =
if opts.study:
# XXX investigate JIT
result.pcreExtra = pcre.study(result.pcreObj, 0x0, addr errorMsg)
if result.pcreExtra == nil:
if errorMsg != nil:
raise StudyError(msg: $errorMsg)
result.captureNameToId = result.getNameToNumberTable()