summary refs log tree commit diff stats
path: root/lib/impure/re.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2019-03-19 15:49:24 +0100
committerAraq <rumpf_a@web.de>2019-03-19 15:49:24 +0100
commiteeae88d81e85bedc34f578d3c8e7be3bb9f18f37 (patch)
tree32aab34a3bdc2471c6252d31f4ed625d9a49e6da /lib/impure/re.nim
parentbfc7522401dec97834d2f0d79f34821d86bc448e (diff)
downloadNim-eeae88d81e85bedc34f578d3c8e7be3bb9f18f37.tar.gz
live with the hacks, PCRE's design is crap
Diffstat (limited to 'lib/impure/re.nim')
-rw-r--r--lib/impure/re.nim7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/impure/re.nim b/lib/impure/re.nim
index 6f57185e6..4f32cd5fb 100644
--- a/lib/impure/re.nim
+++ b/lib/impure/re.nim
@@ -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.