diff options
Diffstat (limited to 'lib/system')
-rw-r--r-- | lib/system/channels.nim | 8 | ||||
-rw-r--r-- | lib/system/io.nim | 24 |
2 files changed, 16 insertions, 16 deletions
diff --git a/lib/system/channels.nim b/lib/system/channels.nim index e4b172c16..51a6f44ee 100644 --- a/lib/system/channels.nim +++ b/lib/system/channels.nim @@ -151,7 +151,7 @@ type region: MemRegion PRawChannel = ptr RawChannel LoadStoreMode = enum mStore, mLoad - Channel* {.gcsafe.}[TMsg] = RawChannel ## a channel for thread communication + Channel*[TMsg] {.gcsafe.} = RawChannel ## a channel for thread communication const ChannelDeadMask = -2 @@ -248,7 +248,7 @@ when not usesDestructors: dstseq.reserved = seq.len for i in 0..seq.len-1: storeAux( - cast[pointer](dst +% align(GenericSeqSize, mt.base.align) +% i*% mt.base.size), + cast[pointer](dst +% align(GenericSeqSize, mt.base.align) +% i *% mt.base.size), cast[pointer](cast[ByteAddress](s2) +% align(GenericSeqSize, mt.base.align) +% i *% mt.base.size), mt.base, t, mode) @@ -265,8 +265,8 @@ when not usesDestructors: storeAux(dest, src, mt.node, t, mode) of tyArray, tyArrayConstr: for i in 0..(mt.size div mt.base.size)-1: - storeAux(cast[pointer](d +% i*% mt.base.size), - cast[pointer](s +% i*% mt.base.size), mt.base, t, mode) + storeAux(cast[pointer](d +% i *% mt.base.size), + cast[pointer](s +% i *% mt.base.size), mt.base, t, mode) of tyRef: var s = cast[PPointer](src)[] var x = cast[PPointer](dest) diff --git a/lib/system/io.nim b/lib/system/io.nim index 86f4be2b9..016db4bac 100644 --- a/lib/system/io.nim +++ b/lib/system/io.nim @@ -434,19 +434,19 @@ proc readLine*(f: File, line: var string): bool {.tags: [ReadIOEffect], var pos = 0 # Use the currently reserved space for a first try - var sp = max(line.string.len, 80) - line.string.setLen(sp) + var sp = max(line.len, 80) + line.setLen(sp) while true: # memset to \L so that we can tell how far fgets wrote, even on EOF, where # fgets doesn't append an \L - for i in 0..<sp: line.string[pos+i] = '\L' + for i in 0..<sp: line[pos+i] = '\L' var fgetsSuccess: bool while true: # fixes #9634; this pattern may need to be abstracted as a template if reused; # likely other io procs need this for correctness. - fgetsSuccess = c_fgets(addr line.string[pos], sp.cint, f) != nil + fgetsSuccess = c_fgets(addr line[pos], sp.cint, f) != nil if fgetsSuccess: break when not defined(NimScript): if errno == EINTR: @@ -456,20 +456,20 @@ proc readLine*(f: File, line: var string): bool {.tags: [ReadIOEffect], checkErr(f) break - let m = c_memchr(addr line.string[pos], '\L'.ord, cast[csize_t](sp)) + let m = c_memchr(addr line[pos], '\L'.ord, cast[csize_t](sp)) if m != nil: # \l found: Could be our own or the one by fgets, in any case, we're done - var last = cast[ByteAddress](m) - cast[ByteAddress](addr line.string[0]) - if last > 0 and line.string[last-1] == '\c': - line.string.setLen(last-1) + var last = cast[ByteAddress](m) - cast[ByteAddress](addr line[0]) + if last > 0 and line[last-1] == '\c': + line.setLen(last-1) return last > 1 or fgetsSuccess # We have to distinguish between two possible cases: # \0\l\0 => line ending in a null character. # \0\l\l => last line without newline, null was put there by fgets. - elif last > 0 and line.string[last-1] == '\0': - if last < pos + sp - 1 and line.string[last+1] != '\0': + elif last > 0 and line[last-1] == '\0': + if last < pos + sp - 1 and line[last+1] != '\0': dec last - line.string.setLen(last) + line.setLen(last) return last > 0 or fgetsSuccess else: # fgets will have inserted a null byte at the end of the string. @@ -477,7 +477,7 @@ proc readLine*(f: File, line: var string): bool {.tags: [ReadIOEffect], # No \l found: Increase buffer and read more inc pos, sp sp = 128 # read in 128 bytes at a time - line.string.setLen(pos+sp) + line.setLen(pos+sp) proc readLine*(f: File): string {.tags: [ReadIOEffect], benign.} = ## reads a line of text from the file `f`. May throw an IO exception. |