Index: src/natools-smaz_implementations-base_64_tools.adb ================================================================== --- src/natools-smaz_implementations-base_64_tools.adb +++ src/natools-smaz_implementations-base_64_tools.adb @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ --- Copyright (c) 2016, Natacha Porté -- +-- Copyright (c) 2016-2017, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- @@ -226,10 +226,33 @@ Digit := Value (Input (Offset)); Offset := Offset + 1; end Next_Digit; + + procedure Next_Digit_Or_End + (Input : in Ada.Streams.Stream_Element_Array; + Offset : in out Ada.Streams.Stream_Element_Offset; + Digit : out Base_64_Digit; + Finished : out Boolean) is + begin + loop + if Offset not in Input'Range then + Finished := True; + return; + end if; + + exit when Input (Offset) in Base_64_Symbol; + + Offset := Offset + 1; + end loop; + + Digit := Value (Input (Offset)); + Finished := False; + Offset := Offset + 1; + end Next_Digit_Or_End; + function Symbol_Count (Input : Ada.Streams.Stream_Element_Array) return Ada.Streams.Stream_Element_Count is Result : Ada.Streams.Stream_Element_Count := 0; Index: src/natools-smaz_implementations-base_64_tools.ads ================================================================== --- src/natools-smaz_implementations-base_64_tools.ads +++ src/natools-smaz_implementations-base_64_tools.ads @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ --- Copyright (c) 2016, Natacha Porté -- +-- Copyright (c) 2016-2017, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- @@ -140,8 +140,13 @@ procedure Next_Digit (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Digit : out Base_64_Digit); + procedure Next_Digit_Or_End + (Input : in Ada.Streams.Stream_Element_Array; + Offset : in out Ada.Streams.Stream_Element_Offset; + Digit : out Base_64_Digit; + Finished : out Boolean); -- Look for the first valid symbol in Input from Offset, and decode it end Natools.Smaz_Implementations.Base_64_Tools;