diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/pure/strutils.nim | 9 | ||||
-rwxr-xr-x | lib/system.nim | 4 | ||||
-rwxr-xr-x | lib/system/assign.nim | 21 | ||||
-rwxr-xr-x | lib/system/inclrtl.nim | 2 | ||||
-rwxr-xr-x | lib/system/sysstr.nim | 2 |
5 files changed, 22 insertions, 16 deletions
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index 435f522eb..de555917c 100755 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -406,14 +406,16 @@ proc ParseInt*(s: string): int {.noSideEffect, procvar, ## Parses a decimal integer value contained in `s`. If `s` is not ## a valid integer, `EInvalidValue` is raised. var L = parseutils.parseInt(s, result, 0) - if L != s.len: raise newException(EInvalidValue, "invalid integer: " & s) + if L != s.len or L == 0: + raise newException(EInvalidValue, "invalid integer: " & s) proc ParseBiggestInt*(s: string): biggestInt {.noSideEffect, procvar, rtl, extern: "nsuParseBiggestInt".} = ## Parses a decimal integer value contained in `s`. If `s` is not ## a valid integer, `EInvalidValue` is raised. var L = parseutils.parseBiggestInt(s, result, 0) - if L != s.len: raise newException(EInvalidValue, "invalid integer: " & s) + if L != s.len or L == 0: + raise newException(EInvalidValue, "invalid integer: " & s) proc ParseFloat*(s: string): float {.noSideEffect, procvar, rtl, extern: "nsuParseFloat".} = @@ -421,7 +423,8 @@ proc ParseFloat*(s: string): float {.noSideEffect, procvar, ## a valid floating point number, `EInvalidValue` is raised. ``NAN``, ## ``INF``, ``-INF`` are also supported (case insensitive comparison). var L = parseutils.parseFloat(s, result, 0) - if L != s.len: raise newException(EInvalidValue, "invalid float: " & s) + if L != s.len or L == 0: + raise newException(EInvalidValue, "invalid float: " & s) proc ParseHexInt*(s: string): int {.noSideEffect, procvar, rtl, extern: "nsuParseHexInt".} = diff --git a/lib/system.nim b/lib/system.nim index 6909185e6..043275302 100755 --- a/lib/system.nim +++ b/lib/system.nim @@ -1198,12 +1198,12 @@ proc each*[T](data: var openArray[T], op: proc (x: var T)) = # ----------------- GC interface --------------------------------------------- -proc GC_disable*() {.rtl.} +proc GC_disable*() {.rtl, inl.} ## disables the GC. If called n-times, n calls to `GC_enable` are needed to ## reactivate the GC. Note that in most circumstances one should only disable ## the mark and sweep phase with `GC_disableMarkAndSweep`. -proc GC_enable*() {.rtl.} +proc GC_enable*() {.rtl, inl.} ## enables the GC again. proc GC_fullCollect*() {.rtl.} diff --git a/lib/system/assign.nim b/lib/system/assign.nim index 9f0afb363..24d688ca9 100755 --- a/lib/system/assign.nim +++ b/lib/system/assign.nim @@ -7,9 +7,7 @@ # distribution, for details about the copyright. # -#when defined(debugGC): -# {.define: logAssign.} -proc genericAssign(dest, src: Pointer, mt: PNimType) {.compilerProc.} +proc genericAssignAux(dest, src: Pointer, mt: PNimType) proc genericAssignAux(dest, src: Pointer, n: ptr TNimNode) = var d = cast[TAddress](dest) @@ -17,8 +15,8 @@ proc genericAssignAux(dest, src: Pointer, n: ptr TNimNode) = case n.kind of nkNone: assert(false) of nkSlot: - genericAssign(cast[pointer](d +% n.offset), cast[pointer](s +% n.offset), - n.typ) + genericAssignAux(cast[pointer](d +% n.offset), cast[pointer](s +% n.offset), + n.typ) of nkList: for i in 0..n.len-1: genericAssignAux(dest, src, n.sons[i]) @@ -28,7 +26,7 @@ proc genericAssignAux(dest, src: Pointer, n: ptr TNimNode) = var m = selectBranch(src, n) if m != nil: genericAssignAux(dest, src, m) -proc genericAssign(dest, src: Pointer, mt: PNimType) = +proc genericAssignAux(dest, src: Pointer, mt: PNimType) = var d = cast[TAddress](dest) s = cast[TAddress](src) @@ -47,7 +45,7 @@ proc genericAssign(dest, src: Pointer, mt: PNimType) = newObj(mt, seq.len * mt.base.size + GenericSeqSize)) var dst = cast[taddress](cast[ppointer](dest)^) for i in 0..seq.len-1: - genericAssign( + genericAssignAux( cast[pointer](dst +% i*% mt.base.size +% GenericSeqSize), cast[pointer](cast[taddress](s2) +% i *% mt.base.size +% GenericSeqSize), @@ -60,8 +58,8 @@ proc genericAssign(dest, src: Pointer, mt: PNimType) = genericAssignAux(dest, src, mt.node) of tyArray, tyArrayConstr: for i in 0..(mt.size div mt.base.size)-1: - genericAssign(cast[pointer](d +% i*% mt.base.size), - cast[pointer](s +% i*% mt.base.size), mt.base) + genericAssignAux(cast[pointer](d +% i*% mt.base.size), + cast[pointer](s +% i*% mt.base.size), mt.base) of tyString: # a leaf var s2 = cast[ppointer](s)^ if s2 != nil: # nil strings are possible! @@ -75,6 +73,11 @@ proc genericAssign(dest, src: Pointer, mt: PNimType) = else: copyMem(dest, src, mt.size) # copy raw bits +proc genericAssign(dest, src: Pointer, mt: PNimType) {.compilerProc.} = + GC_disable() + genericAssignAux(dest, src, mt) + GC_enable() + proc genericSeqAssign(dest, src: Pointer, mt: PNimType) {.compilerProc.} = var src = src # ugly, but I like to stress the parser sometimes :-) genericAssign(dest, addr(src), mt) diff --git a/lib/system/inclrtl.nim b/lib/system/inclrtl.nim index 3898355c8..23cecfbc1 100755 --- a/lib/system/inclrtl.nim +++ b/lib/system/inclrtl.nim @@ -1,7 +1,7 @@ # # # Nimrod's Runtime Library -# (c) Copyright 2010 Andreas Rumpf +# (c) Copyright 2011 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. diff --git a/lib/system/sysstr.nim b/lib/system/sysstr.nim index 6c5435724..2afb91d7b 100755 --- a/lib/system/sysstr.nim +++ b/lib/system/sysstr.nim @@ -1,7 +1,7 @@ # # # Nimrod's Runtime Library -# (c) Copyright 2010 Andreas Rumpf +# (c) Copyright 2011 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. |