Natools

Check-in [0e2f32ef01]
Login
Overview
Comment:s_expressions-atom_buffers: fix stream read
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0e2f32ef014f259c3cc7c5c2e3c30695d9aef553
User & Date: nat on 2014-09-01 18:29:06
Other Links: manifest | tags
Context
2014-09-02
17:21
time_statistics: new parent package for time statistics gathering check-in: 13debf8a9e user: nat tags: trunk
2014-09-01
18:29
s_expressions-atom_buffers: fix stream read check-in: 0e2f32ef01 user: nat tags: trunk
2014-08-31
14:45
s_expressions-atom_buffers-tests: add a test for the new stream interface check-in: 3c45cf38af user: nat tags: trunk
Changes

Modified src/natools-s_expressions-atom_buffers.adb from [34dcf49f16] to [65ea325a50].

227
228
229
230
231
232
233



234
235
236



237
238
239
240
241
242
243
244
245

   overriding procedure Read
     (Buffer : in out Atom_Buffer;
      Item : out Ada.Streams.Stream_Element_Array;
      Last : out Ada.Streams.Stream_Element_Offset) is
   begin
      if Item'Length < Buffer.Used then



         Last := Item'Last;
         Item := Buffer.Ref.Query.Data.all (1 .. Item'Length);
         Buffer.Used := Buffer.Used - Item'Length;



      else
         Last := Item'First + Buffer.Used - 1;
         Item (Item'First .. Last)
           := Buffer.Ref.Query.Data.all (1 .. Buffer.Used);
         Buffer.Used := 0;
      end if;
   end Read;

end Natools.S_Expressions.Atom_Buffers;







>
>
>
|
|
|
>
>
>









227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251

   overriding procedure Read
     (Buffer : in out Atom_Buffer;
      Item : out Ada.Streams.Stream_Element_Array;
      Last : out Ada.Streams.Stream_Element_Offset) is
   begin
      if Item'Length < Buffer.Used then
         declare
            Mutator : constant Atom_Refs.Mutator := Buffer.Ref.Update;
         begin
            Last := Item'Last;
            Item := Mutator.Data.all (1 .. Item'Length);
            Buffer.Used := Buffer.Used - Item'Length;
            Mutator.Data.all (1 .. Buffer.Used) := Mutator.Data.all
              (Item'Length + 1 .. Item'Length + Buffer.Used);
         end;
      else
         Last := Item'First + Buffer.Used - 1;
         Item (Item'First .. Last)
           := Buffer.Ref.Query.Data.all (1 .. Buffer.Used);
         Buffer.Used := 0;
      end if;
   end Read;

end Natools.S_Expressions.Atom_Buffers;