make tio test green again
This commit is contained in:
parent
64517445ea
commit
7896903fd0
1 changed files with 7 additions and 3 deletions
|
|
@ -143,13 +143,17 @@ proc getFileHandle*(f: File): FileHandle = c_fileno(f)
|
|||
|
||||
proc readLine(f: File, line: var TaintedString): bool =
|
||||
var pos = 0
|
||||
var sp: cint = 80
|
||||
line.string.setLen(sp)
|
||||
|
||||
# Use the currently reserved space for a first try
|
||||
var sp = line.string.len
|
||||
if sp == 0:
|
||||
sp = 80
|
||||
line.string.setLen(sp)
|
||||
while true:
|
||||
# memset to \L so that we can tell how far fgets wrote, even on EOF, where
|
||||
# fgets doesn't append an \L
|
||||
nimSetMem(addr line.string[pos], '\L'.ord, sp)
|
||||
var fgetsSuccess = c_fgets(addr line.string[pos], sp, f) != nil
|
||||
var fgetsSuccess = c_fgets(addr line.string[pos], sp.cint, f) != nil
|
||||
if not fgetsSuccess: checkErr(f)
|
||||
let m = c_memchr(addr line.string[pos], '\L'.ord, sp)
|
||||
if m != nil:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue