mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-07 05:23:20 +00:00
live with the hacks, PCRE's design is crap
This commit is contained in:
@@ -442,7 +442,7 @@ proc extractOptions(pattern: string): tuple[pattern: string, flags: int, study:
|
||||
# }}}
|
||||
|
||||
proc destroyRegex(pattern: Regex) =
|
||||
pcre.free(pattern.pcreObj)
|
||||
pcre.free_substring(cast[cstring](pattern.pcreObj))
|
||||
pattern.pcreObj = nil
|
||||
if pattern.pcreExtra != nil:
|
||||
pcre.free_study(pattern.pcreExtra)
|
||||
|
||||
@@ -60,9 +60,12 @@ proc rawCompile(pattern: string, flags: cint): ptr Pcre =
|
||||
raiseInvalidRegex($msg & "\n" & pattern & "\n" & spaces(offset) & "^\n")
|
||||
|
||||
proc finalizeRegEx(x: Regex) =
|
||||
pcre.free(x.h)
|
||||
# XXX This is a hack, but PCRE does not export its "free" function properly.
|
||||
# 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):
|
||||
pcre.free_study(x.e)
|
||||
pcre.free_substring(cast[cstring](x.e))
|
||||
|
||||
proc re*(s: string, flags = {reStudy}): Regex =
|
||||
## Constructor of regular expressions.
|
||||
|
||||
@@ -341,8 +341,6 @@ proc compile2*(pattern: cstring,
|
||||
erroffset: ptr cint,
|
||||
tableptr: pointer): ptr Pcre
|
||||
|
||||
proc free*(p: ptr Pcre)
|
||||
|
||||
proc config*(what: cint,
|
||||
where: pointer): cint
|
||||
|
||||
|
||||
Reference in New Issue
Block a user