Natools

Check-in [1f3ace98c0]
Login
Overview
Comment:smaz: fix off-by-one error in Verbatim_Size
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1f3ace98c05e73220278c47a9a4b73566c2c5362
User & Date: nat on 2017-02-17 21:33:03
Other Links: manifest | tags
Context
2017-02-18
22:14
smaz_tests: rename base-256 sample string test for consistency check-in: beb52edfa5 user: nat tags: trunk
2017-02-17
21:33
smaz: fix off-by-one error in Verbatim_Size check-in: 1f3ace98c0 user: nat tags: trunk
2017-02-16
20:56
smaz-tests: add sample strings without variable-length verbatim check-in: f1bcc5d576 user: nat tags: trunk
Changes

Modified src/natools-smaz.adb from [85362c90bf] to [4194423a31].

1
2

3
4
5
6
7
8
9
1

2
3
4
5
6
7
8
9

-
+







------------------------------------------------------------------------------
-- 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.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
109
110
111
112
113
114
115
116
117


118
119

120
121
122
123
124
125
126
109
110
111
112
113
114
115


116
117
118

119
120
121
122
123
124
125
126







-
-
+
+

-
+







         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;
         Block_Count : constant Ada.Streams.Stream_Element_Count
           := (Remaining + Verbatim1_Max_Size - 1) / Verbatim1_Max_Size;
      begin
         Overhead := Overhead + Full_Blocks;
         Overhead := Overhead + Block_Count;
      end;

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