~sircmpwn/hare-compress

0d4b72a1a71a664d7f664845fea25d7fcc0a54a4 — Sebastian 2 years ago 2150858
io::close can error

Signed-off-by: Sebastian <sebastian@sebsite.pw>
3 files changed, 6 insertions(+), 6 deletions(-)

M compress/flate/inflate.ha
M compress/zlib/.testdata/gen.ha
M compress/zlib/reader.ha
M compress/flate/inflate.ha => compress/flate/inflate.ha +2 -2
@@ 398,7 398,7 @@ fn read(s: *io::stream, buf: []u8) (size | io::EOF | io::error) = {
	return n;
};

fn close(s: *io::stream) void = {
fn close(s: *io::stream) (void | io::error) = {
	const s = s: *decompressor;
	free(s.bufstart);
	free(s.hist);


@@ 433,7 433,7 @@ fn close(s: *io::stream) void = {
	let ins = bufio::fixed(in, io::mode::READ);
	let outs = bufio::dynamic(io::mode::WRITE);
	let s = inflate(&ins);
	defer io::close(&s);
	defer io::close(&s)!;
	match (io::copy(&outs, &s)) {
	case size => void;
	case let e: io::error =>

M compress/zlib/.testdata/gen.ha => compress/zlib/.testdata/gen.ha +2 -2
@@ 29,7 29,7 @@ export fn main() void = {

	for (let i = 0z; i < len(vectors); i += 1) {
		const in = os::open(vectors[i].0)!;
		defer io::close(in);
		defer io::close(in)!;
		const ins = bufio::dynamic(io::mode::WRITE);
		io::copy(ins, in)!;
		const inb = bufio::finish(ins);


@@ 37,7 37,7 @@ export fn main() void = {
		write(vectors[i].0, inb);

		const out = os::open(vectors[i].1)!;
		defer io::close(out);
		defer io::close(out)!;
		const outs = bufio::dynamic(io::mode::WRITE);
		io::copy(outs, out)!;
		const outb = bufio::finish(ins);

M compress/zlib/reader.ha => compress/zlib/reader.ha +2 -2
@@ 85,9 85,9 @@ fn read(s: *io::stream, buf: []u8) (size | io::EOF | io::error) = {
	return hash::write(&s.hash, buf);
};

fn close(s: *io::stream) void = {
fn close(s: *io::stream) (void | io::error) = {
	const s = s: *reader;
	io::close(&s.flate);
	io::close(&s.flate)?;
};

// Creates a stream which decompresses zlib (RFC 1950) data.