~sircmpwn/hare-compress

890c1e62f3921e1a34ab1218818c66da51d52abc — Drew DeVault 9 months ago 78bfbe2
all: strio/bufio => memio
2 files changed, 11 insertions(+), 11 deletions(-)

M compress/gzip/reader.ha
M compress/zlib/+test.ha
M compress/gzip/reader.ha => compress/gzip/reader.ha +8 -8
@@ 5,12 5,12 @@ use endian;
use errors;
use fmt;
use fs;
use hash;
use hash::crc32;
use hash;
use io;
use memio;
use os;
use strings;
use strio;
use time;

def GZIPID1: u8     = 0x1f;


@@ 140,7 140,7 @@ const reader_vtable: io::vtable = io::vtable {

// read an ISO 8859-1 (LATIN-1) string and return it in UTF-8
fn readstr(s: io::handle, h: *hash::hash) (str | io::error) = {
	let out = strio::dynamic();
	let out = memio::dynamic();
	let st = io::tee(s, h);
	for (true) {
		const ch = match (bufio::scanbyte(&st)?) {


@@ 154,7 154,7 @@ fn readstr(s: io::handle, h: *hash::hash) (str | io::error) = {
		};
		io::writeall(&out, iso88591[ch])!;
	};
	return strio::string(&out);
	return memio::string(&out)!;
};

@test fn readstr() void = {


@@ 165,7 165,7 @@ fn readstr(s: io::handle, h: *hash::hash) (str | io::error) = {
	];
	for (let i = 0z; i < len(vectors); i += 1) {
		const vector = vectors[i];
		const st = bufio::fixed(vector.0, io::mode::READ);
		const st = memio::fixed(vector.0);
		const h = crc32::crc32(&hash::crc32::ieee_table);
		const s = readstr(&st, &h) as str;
		assert(s == vector.1);


@@ 207,8 207,8 @@ fn close(s: *io::stream) (void | io::error) = {

@test fn decompress() void = {
	for (let i = 0z; i < len(vectors); i += 1) {
		let in = bufio::fixed(*vectors[i].2, io::mode::READ);
		let out = bufio::dynamic(io::mode::WRITE);
		let in = memio::fixed(*vectors[i].2);
		let out = memio::dynamic();
		let d = match (decompress(&in)) {
		case let res: (header, reader) =>
			yield res.1;


@@ 223,7 223,7 @@ fn close(s: *io::stream) (void | io::error) = {
		case size =>
			yield;
		};
		let s = bufio::buffer(&out);
		let s = memio::buffer(&out);
		assert(bytes::equal(s, *vectors[i].1));
		assert(d.header.name == vectors[i].0);
	};

M compress/zlib/+test.ha => compress/zlib/+test.ha +3 -3
@@ 29,8 29,8 @@ use memio;

@test fn decompress() void = {
	for (let i = 1z; i < len(vectors); i += 1) {
		let in = bufio::fixed(*vectors[i].1, io::mode::READ);
		let out = bufio::dynamic(io::mode::WRITE);
		let in = memio::fixed(*vectors[i].1);
		let out = memio::dynamic();
		let d = match (decompress(&in)) {
		case let s: reader =>
			yield s;


@@ 44,7 44,7 @@ use memio;
			fmt::errorfln("vector {}: {}", i, io::strerror(e))!;
			abort();
		};
		let s = bufio::buffer(&out);
		let s = memio::buffer(&out);
		assert(bytes::equal(s, *vectors[i].0));
	};
};