Commit cf5028e3 by Robert Dewar Committed by Arnaud Charlet

g-comlin.adb: Minor reformatting

2008-08-20  Robert Dewar  <dewar@adacore.com>

	* g-comlin.adb: Minor reformatting

From-SVN: r139273
parent bb1b6ec8
......@@ -106,10 +106,12 @@ package body GNAT.Command_Line is
procedure Remove (Line : in out Argument_List_Access; Index : Integer);
-- Remove a specific element from Line
procedure Append
procedure Add
(Line : in out Argument_List_Access;
Str : String_Access);
-- Append a new element to Line
Str : String_Access;
Before : Boolean := False);
-- Add a new element to Line. If Before is True, the item is inserted at
-- the beginning.
function Can_Have_Parameter (S : String) return Boolean;
-- Tell if S can have a parameter.
......@@ -143,14 +145,14 @@ package body GNAT.Command_Line is
Result : Argument_List_Access;
Sections : Argument_List_Access;
Params : Argument_List_Access);
-- Group switches with common prefixes whenever possible.
-- Once they have been grouped, we also check items for possible aliasing
-- Group switches with common prefixes whenever possible. Once they have
-- been grouped, we also check items for possible aliasing.
procedure Alias_Switches
(Cmd : Command_Line;
Result : Argument_List_Access;
Params : Argument_List_Access);
-- When possible, replace or more switches by an alias, i.e. a shorter
-- When possible, replace one or more switches by an alias, i.e. a shorter
-- version.
function Looking_At
......@@ -1080,8 +1082,8 @@ package body GNAT.Command_Line is
Config := new Command_Line_Configuration_Record;
end if;
Append (Config.Aliases, new String'(Switch));
Append (Config.Expansions, new String'(Expanded));
Add (Config.Aliases, new String'(Switch));
Add (Config.Expansions, new String'(Expanded));
end Define_Alias;
-------------------
......@@ -1097,7 +1099,7 @@ package body GNAT.Command_Line is
Config := new Command_Line_Configuration_Record;
end if;
Append (Config.Prefixes, new String'(Prefix));
Add (Config.Prefixes, new String'(Prefix));
end Define_Prefix;
-------------------
......@@ -1113,7 +1115,7 @@ package body GNAT.Command_Line is
Config := new Command_Line_Configuration_Record;
end if;
Append (Config.Switches, new String'(Switch));
Add (Config.Switches, new String'(Switch));
end Define_Switch;
--------------------
......@@ -1129,7 +1131,7 @@ package body GNAT.Command_Line is
Config := new Command_Line_Configuration_Record;
end if;
Append (Config.Sections, new String'(Section));
Add (Config.Sections, new String'(Section));
end Define_Section;
------------------
......@@ -1576,12 +1578,14 @@ package body GNAT.Command_Line is
Switch : String;
Parameter : String := "";
Separator : Character := ' ';
Section : String := "")
Section : String := "";
Add_Before : Boolean := False)
is
Success : Boolean;
pragma Unreferenced (Success);
begin
Add_Switch (Cmd, Switch, Parameter, Separator, Section, Success);
Add_Switch
(Cmd, Switch, Parameter, Separator, Section, Add_Before, Success);
end Add_Switch;
----------------
......@@ -1594,6 +1598,7 @@ package body GNAT.Command_Line is
Parameter : String := "";
Separator : Character := ' ';
Section : String := "";
Add_Before : Boolean := False;
Success : out Boolean)
is
procedure Add_Simple_Switch (Simple : String; Param : String);
......@@ -1646,20 +1651,33 @@ package body GNAT.Command_Line is
end loop;
-- Inserting at least one switch
Success := True;
Append (Cmd.Expanded, new String'(Simple));
Add (Cmd.Expanded, new String'(Simple), Add_Before);
if Param /= "" then
Append (Cmd.Params, new String'(Separator & Param));
Add
(Cmd.Params,
new String'(Separator & Param),
Add_Before);
else
Append (Cmd.Params, null);
Add
(Cmd.Params,
null,
Add_Before);
end if;
if Section = "" then
Append (Cmd.Sections, null);
Add
(Cmd.Sections,
null,
Add_Before);
else
Append (Cmd.Sections, new String'(Section));
Add
(Cmd.Sections,
new String'(Section),
Add_Before);
end if;
end if;
end Add_Simple_Switch;
......@@ -1702,22 +1720,35 @@ package body GNAT.Command_Line is
-- Append --
------------
procedure Append
procedure Add
(Line : in out Argument_List_Access;
Str : String_Access)
Str : String_Access;
Before : Boolean := False)
is
Tmp : Argument_List_Access := Line;
begin
if Tmp /= null then
Line := new Argument_List (Tmp'First .. Tmp'Last + 1);
if Before then
Line (Tmp'First + 1 .. Tmp'Last + 1) := Tmp.all;
else
Line (Tmp'Range) := Tmp.all;
end if;
Unchecked_Free (Tmp);
else
Line := new Argument_List (1 .. 1);
end if;
if Before then
Line (Line'First) := Str;
else
Line (Line'Last) := Str;
end Append;
end if;
end Add;
-------------------
-- Remove_Switch --
......@@ -2126,7 +2157,7 @@ package body GNAT.Command_Line is
end loop;
if not Found then
Append (Sections_List, Sections (E));
Add (Sections_List, Sections (E));
end if;
end if;
end loop;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment