~arslee07/hare-nbt

47fbe9db47ce99fb2cf0d26197d3be6c192d7c4a — arslee07 3 months ago c3b3c08
Fixed loading

io::readall is used instead of io::read to read into the buffer properly
1 files changed, 4 insertions(+), 1 deletions(-)

M format/nbt/load.ha
M format/nbt/load.ha => format/nbt/load.ha +4 -1
@@ 8,7 8,7 @@ use strings;
use math;

fn scan_buf(h: io::handle, buf: const []u8) (void | error) = {
	let result = io::read(h, buf)?;
	let result = io::readall(h, buf)?;
	match (result) {
		case let sz: size =>
			if (sz != len(buf))


@@ 152,6 152,9 @@ fn scan_type(h: io::handle) (tagtype | error) = {

fn scan_string(h: io::handle) (str | error) = {
	let length = scan_short(h)?: u16;
	if (length == 0) {
		return "";
	};
	let buf: []u8 = alloc([0...], length);
	scan_buf(h, buf)?;
	return strings::fromutf8_unsafe(buf);