From e2eb9f815ebcc129aea934ddb1e26698b07806ed Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Fri, 21 Oct 2016 16:57:57 +0200 Subject: [PATCH] fixes #564 --- lib/system/sysio.nim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim index 3e9657ce08..42a9e09ec8 100644 --- a/lib/system/sysio.nim +++ b/lib/system/sysio.nim @@ -104,13 +104,14 @@ proc getFileHandle*(f: File): FileHandle = c_fileno(f) proc readLine(f: File, line: var TaintedString): bool = var pos = 0 + var space: cint = 80 # Use the currently reserved space for a first try - when defined(nimscript): - var space: cint = 80 + if line.string.isNil: + line = TaintedString(newStringOfCap(80)) else: - var space: cint = cint(cast[PGenericSeq](line.string).space) - line.string.setLen(space) - + when not defined(nimscript): + space = cint(cast[PGenericSeq](line.string).space) + line.string.setLen(space) while true: # memset to \l so that we can tell how far fgets wrote, even on EOF, where # fgets doesn't append an \l