core :: Reader :: read_bytes_to_cstring
max
bytes from source and stores them in bytes
# Reads up to `max` bytes from source and stores them in `bytes`
fun read_bytes_to_cstring(bytes: CString, max: Int): Int do
var llen = lookahead_length
if llen == 0 then return raw_read_bytes(bytes, max)
var rd = max.min(llen)
var lk = lookahead
lk.copy_to(bytes, rd, 0, 0)
if rd < llen then
lk.lshift(rd, llen - rd, rd)
lookahead_length -= rd
else
lookahead_length = 0
end
return rd + raw_read_bytes(bytes.fast_cstring(rd), max - rd)
end
lib/core/stream.nit:233,2--247,4