Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,18 +0,0 @@
|
|||
generic
|
||||
with procedure Put_Line(Line: String);
|
||||
package Word_Wrap is
|
||||
|
||||
type Basic(Length_Of_Output_Line: Positive) is tagged private;
|
||||
|
||||
procedure Push_Word(State: in out Basic; Word: String);
|
||||
procedure New_Paragraph(State: in out Basic);
|
||||
procedure Finish(State: in out Basic);
|
||||
|
||||
private
|
||||
type Basic(Length_Of_Output_Line: Positive) is tagged record
|
||||
Line: String(1 .. Length_Of_Output_Line);
|
||||
Size: Natural := 0; -- Line(1 .. Size) is relevant
|
||||
Top_Of_Paragraph: Boolean := True;
|
||||
end record;
|
||||
|
||||
end Word_Wrap;
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
package body Word_Wrap is
|
||||
|
||||
procedure Push_Word(State: in out Basic; Word: String) is
|
||||
begin
|
||||
if Word'Length + State.Size >= State.Length_Of_Output_Line then
|
||||
Put_Line(State.Line(1 .. State.Size));
|
||||
State.Line(1 .. Word'Length) := Word; -- may raise CE if Word too long
|
||||
State.Size := Word'Length;
|
||||
elsif State.Size > 0 then
|
||||
State.Line(State.Size+1 .. State.Size+1+Word'Length) := ' ' & Word;
|
||||
State.Size := State.Size + 1 + Word'Length;
|
||||
else
|
||||
State.Line(1 .. Word'Length) := Word;
|
||||
State.Size := Word'Length;
|
||||
end if;
|
||||
State.Top_Of_Paragraph := False;
|
||||
end Push_Word;
|
||||
|
||||
procedure New_Paragraph(State: in out Basic) is
|
||||
begin
|
||||
Finish(State);
|
||||
if not State.Top_Of_Paragraph then
|
||||
Put_Line("");
|
||||
State.Top_Of_Paragraph := True;
|
||||
end if;
|
||||
end New_Paragraph;
|
||||
|
||||
procedure Finish(State: in out Basic) is
|
||||
begin
|
||||
if State.Size > 0 then
|
||||
Put_Line(State.Line(1 .. State.Size));
|
||||
State.Size := 0;
|
||||
end if;
|
||||
end Finish;
|
||||
|
||||
end Word_Wrap;
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
with Ada.Text_IO, Word_Wrap, Ada.Strings.Unbounded, Ada.Command_Line;
|
||||
|
||||
procedure Wrap is
|
||||
|
||||
use Ada.Strings.Unbounded;
|
||||
|
||||
Line: Unbounded_String;
|
||||
Word: Unbounded_String;
|
||||
|
||||
function "+"(S: String) return Unbounded_String renames To_Unbounded_String;
|
||||
function "-"(U: Unbounded_String) return String renames To_String;
|
||||
|
||||
package IO renames Ada.Text_IO;
|
||||
|
||||
procedure Split(S: Unbounded_String; First, Rest: out Unbounded_String) is
|
||||
|
||||
function Skip_Leading_Spaces(S: String) return String is
|
||||
begin
|
||||
if S="" then return "";
|
||||
elsif S(S'First) = ' ' then return S(S'First+1 .. S'Last);
|
||||
else return S;
|
||||
end if;
|
||||
end Skip_Leading_Spaces;
|
||||
|
||||
Str: String := Skip_Leading_Spaces(-S);
|
||||
I: Positive := Str'First;
|
||||
J: Natural;
|
||||
begin
|
||||
-- read nonspaces for First output param
|
||||
J := I-1;
|
||||
while J < Str'Last and then Str(J+1) /= ' ' loop
|
||||
J := J + 1;
|
||||
end loop;
|
||||
First := + Str(I .. J);
|
||||
|
||||
-- write output param Rest
|
||||
Rest := + Skip_Leading_Spaces(Str(J+1 .. Str'Last));
|
||||
end Split;
|
||||
|
||||
procedure Print(S: String) is
|
||||
begin
|
||||
IO.Put_Line(S);
|
||||
end Print;
|
||||
|
||||
package WW is new Word_Wrap(Print);
|
||||
|
||||
Wrapper: WW.Basic(Integer'Value(Ada.Command_Line.Argument(1)));
|
||||
|
||||
begin
|
||||
while not IO.End_Of_File loop
|
||||
Line := +IO.Get_Line;
|
||||
if Line = +"" then
|
||||
Wrapper.New_Paragraph;
|
||||
Line := +IO.Get_Line;
|
||||
end if;
|
||||
while Line /= +"" loop
|
||||
Split(Line, First => Word, Rest => Line);
|
||||
Wrapper.Push_Word(-Word);
|
||||
end loop;
|
||||
end loop;
|
||||
Wrapper.Finish;
|
||||
end Wrap;
|
||||
Loading…
Add table
Add a link
Reference in a new issue