text
stringlengths
0
234
else
Ada.Text_IO.Put ('{' & Symbol_range'Image (S) & '}');
end if;
end Show_symbol;
begin
for X in reverse Symbol_range loop
Slen (X) := UnZ_IO.Bit_buffer.Read_and_dump (6);
if list_followers then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Show_symbol (X);
Ada.Text_IO.Put (" - > (" & Integer'Image (Slen (X)) & ") ");
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
for I in 0 .. Slen (X) - 1 loop
Followers (X, I) := UnZ_IO.Bit_buffer.Read_and_dump (8);
if list_followers then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Show_symbol (Followers (X, I));
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
end loop;
if list_followers then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.New_Line;
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
end loop;
end LoadFollowers;
unreduce_length,
char_read,
last_char : Integer := 0;
-- ^ some := 0 are useless, just to calm down ObjectAda 7.2.2
S : UnZip.File_size_type := UnZ_Glob.uncompsize;
-- number of bytes left to decompress
unflushed : Boolean := True;
maximum_AND_mask : constant Unsigned_32 := Shift_Left (1, 8 - factor) - 1;
procedure Out_byte (b : Zip.Byte) is
begin
S := S - 1;
UnZ_Glob.slide (UnZ_Glob.slide_index) := b;
UnZ_Glob.slide_index := UnZ_Glob.slide_index + 1;
UnZ_IO.Flush_if_full (UnZ_Glob.slide_index, unflushed);
end Out_byte;
V : Unsigned_32 := 0;
type State_type is (normal, length_a, length_b, distance);
state : State_type := normal;
begin
LoadFollowers;
while S > 0 and then not UnZ_Glob.Zip_EOF loop
-- 1/ Probabilistic expansion
if Slen (last_char) = 0 then
-- follower set is empty for this character
char_read := UnZ_IO.Bit_buffer.Read_and_dump (8);
elsif UnZ_IO.Bit_buffer.Read_and_dump (1) = 0 then
char_read := Followers (
last_char,
UnZ_IO.Bit_buffer.Read_and_dump (B_Table (Slen (last_char)))
);
else
char_read := UnZ_IO.Bit_buffer.Read_and_dump (8);
end if;
-- 2/ Expand the resulting Zip.Byte into repeated sequences
case state is
when normal =>
if char_read = DLE_code then
-- >> Next will be a DLE
state := length_a;
else
-- >> A single char
Out_byte (Zip.Byte (char_read));
end if;
when length_a =>
if char_read = 0 then
-- >> DLE_code & 0 - > was just the Zip.Byte coded DLE_code
Out_byte (DLE_code);
state := normal;
else
V := Unsigned_32 (char_read);
unreduce_length := Integer (V and maximum_AND_mask);
-- The remaining bits of V will be used for the distance
if unreduce_length = Integer (maximum_AND_mask) then
state := length_b;
-- >> length must be completed before reading distance
else
state := distance;
end if;
end if;
when length_b =>
unreduce_length := unreduce_length + char_read;
state := distance;