Rename checksum fields and variables

This commit is contained in:
Nigel Tao committed 2018-03-28 11:15:13 +11:00
1 parent 86d0ade206
commit 72449fa0ec
7 files changed
+28 -28

No files matched your search

+3 -3
View File
@@ -89,12 +89,12 @@ pub func decoder.decode?(dst writer1, src reader1)() {
}
// Decode and checksum the DEFLATE-encoded payload.
var checksum u32
var checksum_got u32
while true {
in.dst.mark()
var z status = try this.flate.decode?(dst:in.dst, src:in.src)
if not this.ignore_checksum {
// TODO: checksum = this.checksum.update(x:in.dst.since_mark())
// TODO: checksum_got = this.checksum.update(x:in.dst.since_mark())
}
if z.is_ok() {
break
@@ -102,7 +102,7 @@ pub func decoder.decode?(dst writer1, src reader1)() {
yield z
}
// TODO: read the 4 bytes regardless of this.ignore_checksum.
if (not this.ignore_checksum) and (checksum != in.src.read_u32be?()) {
if (not this.ignore_checksum) and (checksum_got != in.src.read_u32be?()) {
// TODO: return error "checksum mismatch"
}
// TODO: handle the 4 byte ISIZE field.
+4 -4
View File
@@ -25,7 +25,7 @@ pub error "TODO: unsupported zlib preset dictionary"
pub struct decoder?(
flate deflate.decoder,
adler adler32,
checksum adler32,
ignore_checksum bool,
)
@@ -49,12 +49,12 @@ pub func decoder.decode?(dst writer1, src reader1)() {
}
// Decode and checksum the DEFLATE-encoded payload.
var checksum u32
var checksum_got u32
while true {
in.dst.mark()
var z status = try this.flate.decode?(dst:in.dst, src:in.src)
if not this.ignore_checksum {
checksum = this.adler.update(x:in.dst.since_mark())
checksum_got = this.checksum.update(x:in.dst.since_mark())
}
if z.is_ok() {
break
@@ -62,7 +62,7 @@ pub func decoder.decode?(dst writer1, src reader1)() {
yield z
}
// TODO: read the 4 bytes regardless of this.ignore_checksum.
if (not this.ignore_checksum) and (checksum != in.src.read_u32be?()) {
if (not this.ignore_checksum) and (checksum_got != in.src.read_u32be?()) {
return error "checksum mismatch"
}
}