added system.setControlCHook, system.writeStackTrace
This commit is contained in:
parent
ccd58fba2c
commit
b2746c4659
4 changed files with 17 additions and 2 deletions
|
|
@ -85,7 +85,8 @@ proc setRow(stmt: PStmt, r: var TRow, cols: int) =
|
||||||
for col in 0..cols-1:
|
for col in 0..cols-1:
|
||||||
setLen(r[col], column_bytes(stmt, col)) # set capacity
|
setLen(r[col], column_bytes(stmt, col)) # set capacity
|
||||||
setLen(r[col], 0)
|
setLen(r[col], 0)
|
||||||
add(r[col], column_text(stmt, col))
|
let x = column_text(stmt, col)
|
||||||
|
if not isNil(x): add(r[col], x)
|
||||||
|
|
||||||
iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): TRow =
|
args: openarray[string]): TRow =
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ proc parseBiggestInt*(s: string, number: var biggestInt, start = 0): int {.
|
||||||
## parses an integer starting at `start` and stores the value into `number`.
|
## parses an integer starting at `start` and stores the value into `number`.
|
||||||
## Result is the number of processed chars or 0 if there is no integer.
|
## Result is the number of processed chars or 0 if there is no integer.
|
||||||
## `EOverflow` is raised if an overflow occurs.
|
## `EOverflow` is raised if an overflow occurs.
|
||||||
var res: biggestInt = number
|
var res: biggestInt
|
||||||
# use 'res' for exception safety (don't write to 'number' in case of an
|
# use 'res' for exception safety (don't write to 'number' in case of an
|
||||||
# overflow exception:
|
# overflow exception:
|
||||||
result = rawParseInt(s, res, start)
|
result = rawParseInt(s, res, start)
|
||||||
|
|
@ -281,6 +281,7 @@ proc parseBiggestFloat*(s: string, number: var biggestFloat, start = 0): int {.
|
||||||
while s[i] == '_': inc(i)
|
while s[i] == '_': inc(i)
|
||||||
# Calculate Exponent
|
# Calculate Exponent
|
||||||
var hd = 1.0
|
var hd = 1.0
|
||||||
|
# XXX: this loop is horrible for large exponents:
|
||||||
for j in 1..exponent: hd = hd * 10.0
|
for j in 1..exponent: hd = hd * 10.0
|
||||||
if esign > 0.0: number = number * hd
|
if esign > 0.0: number = number * hd
|
||||||
else: number = number / hd
|
else: number = number / hd
|
||||||
|
|
|
||||||
|
|
@ -1872,6 +1872,14 @@ when not defined(EcmaScript) and not defined(NimrodVM):
|
||||||
initStackBottom()
|
initStackBottom()
|
||||||
initGC()
|
initGC()
|
||||||
|
|
||||||
|
proc setControlCHook*(hook: proc () {.noconv.})
|
||||||
|
## allows you to override the behaviour of your application when CTRL+C
|
||||||
|
## is pressed. Only one such hook is supported.
|
||||||
|
|
||||||
|
proc writeStackTrace*()
|
||||||
|
## writes the current stack trace to ``stderr``. This is only works
|
||||||
|
## for debug builds.
|
||||||
|
|
||||||
{.push stack_trace: off.}
|
{.push stack_trace: off.}
|
||||||
include "system/excpt"
|
include "system/excpt"
|
||||||
# we cannot compile this with stack tracing on
|
# we cannot compile this with stack tracing on
|
||||||
|
|
|
||||||
|
|
@ -292,6 +292,11 @@ proc registerSignalHandler() =
|
||||||
when not defined(noSignalHandler):
|
when not defined(noSignalHandler):
|
||||||
registerSignalHandler() # call it in initialization section
|
registerSignalHandler() # call it in initialization section
|
||||||
|
|
||||||
|
proc setControlCHook(hook: proc () {.noconv.}) =
|
||||||
|
# ugly cast, but should work on all architectures:
|
||||||
|
type TSignalHandler = proc (sig: cint) {.noconv.}
|
||||||
|
c_signal(SIGINT, cast[TSignalHandler](hook))
|
||||||
|
|
||||||
proc raiseRangeError(val: biggestInt) {.compilerproc, noreturn, noinline.} =
|
proc raiseRangeError(val: biggestInt) {.compilerproc, noreturn, noinline.} =
|
||||||
raise newException(EOutOfRange, "value " & $val & " out of range")
|
raise newException(EOutOfRange, "value " & $val & " out of range")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue