pcre.nim: added pcre_free and removed hacks in nre and re.nim
This commit is contained in:
parent
d3df1b8eda
commit
cd9caf09d1
3 changed files with 5 additions and 6 deletions
|
|
@ -442,7 +442,7 @@ proc extractOptions(pattern: string): tuple[pattern: string, flags: int, study:
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
proc destroyRegex(pattern: Regex) =
|
proc destroyRegex(pattern: Regex) =
|
||||||
pcre.free_substring(cast[cstring](pattern.pcreObj))
|
pcre.free(pattern.pcreObj)
|
||||||
pattern.pcreObj = nil
|
pattern.pcreObj = nil
|
||||||
if pattern.pcreExtra != nil:
|
if pattern.pcreExtra != nil:
|
||||||
pcre.free_study(pattern.pcreExtra)
|
pcre.free_study(pattern.pcreExtra)
|
||||||
|
|
|
||||||
|
|
@ -60,12 +60,9 @@ proc rawCompile(pattern: string, flags: cint): ptr Pcre =
|
||||||
raiseInvalidRegex($msg & "\n" & pattern & "\n" & spaces(offset) & "^\n")
|
raiseInvalidRegex($msg & "\n" & pattern & "\n" & spaces(offset) & "^\n")
|
||||||
|
|
||||||
proc finalizeRegEx(x: Regex) =
|
proc finalizeRegEx(x: Regex) =
|
||||||
# XXX This is a hack, but PCRE does not export its "free" function properly.
|
pcre.free(x.h)
|
||||||
# Sigh. The hack relies on PCRE's implementation (see ``pcre_get.c``).
|
|
||||||
# Fortunately the implementation is unlikely to change.
|
|
||||||
pcre.free_substring(cast[cstring](x.h))
|
|
||||||
if not isNil(x.e):
|
if not isNil(x.e):
|
||||||
pcre.free_substring(cast[cstring](x.e))
|
pcre.free_study(x.e)
|
||||||
|
|
||||||
proc re*(s: string, flags = {reStudy}): Regex =
|
proc re*(s: string, flags = {reStudy}): Regex =
|
||||||
## Constructor of regular expressions.
|
## Constructor of regular expressions.
|
||||||
|
|
|
||||||
|
|
@ -341,6 +341,8 @@ proc compile2*(pattern: cstring,
|
||||||
erroffset: ptr cint,
|
erroffset: ptr cint,
|
||||||
tableptr: pointer): ptr Pcre
|
tableptr: pointer): ptr Pcre
|
||||||
|
|
||||||
|
proc free*(p: ptr Pcre)
|
||||||
|
|
||||||
proc config*(what: cint,
|
proc config*(what: cint,
|
||||||
where: pointer): cint
|
where: pointer): cint
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue