Fixes streams bugs
This commit is contained in:
parent
3fd48b7622
commit
8149c07458
1 changed files with 3 additions and 3 deletions
|
|
@ -132,7 +132,7 @@ proc write*(s: Stream, x: string) =
|
||||||
when nimvm:
|
when nimvm:
|
||||||
writeData(s, cstring(x), x.len)
|
writeData(s, cstring(x), x.len)
|
||||||
else:
|
else:
|
||||||
if x.len > 0: writeData(s, unsafeAddr x[0], x.len)
|
if x.len > 0: writeData(s, cstring(x), x.len)
|
||||||
|
|
||||||
proc writeLine*(s: Stream, args: varargs[string, `$`]) =
|
proc writeLine*(s: Stream, args: varargs[string, `$`]) =
|
||||||
## writes one or more strings to the the stream `s` followed
|
## writes one or more strings to the the stream `s` followed
|
||||||
|
|
@ -252,14 +252,14 @@ proc readStr*(s: Stream, length: int): TaintedString =
|
||||||
## reads a string of length `length` from the stream `s`. Raises `EIO` if
|
## reads a string of length `length` from the stream `s`. Raises `EIO` if
|
||||||
## an error occurred.
|
## an error occurred.
|
||||||
result = newString(length).TaintedString
|
result = newString(length).TaintedString
|
||||||
var L = readData(s, addr(string(result)[0]), length)
|
var L = readData(s, cstring(result), length)
|
||||||
if L != length: setLen(result.string, L)
|
if L != length: setLen(result.string, L)
|
||||||
|
|
||||||
proc peekStr*(s: Stream, length: int): TaintedString =
|
proc peekStr*(s: Stream, length: int): TaintedString =
|
||||||
## peeks a string of length `length` from the stream `s`. Raises `EIO` if
|
## peeks a string of length `length` from the stream `s`. Raises `EIO` if
|
||||||
## an error occurred.
|
## an error occurred.
|
||||||
result = newString(length).TaintedString
|
result = newString(length).TaintedString
|
||||||
var L = peekData(s, addr(string(result)[0]), length)
|
var L = peekData(s, cstring(result), length)
|
||||||
if L != length: setLen(result.string, L)
|
if L != length: setLen(result.string, L)
|
||||||
|
|
||||||
proc readLine*(s: Stream, line: var TaintedString): bool =
|
proc readLine*(s: Stream, line: var TaintedString): bool =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue