Natools

Check-in [75f285cc82]
Login
Overview
Comment:chunked_strings: improive Find_Token implementation
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 75f285cc82a12de9e3eee9da65b4fd4d09c3d2f7
User & Date: nat on 2013-10-09 21:10:19
Other Links: manifest | tags
Context
2013-10-10
21:23
chunked_strings-tests-bugfixes: new test case exposing a bug check-in: 278fda3aa5 user: nat tags: trunk
2013-10-09
21:10
chunked_strings: improive Find_Token implementation check-in: 75f285cc82 user: nat tags: trunk
2013-10-08
21:21
string_slices: fix Is_Subrange so that any empty range is a subrange of any range check-in: 96a6d2d262 user: nat tags: trunk
Changes

Modified src/natools-chunked_strings.adb from [12439cabc9] to [dc49608feb].

1602
1603
1604
1605
1606
1607
1608
1609
1610
1611




1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1602
1603
1604
1605
1606
1607
1608



1609
1610
1611
1612
1613
1614











1615
1616
1617
1618
1619
1620
1621







-
-
-
+
+
+
+


-
-
-
-
-
-
-
-
-
-
-








   procedure Find_Token (Source : in     Chunked_String;
                         Set    : in     Maps.Character_Set;
                         Test   : in     Ada.Strings.Membership;
                         First  :    out Positive;
                         Last   :    out Natural)
   is
      function Invert (M : Ada.Strings.Membership)
         return Ada.Strings.Membership;
      pragma Inline (Invert);
      Invert : constant array (Ada.Strings.Membership)
        of Ada.Strings.Membership
        := (Ada.Strings.Inside  => Ada.Strings.Outside,
            Ada.Strings.Outside => Ada.Strings.Inside);

      N : Natural;

      function Invert (M : Ada.Strings.Membership)
         return Ada.Strings.Membership
      is
         use Ada.Strings;
      begin
         case M is
            when Inside  => return Outside;
            when Outside => return Inside;
         end case;
      end Invert;
   begin
      N := Index (Source, Set, Test);

      if N = 0 then
         First := 1;
         Last := 0;
      else

Modified tests/natools-chunked_strings-tests-coverage.adb from [500a15f162] to [f1215135e1].

380
381
382
383
384
385
386
387

388
389
390
391
392
393
394
380
381
382
383
384
385
386

387
388
389
390
391
392
393
394







-
+







         NT.Item (Report, Name, NT.Success);
      end if;
   exception
      when Error : others => NT.Report_Exception (Report, Name, Error);
   end;

   declare
      Name : constant String := "Function Find_Token at string end";
      Name : constant String := "Procedure Find_Token at string end";
      CS : constant Chunked_String := To_Chunked_String ("--end");
      First : Positive;
      Last : Natural;
   begin
      Find_Token
        (Source => CS,
         Set => Maps.To_Set ("abcdefghijklmnopqrst"),