Natools

Check-in [1183e8ca09]
Login
Overview
Comment:smaz_implementations-base_256: fix off-by-one error in Verbatim_Size
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1183e8ca098d7259b99beba15900d833babf7294
User & Date: nat on 2017-02-20 20:16:30
Other Links: manifest | tags
Context
2017-02-21
21:11
smaz_implementations-base_256: fix exception on 1-byte non-VLV blocks check-in: baef3cc8be user: nat tags: trunk
2017-02-20
20:16
smaz_implementations-base_256: fix off-by-one error in Verbatim_Size check-in: 1183e8ca09 user: nat tags: trunk
2017-02-19
21:06
smaz_tests: copy base-256 non-VLV tests from retired smaz test suite check-in: d389660384 user: nat tags: trunk
Changes

Modified src/natools-smaz_implementations-base_256.adb from [aae2e3da04] to [2ae576e7b5].

1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- Copyright (c) 2016, 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.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --

|







1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- 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.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
         if Remaining > Verbatim1_Max_Size then
            Overhead := Overhead + 2;
            Remaining := 0;
         end if;
      end if;

      declare
         Full_Blocks : constant Ada.Streams.Stream_Element_Count
           := Remaining / Verbatim1_Max_Size;
      begin
         Overhead := Overhead + Full_Blocks;
      end;

      return Overhead + Ada.Streams.Stream_Element_Count (Input_Length);
   end Verbatim_Size;


   procedure Write_Code







|
|

|







110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
         if Remaining > Verbatim1_Max_Size then
            Overhead := Overhead + 2;
            Remaining := 0;
         end if;
      end if;

      declare
         Block_Count : constant Ada.Streams.Stream_Element_Count
           := (Remaining + Verbatim1_Max_Size - 1) / Verbatim1_Max_Size;
      begin
         Overhead := Overhead + Block_Count;
      end;

      return Overhead + Ada.Streams.Stream_Element_Count (Input_Length);
   end Verbatim_Size;


   procedure Write_Code