std/xz: prepare to decode concatenated streams

This commit is contained in:
Nigel Tao committed 2024-02-26 21:48:31 +11:00
1 parent f06858f395
commit 8ff5693d9d
2 files changed
+10 -4

No files matched your search

+2
View File
@@ -67900,6 +67900,7 @@ wuffs_xz__decoder__do_transform_io(
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
do {
{ {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
uint64_t t_0; uint64_t t_0;
@@ -68603,6 +68604,7 @@ wuffs_xz__decoder__do_transform_io(
status = wuffs_base__make_status(wuffs_xz__error__bad_footer); status = wuffs_base__make_status(wuffs_xz__error__bad_footer);
goto exit; goto exit;
} }
} while (0);
ok: ok:
self->private_impl.p_do_transform_io = 0; self->private_impl.p_do_transform_io = 0;
+8 -4
View File
@@ -153,6 +153,7 @@ pri func decoder.do_transform_io?(dst: base.io_writer, src: base.io_reader, work
var c8 : base.u8 var c8 : base.u8
var footer_magic : base.u16 var footer_magic : base.u16
while.streams true {
header_magic = args.src.read_u48le_as_u64?() header_magic = args.src.read_u48le_as_u64?()
if header_magic <> '\xFD\x37\x7A\x58\x5A\x00'le { if header_magic <> '\xFD\x37\x7A\x58\x5A\x00'le {
return "#bad header" return "#bad header"
@@ -181,13 +182,13 @@ pri func decoder.do_transform_io?(dst: base.io_writer, src: base.io_reader, work
} }
this.flags = (header_magic & 0xFFFF) as base.u16 this.flags = (header_magic & 0xFFFF) as base.u16
while true { while.blocks true {
if args.src.length() <= 0 { if args.src.length() <= 0 {
yield? base."$short read" yield? base."$short read"
continue continue.blocks
} else if args.src.peek_u8() == 0x00 { } else if args.src.peek_u8() == 0x00 {
// We've hit the Index instead of a Block. // We've hit the Index instead of a Block.
break break.blocks
} }
this.num_actual_blocks ~mod+= 1 this.num_actual_blocks ~mod+= 1
@@ -367,7 +368,7 @@ pri func decoder.do_transform_io?(dst: base.io_writer, src: base.io_reader, work
return "#bad checksum" return "#bad checksum"
} }
} }
} endwhile } endwhile.blocks
// Verify the index. // Verify the index.
this.backwards_size = 0 this.backwards_size = 0
@@ -429,6 +430,9 @@ pri func decoder.do_transform_io?(dst: base.io_writer, src: base.io_reader, work
if footer_magic <> '\x59\x5A'le { if footer_magic <> '\x59\x5A'le {
return "#bad footer" return "#bad footer"
} }
break.streams
} endwhile.streams
} }
pri func decoder.decode_block_header_with_padding?(src: base.io_reader) { pri func decoder.decode_block_header_with_padding?(src: base.io_reader) {