text
stringlengths
0
234
exception
when others =>
raise UnZip.Write_Error;
Function Definition: procedure Clear_Leaf_Nodes is
Function Body: Pc : Integer; -- previous code
Act_Max_Code : Integer; -- max code to be searched for leaf nodes
begin
Act_Max_Code := Next_Free - 1;
for I in First_Entry .. Act_Max_Code loop
Previous_Code (I) :=
Integer (Unsigned_32 (Previous_Code (I)) or 16#8000#);
end loop;
for I in First_Entry .. Act_Max_Code loop
Pc := Previous_Code (I) mod 16#8000#;
if Pc > 256 then
Previous_Code (Pc) := Previous_Code (Pc) mod 16#8000#;
end if;
end loop;
-- Build new free list
Pc := -1;
Next_Free := -1;
for I in First_Entry .. Act_Max_Code loop
-- Either free before or marked now
if (Unsigned_32 (Previous_Code (I)) and 16#C000#) /= 0 then
-- Link last item to this item
if Pc = -1 then
Next_Free := I;
else
Previous_Code (Pc) := -I;
end if;
Pc := I;
end if;
end loop;
if Pc /= -1 then
Previous_Code (Pc) := -Act_Max_Code - 1;
end if;
end Clear_Leaf_Nodes;
procedure Unshrink is
Incode : Integer; -- Code read in
Last_Incode : Integer;
Last_Outcode : Zip.Byte;
Code_Size : Integer := Initial_Code_Size; -- Actual code size (9 .. 13)
Stack : Zip.Byte_Buffer (0 .. Max_Stack); -- Stack for output
Stack_Ptr : Integer := Max_Stack;
New_Code : Integer; -- Save new normal code read
Code_for_Special : constant := 256;
Code_Increase_size : constant := 1;
Code_Clear_table : constant := 2;
S : UnZip.File_size_type := UnZ_Glob.uncompsize;
-- Fix Jan - 2009 : replaces a remaining bits counter as Unsigned_*32* .. .
procedure Read_Code is
pragma Inline (Read_Code);
begin
Incode := UnZ_IO.Bit_buffer.Read_and_dump (Code_Size);
end Read_Code;
begin
Previous_Code := (others => 0);
Actual_Code := (others => 0);
Stack := (others => 0);
Writebuf := (others => 0);
if UnZ_Glob.compsize = Unsigned_32'Last then
-- Compressed Size was not in header!
raise UnZip.Not_supported;
elsif UnZ_Glob.uncompsize = 0 then
return; -- compression of a 0 - file with Shrink.pas
end if;
-- initialize free codes list
for I in Previous_Code'Range loop
Previous_Code (I) := -(I + 1);
end loop;
Next_Free := First_Entry;
Write_Ptr := 0;
Read_Code;
Last_Incode := Incode;
Last_Outcode := Zip.Byte (Incode);
Write_Byte (Last_Outcode);
S := S - 1;
while S > 0 and then not UnZ_Glob.Zip_EOF loop
Read_Code;
if Incode = Code_for_Special then
Read_Code;
case Incode is
when Code_Increase_size =>