diff options
-rw-r--r-- | src/nre.nim | 3 | ||||
-rw-r--r-- | src/private/pcre.nim | 14 |
2 files changed, 6 insertions, 11 deletions
diff --git a/src/nre.nim b/src/nre.nim index 2611ee7f6..1cd534cc0 100644 --- a/src/nre.nim +++ b/src/nre.nim @@ -78,6 +78,7 @@ type StudyError* = ref object of Exception +# Creation & Destruction {{{ proc destroyRegex(self: Regex) = pcre.free_substring(cast[cstring](self.pcreObj)) self.pcreObj = nil @@ -106,11 +107,13 @@ proc initRegex*(pattern: string, options = "Sx"): Regex = result.pcreExtra = pcre.study(result.pcreObj, 0x0, addr errorMsg) if result.pcreExtra == nil: raise StudyError(msg: $errorMsg) +# }}} proc getinfo[T](self: Regex, opt: cint): T = let retcode = pcre.fullinfo(self.pcreObj, self.pcreExtra, opt, addr result) if retcode < 0: + # XXX Error message that doesn't expose implementation details raise newException(FieldError, "Invalid getinfo for $1, errno $2" % [$opt, $retcode]) proc getCaptureCount(self: Regex): int = diff --git a/src/private/pcre.nim b/src/private/pcre.nim index 385f85bc1..41afa72fb 100644 --- a/src/private/pcre.nim +++ b/src/private/pcre.nim @@ -309,14 +309,6 @@ type jit_stack16* = object jit_stack32* = object - -# When Pcre is compiled as a C++ library, the subject pointer type can be -#replaced with a custom type. For conventional use, the public interface is a -#const char *. - -type - SPTR* = cstring - # The structure for passing additional data to pcre_exec(). This is defined in #such as way as to be extensible. Always add new fields at the end, in order to #remain compatible. @@ -344,7 +336,7 @@ type # ------------------------ Version 0 ------------------------------- callout_number* {.importc: "callout_number".}: cint # Number compiled into pattern offset_vector* {.importc: "offset_vector".}: ptr cint # The offset vector - subject* {.importc: "subject".}: SPTR # The subject being matched + subject* {.importc: "subject".}: cstring # The subject being matched subject_length* {.importc: "subject_length".}: cint # The length of the subject start_match* {.importc: "start_match".}: cint # Offset to start of this match attempt current_position* {.importc: "current_position".}: cint # Where we currently are in the subject @@ -398,10 +390,10 @@ proc copy_substring*(a2: cstring; a3: ptr cint; a4: cint; a5: cint; a6: cstring; proc dfa_exec*(a2: ptr Pcre; a3: ptr ExtraData; a4: cstring; a5: cint; a6: cint; a7: cint; a8: ptr cint; a9: cint; a10: ptr cint; a11: cint): cint {. cdecl, importc: "pcre_dfa_exec", pcreImport.} -proc exec*(a2: ptr Pcre; a3: ptr ExtraData; a4: SPTR; a5: cint; a6: cint; a7: cint; +proc exec*(a2: ptr Pcre; a3: ptr ExtraData; a4: cstring; a5: cint; a6: cint; a7: cint; a8: ptr cint; a9: cint): cint {.cdecl, importc: "pcre_exec", pcreImport.} -proc jit_exec*(a2: ptr Pcre; a3: ptr ExtraData; a4: SPTR; a5: cint; a6: cint; +proc jit_exec*(a2: ptr Pcre; a3: ptr ExtraData; a4: cstring; a5: cint; a6: cint; a7: cint; a8: ptr cint; a9: cint; a10: ptr jit_stack): cint {. cdecl, importc: "pcre_jit_exec", pcreImport.} proc free_substring*(a2: cstring) {.cdecl, importc: "pcre_free_substring", |