text
stringlengths
0
234
Dump (n);
return res;
end Read_and_dump_U32;
end Bit_buffer;
procedure Flush (x : Natural) is
use Zip, UnZip, Ada.Streams;
user_aborting : Boolean;
begin
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put ("[Flush .. .");
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
begin
case mode is
when write_to_binary_file =>
BlockWrite (Ada.Streams.Stream_IO.Stream (out_bin_file).all, UnZ_Glob.slide (0 .. x - 1));
when write_to_text_file =>
Zip.Write_as_text (
UnZ_IO.out_txt_file, UnZ_Glob.slide (0 .. x - 1), UnZ_IO.last_char
);
when write_to_memory =>
for i in 0 .. x - 1 loop
output_memory_access.all (UnZ_Glob.uncompressed_index) :=
Ada.Streams.Stream_Element (UnZ_Glob.slide (i));
UnZ_Glob.uncompressed_index := UnZ_Glob.uncompressed_index + 1;
end loop;
when just_test =>
null;
end case;
exception
when others =>
raise UnZip.Write_Error;
Function Definition: procedure Delete_output is -- an error has occured (bad compressed data)
Function Body: begin
if no_trace then -- if there is a trace, we are debugging
case mode is -- and want to keep the malformed file
when write_to_binary_file =>
Ada.Streams.Stream_IO.Delete (UnZ_IO.out_bin_file);
when write_to_text_file =>
Ada.Text_IO.Delete (UnZ_IO.out_txt_file);
when others =>
null;
end case;
end if;
end Delete_output;
end UnZ_IO;
package body UnZ_Meth is
--------[ Method : Unshrink ] --------
-- Original in Pascal written by Christian Ghisler.
Max_Code : constant := 8192;
Max_Stack : constant := 8192;
Initial_Code_Size : constant := 9;
Maximum_Code_Size : constant := 13;
First_Entry : constant := 257;
-- Rest of slide=write buffer =766 bytes
Write_Max : constant := wsize - 3 * (Max_Code - 256) - Max_Stack - 2;
Previous_Code : array (First_Entry .. Max_Code) of Integer;
Actual_Code : array (First_Entry .. Max_Code) of Zip.Byte;
Next_Free : Integer; -- Next free code in trie
Write_Ptr : Integer; -- Pointer to output buffer
Writebuf : Zip.Byte_Buffer (0 .. Write_Max); -- Write buffer
procedure Unshrink_Flush is
use Zip, UnZip, Ada.Streams, Ada.Streams.Stream_IO;
user_aborting : Boolean;
begin
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put ("[Unshrink_Flush]");
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
begin
case mode is
when write_to_binary_file =>
BlockWrite (Stream (UnZ_IO.out_bin_file).all, Writebuf (0 .. Write_Ptr - 1));
when write_to_text_file =>
Zip.Write_as_text (UnZ_IO.out_txt_file, Writebuf (0 .. Write_Ptr - 1), UnZ_IO.last_char);
when write_to_memory =>
for I in 0 .. Write_Ptr - 1 loop
output_memory_access.all (UnZ_Glob.uncompressed_index) :=
Stream_Element (Writebuf (I));
UnZ_Glob.uncompressed_index := UnZ_Glob.uncompressed_index + 1;
end loop;
when just_test =>
null;
end case;