diff options
-rw-r--r-- | lib/system/sysio.nim | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim index 3e9657ce0..42a9e09ec 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 |