summaryrefslogtreecommitdiff
path: root/lib/bio
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-10-14 01:13:22 -0700
committerOri Bernstein <ori@eigenstate.org>2015-10-14 01:13:22 -0700
commitbb00e7717dfd6cf6cb66b9866dae3ea750216177 (patch)
treeaa092712900c27cecb749c4c3491dd127ffa5c86 /lib/bio
parent03bf16f1492a7bb4b01fad3d1424f9f185788b0b (diff)
downloadmc-bb00e7717dfd6cf6cb66b9866dae3ea750216177.tar.gz
Fix the handling of '\r\n'.
We were returning a spurious empty string. Oops.
Diffstat (limited to 'lib/bio')
-rw-r--r--lib/bio/bio.myr9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/bio/bio.myr b/lib/bio/bio.myr
index bb1592a..584f94e 100644
--- a/lib/bio/bio.myr
+++ b/lib/bio/bio.myr
@@ -418,7 +418,7 @@ const skipspace = {f
/* 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 @@ const readln = {f
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