ref: bb00e7717dfd6cf6cb66b9866dae3ea750216177
parent: 03bf16f1492a7bb4b01fad3d1424f9f185788b0b
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Oct 13 21:13:22 EDT 2015
Fix the handling of '\r\n'. We were returning a spurious empty string. Oops.
--- a/lib/bio/bio.myr
+++ b/lib/bio/bio.myr
@@ -418,7 +418,7 @@
/* Same as delim, but with special handling for '\n', '\r', and '\r\n' */
const readln = {f
- var ret, c, n
+ var ret, c
ret = [][:]
while true
@@ -438,13 +438,12 @@
for var i = f.rstart; i < f.rend; i++
c = f.rbuf[i] castto(char)
if c == '\r' || c == '\n'
- n = 1
+ ret = readinto(f, ret, i - f.rstart)
+ f.rstart++
/* if we have '\r', we can get '\r\n'. */
if c == '\r' && unwrapc(peekc(f), -1) == '\n'
- n = 2
+ f.rstart++
;;
- ret = readinto(f, ret, i - f.rstart)
- f.rstart += n
-> `Ok ret
;;
:nextitergetln