oridb / mc

Myrddin Compiler
MIT License
387 stars 34 forks source link

Fixes for bio.readto #189

Closed cbvi closed 5 years ago

cbvi commented 5 years ago

A few things:

  1. bio.readto currently only returns the last character found, as f.rstart is being incremented on each iteration. As far as I can tell this is unnecessary, as it isn't read again in the loop, and so only needs to be set for the Drop case when the delimiter is found or the loop ends, which is already being done. Removing that makes readto work, and doesn't appear to change the behaviour of bio.skipto.

  2. Only readinto() the part of the buffer that was checked. This makes readto work when the delimiter crosses the Buffsz boundary, same as skipto does.

  3. Free ret in case of non-eof error, as it may have had data allocated on a previous iteration.