Skip to content

Commit

Permalink
asdanag: scans: GetLine
Browse files Browse the repository at this point in the history
  • Loading branch information
mkf committed Jan 6, 2020
1 parent 8455685 commit 1e7b321
Showing 1 changed file with 1 addition and 34 deletions.
35 changes: 1 addition & 34 deletions src/asdanag.adb
Original file line number Diff line number Diff line change
Expand Up @@ -75,41 +75,8 @@ procedure Asdanag is
InputTooLarge : exception;

procedure scans (w : two_t) is
fin : Boolean := False;
i : index_t := 1;
begin
charseq:
loop
if i = index_t'Last then
raise InputTooLarge with Standard.String(s(w));
end if;
declare
c : Character;
begin
if i = 1 then
loop
Ada.Text_IO.Get_Immediate(c);
exit when c /= Ada.Characters.Latin_1.LF;
end loop;
end if;
fin := fin or (c = Ada.Characters.Latin_1.LF);
exit charseq when fin;
s (w) (i) := c;
i := i + 1;
exception
when Ada.Text_IO.End_Error =>
if i = 1 then
raise;
else
fin := True;
end if;
end;
exit when fin;
end loop charseq;
returning :
begin
lens (w) := i - 1;
end returning;
Ada.Text_IO.Get_Line(String(s(w)), Integer(lens(w)));
end scans;

begin
Expand Down

0 comments on commit 1e7b321

Please sign in to comment.