diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-10-21 16:57:57 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-10-21 16:57:57 +0200 |
commit | e2eb9f815ebcc129aea934ddb1e26698b07806ed (patch) | |
tree | 127b23b3fc0e3800256a443fbc3c5a001438625b /lib | |
parent | c247b50c0080fbb15b53f5ad568fee2f5a292928 (diff) | |
download | Nim-e2eb9f815ebcc129aea934ddb1e26698b07806ed.tar.gz |
fixes #564
Diffstat (limited to 'lib')
-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 |