text stringlengths 0 234 |
|---|
K : Integer; |
procedure Init is |
begin |
B := 0; |
K := 0; |
end Init; |
procedure Need( n : Natural ) is |
pragma Inline(Need); |
bt: U8; |
begin |
while K < n loop |
Read_raw_byte( bt ); |
B:= B or Shift_Left( Unsigned_32( bt ), K ); |
K:= K + 8; |
end loop; |
end Need; |
procedure Dump ( n : Natural ) is |
begin |
B := Shift_Right(B, n ); |
K := K - n; |
end Dump; |
procedure Dump_to_byte_boundary is |
begin |
Dump ( K mod 8 ); |
end Dump_to_byte_boundary; |
function Read_U32 ( n: Natural ) return Unsigned_32 is |
begin |
Need(n); |
return B and (Shift_Left(1,n) - 1); |
end Read_U32; |
function Read ( n: Natural ) return Integer is |
begin |
return Integer(Read_U32(n)); |
end Read; |
function Read_and_dump( n: Natural ) return Integer is |
res: Integer; |
begin |
res:= Read(n); |
Dump(n); |
return res; |
end Read_and_dump; |
function Read_and_dump_U32( n: Natural ) return Unsigned_32 is |
res: Unsigned_32; |
begin |
res:= Read_U32(n); |
Dump(n); |
return res; |
end Read_and_dump_U32; |
end Bit_buffer; |
old_bytes: Natural:= 0; |
-- how many bytes to be resent from last Inflate output |
byte_mem: Byte_array(1..8); |
procedure Flush ( x: Natural ) is |
begin |
if full_trace then |
Ada.Text_IO.Put("[Flush..." & Integer'Image(x)); |
end if; |
CRC32.Update( UnZ_Glob.crc32val, UnZ_Glob.slide( 0..x-1 ) ); |
if old_bytes > 0 then |
declare |
app: constant Byte_array:= |
byte_mem(1..old_bytes) & UnZ_Glob.slide(0..x-1); |
begin |
Output_uncompressed(app, old_bytes); |
-- In extreme cases (x very small), we might have some of |
-- the rejected bytes from byte_mem. |
if old_bytes > 0 then |
byte_mem(1..old_bytes):= app(app'Last-(old_bytes-1)..app'Last); |
end if; |
Function Definition: procedure Inflate_stored_block is -- Actually, nothing to inflate |
Function Body: N : Integer; |
begin |
if full_trace then |
Ada.Text_IO.Put_Line("Begin Inflate_stored_block"); |
end if; |
UnZ_IO.Bit_buffer.Dump_to_byte_boundary; |
-- Get the block length and its complement |
N:= UnZ_IO.Bit_buffer.Read_and_dump( 16 ); |
if N /= Integer( |
(not UnZ_IO.Bit_buffer.Read_and_dump_U32(16)) |
and 16#ffff#) |
then |
raise error_in_image_data; |
end if; |
while N > 0 and then not UnZ_Glob.Zip_EOF loop |
-- Read and output the non-compressed data |
N:= N - 1; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.