This commit is contained in:
Dmitry Atamanov 2018-04-06 11:09:05 +03:00 • committed by Andreas Rumpf
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 ## Reads a line from a stream `s`. Note: This is not very efficient. Raises
## `EIO` if an error occurred. ## `EIO` if an error occurred.
result = TaintedString"" result = TaintedString""
if s.atEnd:
raise newEIO("cannot read from stream")
while true: while true:
var c = readChar(s) var c = readChar(s)
if c == '\c': if c == '\c':

View file

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