Natools

Check-in [a3ae81e9c1]
Login
Overview
Comment:smaz_implementations-base_64_tools: fix exception on non-ASCII character
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a3ae81e9c18e3c5f07a9e0dd33d260ca8181ba30
User & Date: nat on 2017-01-04 23:07:28
Other Links: manifest | tags
Context
2017-01-05
22:56
Add an ignore file check-in: 1877439212 user: nat tags: trunk
2017-01-04
23:07
smaz_implementations-base_64_tools: fix exception on non-ASCII character check-in: a3ae81e9c1 user: nat tags: trunk
2017-01-03
20:41
smaz_tests: add a check with non-ASCII characters check-in: 03f59a962d user: nat tags: trunk
Changes

Modified src/natools-smaz_implementations-base_64_tools.adb from [7548e9ed0c] to [7feeafd1f2].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
   use type Ada.Streams.Stream_Element_Offset;

   -----------------------
   -- Bit Manipulations --
   -----------------------

   function Low_6 (Byte : in Character) return Base_64_Digit
     is (Character'Pos (Byte) mod 64);
   function Low_4 (Byte : in Character) return Single_Byte_Padding
     is (Character'Pos (Byte) mod 16);
   function Low_2 (Byte : in Character) return Double_Byte_Padding
     is (Character'Pos (Byte) mod 4);
      --  Least significant bits of a byte

   function High_6 (Byte : in Character) return Base_64_Digit
     is (Character'Pos (Byte) / 4);
   function High_4 (Byte : in Character) return Single_Byte_Padding
     is (Character'Pos (Byte) / 16);
   function High_2 (Byte : in Character) return Double_Byte_Padding
     is (Character'Pos (Byte) / 64);
      --  Most significant bits of a byte

   function Image_2_4 (Low : Double_Byte_Padding; High : Single_Byte_Padding)
     return Base_64_Symbol
     is (Image (Low + High * 4));
   function Image_4_2 (Low : Single_Byte_Padding; High : Double_Byte_Padding)
     return Base_64_Symbol







|

|

|



|

|

|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
   use type Ada.Streams.Stream_Element_Offset;

   -----------------------
   -- Bit Manipulations --
   -----------------------

   function Low_6 (Byte : in Character) return Base_64_Digit
     is (Base_64_Digit (Natural (Character'Pos (Byte)) mod 64));
   function Low_4 (Byte : in Character) return Single_Byte_Padding
     is (Single_Byte_Padding (Natural (Character'Pos (Byte)) mod 16));
   function Low_2 (Byte : in Character) return Double_Byte_Padding
     is (Double_Byte_Padding (Natural (Character'Pos (Byte)) mod 4));
      --  Least significant bits of a byte

   function High_6 (Byte : in Character) return Base_64_Digit
     is (Base_64_Digit (Natural (Character'Pos (Byte)) / 4));
   function High_4 (Byte : in Character) return Single_Byte_Padding
     is (Single_Byte_Padding (Natural (Character'Pos (Byte)) / 16));
   function High_2 (Byte : in Character) return Double_Byte_Padding
     is (Double_Byte_Padding (Natural (Character'Pos (Byte)) / 64));
      --  Most significant bits of a byte

   function Image_2_4 (Low : Double_Byte_Padding; High : Single_Byte_Padding)
     return Base_64_Symbol
     is (Image (Low + High * 4));
   function Image_4_2 (Low : Single_Byte_Padding; High : Double_Byte_Padding)
     return Base_64_Symbol