Natools

Check-in [418ab16bcf]
Login
Overview
Comment:smaz_implementations-base_64: fix encoding issue with with multiblock
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 418ab16bcf14dee45cb66a8c30edd45df865426d
User & Date: nat on 2017-06-25 21:14:12
Other Links: manifest | tags
Context
2017-06-26
20:11
s_expressions-file_writers: add primitive to open or create when needed check-in: c30800d3c3 user: nat tags: trunk
2017-06-25
21:14
smaz_implementations-base_64: fix encoding issue with with multiblock check-in: 418ab16bcf user: nat tags: trunk
2017-06-24
21:03
smaz_tests: new test showing a bug in multiblock base-64 encoding check-in: 84e2f2a874 user: nat tags: trunk
Changes

Modified src/natools-smaz_implementations-base_64.adb from [d47cc06763] to [2229a315c8].

142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
                 + Tools.Image_Length (Last_Run_Size) + Last_Run_Header_Size;
         end;
      else
         declare
            Largest_Prefix : constant Natural
              := (case Input_Length mod 3 is
                  when 1 => 15 * 3 + 1,
                  when 2 => ((62 - Natural (Last_Code)) * 4 - 1) * 3 + 2,
                  when others => 0);
            Prefix_Header_Size : constant Ada.Streams.Stream_Element_Count
              := (if Largest_Prefix > 0 then 1 else 0);
            Largest_Run : constant Positive := 64 * 3;
            Prefix_Size : constant Natural
              := Natural'Min (Largest_Prefix, Input_Length);
            Run_Count : constant Natural







|







142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
                 + Tools.Image_Length (Last_Run_Size) + Last_Run_Header_Size;
         end;
      else
         declare
            Largest_Prefix : constant Natural
              := (case Input_Length mod 3 is
                  when 1 => 15 * 3 + 1,
                  when 2 => ((61 - Natural (Last_Code)) * 4 - 1) * 3 + 2,
                  when others => 0);
            Prefix_Header_Size : constant Ada.Streams.Stream_Element_Count
              := (if Largest_Prefix > 0 then 1 else 0);
            Largest_Run : constant Positive := 64 * 3;
            Prefix_Size : constant Natural
              := Natural'Min (Largest_Prefix, Input_Length);
            Run_Count : constant Natural
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
                  Index := Index + Extra_Blocks * 3;
               end if;
            end;
         elsif Input'Length mod 3 = 2 then
            declare
               Extra_Blocks : constant Natural := Natural'Min
                 (Input'Length / 3,
                  (62 - Natural (Last_Code)) * 4 - 1);
            begin
               Output (Offset)
                 := Tools.Image (61 - Tools.Base_64_Digit (Extra_Blocks / 4));
               Offset := Offset + 1;

               Tools.Encode_Double
                 (Input (Index .. Index + 1),







|







249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
                  Index := Index + Extra_Blocks * 3;
               end if;
            end;
         elsif Input'Length mod 3 = 2 then
            declare
               Extra_Blocks : constant Natural := Natural'Min
                 (Input'Length / 3,
                  (61 - Natural (Last_Code)) * 4 - 1);
            begin
               Output (Offset)
                 := Tools.Image (61 - Tools.Base_64_Digit (Extra_Blocks / 4));
               Offset := Offset + 1;

               Tools.Encode_Double
                 (Input (Index .. Index + 1),