lib/core: fix read_bytes_to_cstring implementation
authorLucas Bajolet <lucas.bajolet@gmail.com>
Thu, 10 May 2018 21:49:47 +0000 (17:49 -0400)
committerLucas Bajolet <lucas.bajolet@gmail.com>
Fri, 11 May 2018 18:37:20 +0000 (14:37 -0400)
When reading bytes from both the lookahead and a source, the lookahead
bytes were not kept in the cstring and we re-written by the
raw_read_bytes after that.

This commit fixes that behaviour.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

lib/core/stream.nit

index 5447b94..c86ea1b 100644 (file)
@@ -240,7 +240,7 @@ abstract class Reader
                else
                        lookahead_length = 0
                end
-               return rd + raw_read_bytes(bytes, max - rd)
+               return rd + raw_read_bytes(bytes.fast_cstring(rd), max - rd)
        end
 
        # Read a string until the end of the line.