Skip to content

Commit d567eea

Browse files
committed
strings.adb: fix Has_Prefix/Suffix for equal strings
"X" is a valid prefix/suffix substrings for the "X" string. Adjust Has_Prefix and Has_Suffix accordingly.
1 parent 1a5129b commit d567eea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/gnatcov/strings.adb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ package body Strings is
7777
function Has_Prefix (S : String; Prefix : String) return Boolean is
7878
Length : constant Integer := Prefix'Length;
7979
begin
80-
return S'Length > Length
80+
return S'Length >= Length
8181
and then S (S'First .. S'First + Length - 1) = Prefix;
8282
end Has_Prefix;
8383

@@ -88,7 +88,7 @@ package body Strings is
8888
function Has_Suffix (S : String; Suffix : String) return Boolean is
8989
Length : constant Integer := Suffix'Length;
9090
begin
91-
return S'Length > Length
91+
return S'Length >= Length
9292
and then S (S'Last - Length + 1 .. S'Last) = Suffix;
9393
end Has_Suffix;
9494

0 commit comments

Comments
 (0)