lace.text.cursor: Fix bug in the 'peek' function.
This commit is contained in:
@@ -141,28 +141,36 @@ is
|
|||||||
end if;
|
end if;
|
||||||
|
|
||||||
declare
|
declare
|
||||||
use ada.Strings.fixed,
|
function get_String return String
|
||||||
ada.Strings.Maps.Constants;
|
is
|
||||||
delimiter_Position : constant Natural := (if match_Case then Index (Self.Target.Data (Self.Current .. Self.Target.Length), Delimiter, from => Self.Current)
|
use ada.Strings.fixed,
|
||||||
else Index (Self.Target.Data (Self.Current .. Self.Target.Length), to_Lower (Delimiter), from => Self.Current,
|
ada.Strings.Maps.Constants;
|
||||||
mapping => lower_case_Map));
|
delimiter_Position : constant Natural := (if match_Case then Index (Self.Target.Data (Self.Current .. Self.Target.Length), Delimiter, from => Self.Current)
|
||||||
begin
|
else Index (Self.Target.Data (Self.Current .. Self.Target.Length), to_Lower (Delimiter), from => Self.Current,
|
||||||
-- put_Line ("delimiter_Position" & delimiter_Position'Image);
|
mapping => lower_case_Map));
|
||||||
|
begin
|
||||||
|
if delimiter_Position = 0
|
||||||
|
then
|
||||||
|
return the_Token : constant String := (if Trim then fixed.Trim (Self.Target.Data (Self.Current .. Self.Target.Length), Both)
|
||||||
|
else Self.Target.Data (Self.Current .. Self.Target.Length))
|
||||||
|
do
|
||||||
|
Self.Current := 0;
|
||||||
|
end return;
|
||||||
|
end if;
|
||||||
|
|
||||||
if delimiter_Position = 0
|
return the_Token : constant String := (if Trim then fixed.Trim (Self.Target.Data (Self.Current .. delimiter_Position - 1), Both)
|
||||||
then
|
else Self.Target.Data (Self.Current .. delimiter_Position - 1))
|
||||||
return the_Token : constant String := (if Trim then fixed.Trim (Self.Target.Data (Self.Current .. Self.Target.Length), Both)
|
|
||||||
else Self.Target.Data (Self.Current .. Self.Target.Length))
|
|
||||||
do
|
do
|
||||||
Self.Current := 0;
|
Self.Current := delimiter_Position + Delimiter'Length;
|
||||||
end return;
|
end return;
|
||||||
end if;
|
end get_String;
|
||||||
|
|
||||||
return the_Token : constant String := (if Trim then fixed.Trim (Self.Target.Data (Self.Current .. delimiter_Position - 1), Both)
|
|
||||||
else Self.Target.Data (Self.Current .. delimiter_Position - 1))
|
unslid_String : constant String := get_String;
|
||||||
do
|
slid_String : constant String (1 .. unslid_String'Length) := unslid_String;
|
||||||
Self.Current := delimiter_Position + Delimiter'Length;
|
|
||||||
end return;
|
begin
|
||||||
|
return slid_String;
|
||||||
end;
|
end;
|
||||||
end next_Token;
|
end next_Token;
|
||||||
|
|
||||||
@@ -258,6 +266,7 @@ is
|
|||||||
end get_Real;
|
end get_Real;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Length (Self : in Item) return Natural
|
function Length (Self : in Item) return Natural
|
||||||
is
|
is
|
||||||
begin
|
begin
|
||||||
@@ -268,14 +277,17 @@ is
|
|||||||
|
|
||||||
function peek (Self : in Item; Length : in Natural := Remaining) return String
|
function peek (Self : in Item; Length : in Natural := Remaining) return String
|
||||||
is
|
is
|
||||||
Last : constant Natural := (if Length = Natural'Last then Self.Target.Length
|
Last : Natural := (if Length = Remaining then Self.Target.Length
|
||||||
else Self.Current + Length - 1);
|
else Self.Current + Length - 1);
|
||||||
begin
|
begin
|
||||||
if at_End (Self)
|
if at_End (Self)
|
||||||
then
|
then
|
||||||
return "";
|
return "";
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
Last := Natural'Min (Last,
|
||||||
|
Self.Target.Length);
|
||||||
|
|
||||||
return Self.Target.Data (Self.Current .. Last);
|
return Self.Target.Data (Self.Current .. Last);
|
||||||
end peek;
|
end peek;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user