tree checksum vpatch file split hunks

all signers: bvt phf

antecedents: vtools_vpatch_newline vtools_ksum

press order:

vtools_genesisphf
vdiff_fixes_newline_gccphf
keccakphf
vdiff_keccakphf
vtools_fixes_bitrate_char_arrayphf
vtools_vpatchphf
vtools_fixes_static_tohexphf
vtools_vpatch_newlinephf
vtools_ksumphf
vtools_tempfile_standalone_notmpbvt phf

patch:

- BB7B5CB38AD1749D191B26362C637E55B9ABC4A4B689885ECECC5C7EEA142D86EF56278874B665BB0C14F73819F2857E33F888BCFDC2BDE3F3401F241FA566A4
+ 6E0728447DD05A8E1D4DD21A9647AC87E1E66B16E1CB15DCA1A9E775907767FCAE8B4DB6BE152ABA863BEE3BF15CFB665512A45F001593BFD990B43E4087D3EF
vtools/manifest
(7 . 3)(7 . 4)
5 517100 phf vtools_fixes_static_tohex Fixes for xalloc's use of static inline courtesy of spyked, fix broken ToHex implementation
6 517100 phf vtools_vpatch_newline Vpatch tool support for "No newline at end of file" directive.
7 543200 phf vtools_ksum Ksum standalone keccak hasher
8 547300 bvt vtools_tempfile_standalone_notmp Standalone temporary file generation code; creates temporary files in the vpatch work directory.
-
+ 4747969B6DF8AA268419F3259A757D1FEE33B8B4A7D440B8ADFE07C7F6335060B533791908FF1F5022ECFB51708277A59B0876812C4343E17DF1F3F0DE0EA767
vtools/src/temporary_file.adb
(0 . 0)(1 . 71)
13 with Bits; use Bits;
14 with System; use System;
15 with SMG_Keccak; use SMG_Keccak;
16
17 package body Temporary_File is
18 -- Create a new file or exit when the file with specified name exists.
19 -- Use fopen(3) with "x" mode to create the file or error out if it
20 -- already exists.
21 subtype File_Ptr is System.Address;
22 subtype C_String is System.Address;
23
24 function fopen (Path: C_String;
25 Mode: C_String) return File_Ptr;
26 pragma Import (C, fopen);
27
28 procedure fclose (Stream: File_Ptr);
29 pragma Import (C, fclose);
30
31 function Create_File_Exclusive(Path: String) return Boolean is
32 Fptr: File_Ptr;
33 begin
34 declare
35 XP : aliased String := Path & ASCII.NUL;
36 XM : aliased String := "wx" & ASCII.NUL;
37 begin
38 Fptr := fopen(XP'Address, XM'Address);
39 end;
40 if Fptr = System.Null_Address then
41 return False;
42 end if;
43 fclose(Fptr);
44 return True;
45 end Create_File_Exclusive;
46
47 -- Create a temporary file with a randomly generated name;
48 -- if the file with random component F exists, retry with
49 -- H(F) as a new random component.
50 Function Temporary_File(Path_Prefix: String;
51 Seed: Bitstream) return String is
52 Hash: Bitstream(1..64*8);
53 Name_Ctx: Keccak_Context;
54
55 procedure Hash_Bitstream(Input: Bitstream) is
56 begin
57 KeccakBegin(Name_Ctx);
58 KeccakHash(Name_Ctx, Input);
59 KeccakEnd(Name_Ctx, Hash);
60 end Hash_Bitstream;
61 begin
62 Hash_Bitstream(Seed);
63 loop
64 declare
65 File_Name: String := Path_Prefix & ToHex(Hash);
66 begin
67 if Create_File_Exclusive(File_Name) then
68 return File_Name;
69 end if;
70 end;
71 Hash_Bitstream(Hash);
72 end loop;
73 end Temporary_File;
74
75 function Temporary_File(Path_Prefix: String;
76 Seed: String) return String is
77 B: Bitstream(1..Seed'Length*8);
78 begin
79 ToBitstream(Seed, B);
80 return Temporary_File(Path_Prefix, B);
81 end Temporary_File;
82
83 end Temporary_File;
-
+ 94160EED9E9D4DAF0B80DEA4CC22B8060554E972E84B072EF7B5227DBCDE4F5B0367C0706A6885A00F1151A59039A94DB196370DFCBE941E352AC8838EA3A03E
vtools/src/temporary_file.ads
(0 . 0)(1 . 3)
88 package Temporary_File is
89 function Temporary_File(Path_Prefix: String; Seed: String) return String;
90 end Temporary_File;
- 23DCF3C0EFF5D5CA20CE1C5091E4DC9B739D2D98630208AA16DEC1298A13C28962089C0311E8E50AF9801C026E79F003FE8B9CE9341C351CB4E4556347D14734
+ 11C17FEDC3C0442C3CA93589A47F5FDC4B9AB3BAB4361A96CBFF4BBB15E031D44BFECEED59E5EA6942F552FCA67214C3FC9D956779F77B8A0E7432CA609F779F
vtools/src/vpatch.adb
(1 . 6)(1 . 4)
95 with Bits; use Bits;
96 with Interfaces.C;
97 with Interfaces.C.Strings;
98 with Ada.Text_IO; use Ada.Text_IO;
99 with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
100 with Character_IO; use Character_IO;
(11 . 6)(9 . 7)
102 with Ada.Characters.Latin_1;
103 with Ada.Sequential_IO;
104 with SMG_Keccak; use SMG_Keccak;
105 with Temporary_File; use Temporary_File;
106
107 procedure VPatch is
108 package Latin_1 renames Ada.Characters.Latin_1;
(59 . 36)(58 . 22)
110
111 -- Temporary File
112
113 procedure MkTemp(Template: Interfaces.C.Strings.Chars_Ptr);
114 pragma Import(C, mktemp);
115
116 function Temp_File_Name(Template: String) return String is
117 X: Interfaces.C.Strings.Chars_Ptr
118 := Interfaces.C.Strings.New_String(Template);
119 begin
120 MkTemp(X);
121 declare
122 Result: String := Interfaces.C.Strings.Value(X);
123 begin
124 Interfaces.C.Strings.Free(X);
125 return Result;
126 end;
127 end;
128
129 procedure Create_Temp(File : in out File_Type;
130 Mode : in File_Mode := Out_File;
131 Template : in String := "vpatch.XXX";
132 Prefix : in String;
133 Seed : in String := "";
134 Form : in String := "") is
135 Name: String := Temp_File_Name(Template);
136 Name: String := Temporary_File.Temporary_File(Prefix, Seed);
137 begin
138 Create(File, Mode, Name, Form);
139 end;
140
141 procedure Create_Temp(File : in out CIO.File_Type;
142 Mode : in CIO.File_Mode := CIO.Out_File;
143 Template : in String := "vpatch.XXX";
144 Prefix : in String;
145 Seed : in String := "";
146 Form : in String := "") is
147 Name: String := Temp_File_Name(Template);
148 Name: String := Temporary_File.Temporary_File(Prefix, Seed);
149 begin
150 Create(File, Mode, Name, Form);
151 end;
(466 . 7)(451 . 7)
153
154 -- prepare keccak and open files
155 KeccakBegin(To_Ctx);
156 Create_Temp(To_F, Template => "tmp.XXX");
157 Create_Temp(To_F, Prefix => "vpatch-", Seed => To_F_Name);
158 case Op is
159 when Op_Create =>
160 Has_Input_File := False;