This commit is contained in:
Andreas Rumpf 2016-10-21 16:57:57 +02:00
commit e2eb9f815e

View file

@ -104,13 +104,14 @@ proc getFileHandle*(f: File): FileHandle = c_fileno(f)
proc readLine(f: File, line: var TaintedString): bool = proc readLine(f: File, line: var TaintedString): bool =
var pos = 0 var pos = 0
# Use the currently reserved space for a first try
when defined(nimscript):
var space: cint = 80 var space: cint = 80
# Use the currently reserved space for a first try
if line.string.isNil:
line = TaintedString(newStringOfCap(80))
else: else:
var space: cint = cint(cast[PGenericSeq](line.string).space) when not defined(nimscript):
space = cint(cast[PGenericSeq](line.string).space)
line.string.setLen(space) line.string.setLen(space)
while true: while true:
# memset to \l so that we can tell how far fgets wrote, even on EOF, where # memset to \l so that we can tell how far fgets wrote, even on EOF, where
# fgets doesn't append an \l # fgets doesn't append an \l