Overview
Comment: | smaz_implementations-base_4096: check end-of-input in Read_Code |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3b9dae1e75a5ac8fa19ae44df39d1ebc |
User & Date: | nat on 2017-02-28 20:13:20 |
Other Links: | manifest | tags |
Context
2017-03-01
| ||
21:38 | smaz_tests: add a test for base-64 input with non-base-64 characters check-in: 8c5686ece7 user: nat tags: trunk | |
2017-02-28
| ||
20:13 | smaz_implementations-base_4096: check end-of-input in Read_Code check-in: 3b9dae1e75 user: nat tags: trunk | |
2017-02-27
| ||
21:27 | smaz_implementations-base_64: check end-of-input in Read_Code check-in: 6c1f9bd682 user: nat tags: trunk | |
Changes
Modified src/natools-smaz_implementations-base_4096.adb from [e5ed72f68a] to [731448fbda].
︙ | ︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | use type Ada.Streams.Stream_Element_Offset; procedure Read_Code (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Code : out Base_4096_Digit); -- Read two base-64 symbols and assemble them into a base-4096 number ------------------------------ -- Local Helper Subprograms -- ------------------------------ procedure Read_Code (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Code : out Base_4096_Digit) is Low, High : Tools.Base_64_Digit; begin Tools.Next_Digit (Input, Offset, Low); Tools.Next_Digit (Input, Offset, High); Code := Base_4096_Digit (Low) + Base_4096_Digit (High) * 64; end Read_Code; ---------------------- -- Public Interface -- ---------------------- procedure Read_Code (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Code : out Base_4096_Digit; Verbatim_Length : out Natural; Last_Code : in Base_4096_Digit; | > > > > > > > > > > > > > > > > > > > > > > > > | > > | > > > > > > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | use type Ada.Streams.Stream_Element_Offset; procedure Read_Code (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Code : out Base_4096_Digit); procedure Read_Code_Or_End (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Code : out Base_4096_Digit; Finished : out Boolean); -- Read two base-64 symbols and assemble them into a base-4096 number ------------------------------ -- Local Helper Subprograms -- ------------------------------ procedure Read_Code (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Code : out Base_4096_Digit) is Low, High : Tools.Base_64_Digit; begin Tools.Next_Digit (Input, Offset, Low); Tools.Next_Digit (Input, Offset, High); Code := Base_4096_Digit (Low) + Base_4096_Digit (High) * 64; end Read_Code; procedure Read_Code_Or_End (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Code : out Base_4096_Digit; Finished : out Boolean) is Low, High : Tools.Base_64_Digit; begin Tools.Next_Digit_Or_End (Input, Offset, Low, Finished); if Finished then return; end if; Tools.Next_Digit (Input, Offset, High); Code := Base_4096_Digit (Low) + Base_4096_Digit (High) * 64; end Read_Code_Or_End; ---------------------- -- Public Interface -- ---------------------- procedure Read_Code (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Code : out Base_4096_Digit; Verbatim_Length : out Natural; Last_Code : in Base_4096_Digit; Variable_Length_Verbatim : in Boolean) is Finished : Boolean; begin Read_Code_Or_End (Input, Offset, Code, Finished); if Finished then Code := Base_4096_Digit'Last; Verbatim_Length := 0; return; end if; if Code <= Last_Code then Verbatim_Length := 0; elsif not Variable_Length_Verbatim then Verbatim_Length := Positive (Base_4096_Digit'Last - Code + 1); Code := 0; elsif Code < Base_4096_Digit'Last then |
︙ | ︙ |