Natools

Check-in [96a6d2d262]
Login
Overview
Comment:string_slices: fix Is_Subrange so that any empty range is a subrange of any range
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 96a6d2d26216d6f6a09ae267f33e36f5fe303f34
User & Date: nat on 2013-10-08 21:21:14
Other Links: manifest | tags
Context
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
2013-10-07
19:12
string_slice_set_tests: add conversion and interval tests check-in: 1bd9bb5772 user: nat tags: trunk
Changes

Modified src/natools-string_slices.adb from [4b6fed0e78] to [c5e18cd3df].

28
29
30
31
32
33
34

35
36
37
38
39
40
41
42
43
44
      return Point >= Reference.First
        and Point < Reference.First + Reference.Length;
   end Is_In;


   function Is_Subrange (Sample, Reference : String_Range) return Boolean is
   begin

      return Sample.First >= Reference.First
        and then Sample.First + Sample.Length
                   <= Reference.First + Reference.Length;
   end Is_Subrange;


   function Last (Self : String_Range) return Natural is
   begin
      return Self.First + Self.Length - 1;
   end Last;







>
|
|
|







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
      return Point >= Reference.First
        and Point < Reference.First + Reference.Length;
   end Is_In;


   function Is_Subrange (Sample, Reference : String_Range) return Boolean is
   begin
      return Sample.Length = 0
        or else (Sample.First >= Reference.First
                 and then Sample.First + Sample.Length
                            <= Reference.First + Reference.Length);
   end Is_Subrange;


   function Last (Self : String_Range) return Natural is
   begin
      return Self.First + Self.Length - 1;
   end Last;