Implement the gzip checksum

Also fix a bug in ast.Raw.SetPackage, discovered because type checking
failed to show that "[] u8" and "[] u8" are equivalent types.
This commit is contained in:
Nigel Tao committed 2018-03-28 12:30:00 +11:00
1 parent 153d1276a1
commit a8e40fedc9
7 files changed
+184 -28

No files matched your search

+7 -4
View File
@@ -94,16 +94,19 @@ pub func decoder.decode?(dst writer1, src reader1)() {
in.dst.mark()
var z status = try this.flate.decode?(dst:in.dst, src:in.src)
if not this.ignore_checksum {
// TODO: checksum_got = this.checksum.update(x:in.dst.since_mark())
checksum_got = this.checksum.update(x:in.dst.since_mark())
}
if z.is_ok() {
break
}
yield z
}
var checksum_want u32 = in.src.read_u32be?()
var checksum_want u32 = in.src.read_u32le?()
var decoded_length_want u32 = in.src.read_u32le?()
if (not this.ignore_checksum) and (checksum_got != checksum_want) {
// TODO: return error "checksum mismatch"
return error "checksum mismatch"
}
if decoded_length_want != 0 {
// TODO: compare with decoded_length_got.
}
// TODO: handle the 4 byte ISIZE field.
}