mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-05 20:47:53 +00:00
ported re.nim to ARC
This commit is contained in:
@@ -45,6 +45,12 @@ type
|
||||
RegexError* = object of ValueError
|
||||
## is raised if the pattern is no valid regular expression.
|
||||
|
||||
when defined(gcDestructors):
|
||||
proc `=destroy`(x: var RegexDesc) =
|
||||
pcre.free_substring(cast[cstring](x.h))
|
||||
if not isNil(x.e):
|
||||
pcre.free_study(x.e)
|
||||
|
||||
proc raiseInvalidRegex(msg: string) {.noinline, noreturn.} =
|
||||
var e: ref RegexError
|
||||
new(e)
|
||||
@@ -73,7 +79,10 @@ proc re*(s: string, flags = {reStudy}): Regex =
|
||||
## Note that Nim's
|
||||
## extended raw string literals support the syntax ``re"[abc]"`` as
|
||||
## a short form for ``re(r"[abc]")``.
|
||||
new(result, finalizeRegEx)
|
||||
when defined(gcDestructors):
|
||||
result = Regex()
|
||||
else:
|
||||
new(result, finalizeRegEx)
|
||||
result.h = rawCompile(s, cast[cint](flags - {reStudy}))
|
||||
if reStudy in flags:
|
||||
var msg: cstring = ""
|
||||
|
||||
Reference in New Issue
Block a user