text
stringlengths
0
234
Code_Size := Code_Size + 1;
if some_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put (
"[LZW code size - >" & Integer'Image (Code_Size) & ']'
);
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
if Code_Size > Maximum_Code_Size then
raise Zip.Zip_file_Error;
end if;
when Code_Clear_table =>
Clear_Leaf_Nodes;
when others =>
raise Zip.Zip_file_Error;
end case;
else -- Normal code
New_Code := Incode;
if Incode < 256 then -- Simple char
Last_Outcode := Zip.Byte (Incode);
Write_Byte (Last_Outcode);
S := S - 1;
else
if Previous_Code (Incode) < 0 then
Stack (Stack_Ptr) := Last_Outcode;
Stack_Ptr := Stack_Ptr - 1;
Incode := Last_Incode;
end if;
while Incode > 256 loop
-- Test added 11 - Dec - 2007 for situations
-- happening on corrupt files:
if Stack_Ptr < Stack'First or else
Incode > Actual_Code'Last
then
raise Zip.Zip_file_Error;
end if;
Stack (Stack_Ptr) := Actual_Code (Incode);
Stack_Ptr := Stack_Ptr - 1;
Incode := Previous_Code (Incode);
end loop;
Last_Outcode := Zip.Byte (Incode mod 256);
Write_Byte (Last_Outcode);
for I in Stack_Ptr + 1 .. Max_Stack loop
Write_Byte (Stack (I));
end loop;
S := S - UnZip.File_size_type (Max_Stack - Stack_Ptr + 1);
Stack_Ptr := Max_Stack;
end if;
Incode := Next_Free;
if Incode <= Max_Code then
Next_Free := -Previous_Code (Incode);
-- Next node in free list
Previous_Code (Incode) := Last_Incode;
Actual_Code (Incode) := Last_Outcode;
end if;
Last_Incode := New_Code;
end if;
end loop;
if some_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put ("[ Unshrink main loop finished ]");
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
Unshrink_Flush;
end Unshrink;
--------[ Method : Unreduce ] --------
procedure Unreduce (factor : Reduction_factor) is
-- Original slide limit : 16#4000#
DLE_code : constant := 144;
subtype Symbol_range is Integer range 0 .. 255;
subtype Follower_range is Integer range 0 .. 63; -- Appnote : <= 32 !
Followers : array (Symbol_range, Follower_range) of Symbol_range :=
(others => (others => 0));
Slen : array (Symbol_range) of Follower_range;
-- Bits taken by (x - 1) mod 256:
B_Table : constant array (Symbol_range) of Integer :=
(0 => 8,
1 .. 2 => 1,
3 .. 4 => 2,
5 .. 8 => 3,
9 .. 16 => 4,
17 .. 32 => 5,
33 .. 64 => 6,
65 .. 128 => 7,
129 .. 255 => 8);
procedure LoadFollowers is
list_followers : constant Boolean := some_trace;
procedure Show_symbol (S : Symbol_range) is
begin
if S in 32 .. 254 then
Ada.Text_IO.Put (Character'Val (S));