From f140c924090f29e11c2b1d8348413eb4efa4ebe9 Mon Sep 17 00:00:00 2001 From: flywind <43030857+xflywind@users.noreply.github.com> Date: Mon, 8 Feb 2021 06:50:15 -0600 Subject: fix some warnings (#16952) --- lib/system/io.nim | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lib/system/io.nim') 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.. 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. -- cgit 1.4.1-2-gfad0