summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCarlin Bingham <cb@viennan.net>2019-03-14 00:50:15 +1300
committerOri Bernstein <ori@eigenstate.org>2019-03-13 23:44:43 -0700
commitadff1dabd7ab37d768b7207b57f572e5d27be01a (patch)
tree5ace806860af8da46f2f9b3adb0bc755eacb2964 /lib
parentd51d40bc1674f5845dab709096be84a4e5c51b2b (diff)
downloadmc-adff1dabd7ab37d768b7207b57f572e5d27be01a.tar.gz
Fix bio.readto
Don't change rstart on each iteration as that prevents it being able to return characters at the start of the buffer if the delim is found, and only read characters from the buffer that were actually checked
Diffstat (limited to 'lib')
-rw-r--r--lib/bio/bio.myr7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/bio/bio.myr b/lib/bio/bio.myr
index 62cca13..18982f3 100644
--- a/lib/bio/bio.myr
+++ b/lib/bio/bio.myr
@@ -427,7 +427,7 @@ const readdelim = {f, delim, mode
for i = f.rstart; i <= f.rend - delim.len; i++
for j = 0; j < delim.len; j++
if f.rbuf[i + j] != delim[j]
- goto notfound
+ goto nextiter
;;
;;
/* If we found it, return that information */
@@ -438,12 +438,11 @@ const readdelim = {f, delim, mode
;;
f.rstart += delim.len
-> `std.Ok ret
-:notfound
- f.rstart = i
+:nextiter
;;
match mode
| `Drop: f.rstart = i
- | `Read: readinto(f, &ret, f.rend - f.rstart)
+ | `Read: readinto(f, &ret, i - f.rstart)
| `Keep:
;;
;;