Skip to content
This repository was archived by the owner on May 22, 2023. It is now read-only.

Commit 0b05cfe

Browse files
committed
prove rom test parse procedure
ref #80
1 parent 1ab75d6 commit 0b05cfe

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Diff for: test/rom/component.adb

+14-5
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,34 @@ is
3232

3333
procedure Parse (Data : String)
3434
is
35-
Last : Positive := Data'Last;
35+
Last : Positive;
3636
begin
37+
if Data'Last not in Positive'Range then
38+
return;
39+
end if;
40+
Last := Data'Last;
3741
if not Componolit.Interfaces.Log.Initialized (Log) and then Data'Length > 1 then
3842
for I in Data'Range loop
39-
if Data (I) = ASCII.LF then
43+
if Data (I) = ASCII.LF and I > 1 then
4044
Last := I - 1;
4145
exit;
4246
end if;
4347
end loop;
4448
Componolit.Interfaces.Log.Client.Initialize (Log, C, Data (Data'First .. Last));
4549
if Componolit.Interfaces.Log.Initialized (Log) then
46-
Componolit.Interfaces.Log.Client.Info (Log, "Log session configured with label: "
47-
& Data (Data'First .. Last));
50+
if Last - Data'First > Componolit.Interfaces.Log.Maximum_Message_Length (Log) then
51+
Last := Data'First + Componolit.Interfaces.Log.Maximum_Message_Length (Log) - 1;
52+
end if;
53+
Componolit.Interfaces.Log.Client.Info (Log, "Log session configured with label: ");
54+
Componolit.Interfaces.Log.Client.Info (Log, Data (Data'First .. Last - 1));
4855
else
4956
Main.Vacate (C, Main.Failure);
5057
end if;
51-
else
58+
elsif Componolit.Interfaces.Log.Initialized (Log) then
5259
Componolit.Interfaces.Log.Client.Info (Log, "Rom changed, exiting...");
5360
Main.Vacate (C, Main.Success);
61+
else
62+
Main.Vacate (C, Main.Failure);
5463
end if;
5564
end Parse;
5665

0 commit comments

Comments
 (0)