Merge branch 'devel' of github.com:nim-lang/Nim into devel

This commit is contained in:
Andreas Rumpf 2019-03-21 09:34:02 +01:00
commit 83c105c3a3
16 changed files with 75 additions and 25 deletions

View file

@ -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)

View file

@ -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.

View file

@ -35,6 +35,7 @@
## `execShellCmd proc <#execShellCmd,string>`_
## * `parseopt module <parseopt.html>`_ for command-line parser beyond
## `parseCmdLine proc <#parseCmdLine,string>`_
## * `uri module <uri.html>`_
## * `distros module <distros.html>`_
## * `dynlib module <dynlib.html>`_
## * `streams module <streams.html>`_
@ -115,13 +116,15 @@ proc joinPath*(head, tail: string): string {.
##
## If `head` is the empty string, `tail` is returned. If `tail` is the empty
## string, `head` is returned with a trailing path separator. If `tail` starts
## with a path separator it will be removed when concatenated to `head`. Other
## path separators not located on boundaries won't be modified.
## with a path separator it will be removed when concatenated to `head`.
## Path separators will be normalized.
##
## See also:
## * `joinPath(varargs) proc <#joinPath,varargs[string]>`_
## * `/ proc <#/,string,string>`_
## * `splitPath proc <#splitPath,string>`_
## * `uri.combine proc <uri.html#combine,Uri,Uri>`_
## * `uri./ proc <uri.html#/,Uri,string>`_
runnableExamples:
when defined(posix):
assert joinPath("usr", "lib") == "usr/lib"
@ -186,6 +189,8 @@ proc `/`*(head, tail: string): string {.noSideEffect.} =
## * `joinPath(head, tail) proc <#joinPath,string,string>`_
## * `joinPath(varargs) proc <#joinPath,varargs[string]>`_
## * `splitPath proc <#splitPath,string>`_
## * `uri.combine proc <uri.html#combine,Uri,Uri>`_
## * `uri./ proc <uri.html#/,Uri,string>`_
runnableExamples:
when defined(posix):
assert "usr" / "" == "usr/"

View file

@ -29,8 +29,7 @@ const
nativeStackTraceSupported = false
hasSomeStackTrace = false
proc quitOrDebug() {.inline.} =
quit(1)
proc quitOrDebug() {.noreturn, importc: "abort", header: "<stdlib.h>", nodecl.}
proc raiseException(e: ref Exception, ename: cstring) {.compilerRtl.} =
sysFatal(ReraiseError, "exception handling is not available")

View file

@ -38,10 +38,15 @@ proc showErrorMessage(data: cstring) {.gcsafe.} =
writeToStdErr(data)
proc quitOrDebug() {.inline.} =
when not defined(endb):
quit(1)
else:
when defined(endb):
endbStep() # call the debugger
elif not defined(nodejs) and not defined(nimscript):
when nimvm:
quit(1)
else:
c_abort()
else:
quit(1)
proc chckIndx(i, a, b: int): int {.inline, compilerproc, benign.}
proc chckRange(i, a, b: int): int {.inline, compilerproc, benign.}

View file

@ -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