This commit is contained in:
Dmitry Atamanov
2018-04-06 11:09:05 +03:00
committed by Andreas Rumpf
parent 4d6456d029
commit cf6d41b51d
2 changed files with 7 additions and 6 deletions

View File

@@ -321,6 +321,8 @@ proc readLine*(s: Stream): TaintedString =
## Reads a line from a stream `s`. Note: This is not very efficient. Raises
## `EIO` if an error occurred.
result = TaintedString""
if s.atEnd:
raise newEIO("cannot read from stream")
while true:
var c = readChar(s)
if c == '\c':

View File

@@ -11,9 +11,8 @@ doAssert fileExists(getCurrentDir() / "tests" / "osproc" / filename)
var p = startProcess(filename, getCurrentDir() / "tests" / "osproc")
p.inputStream.write("5\n")
p.inputStream.flush()
while true:
let line = p.outputStream.readLine()
if line != "":
echo line
else:
break
var line = ""
while p.outputStream.readLine(line.TaintedString):
echo line