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 ...@@ -106,10 +106,12 @@ package body GNAT.Command_Line is
procedure Remove (Line : in out Argument_List_Access; Index : Integer); procedure Remove (Line : in out Argument_List_Access; Index : Integer);
-- Remove a specific element from Line -- Remove a specific element from Line
procedure Append procedure Add
(Line : in out Argument_List_Access; (Line : in out Argument_List_Access;
Str : String_Access); Str : String_Access;
-- Append a new element to Line 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; function Can_Have_Parameter (S : String) return Boolean;
-- Tell if S can have a parameter. -- Tell if S can have a parameter.
...@@ -143,14 +145,14 @@ package body GNAT.Command_Line is ...@@ -143,14 +145,14 @@ package body GNAT.Command_Line is
Result : Argument_List_Access; Result : Argument_List_Access;
Sections : Argument_List_Access; Sections : Argument_List_Access;
Params : Argument_List_Access); Params : Argument_List_Access);
-- Group switches with common prefixes whenever possible. -- Group switches with common prefixes whenever possible. Once they have
-- Once they have been grouped, we also check items for possible aliasing -- been grouped, we also check items for possible aliasing.
procedure Alias_Switches procedure Alias_Switches
(Cmd : Command_Line; (Cmd : Command_Line;
Result : Argument_List_Access; Result : Argument_List_Access;
Params : 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. -- version.
function Looking_At function Looking_At
...@@ -1080,8 +1082,8 @@ package body GNAT.Command_Line is ...@@ -1080,8 +1082,8 @@ package body GNAT.Command_Line is
Config := new Command_Line_Configuration_Record; Config := new Command_Line_Configuration_Record;
end if; end if;
Append (Config.Aliases, new String'(Switch)); Add (Config.Aliases, new String'(Switch));
Append (Config.Expansions, new String'(Expanded)); Add (Config.Expansions, new String'(Expanded));
end Define_Alias; end Define_Alias;
------------------- -------------------
...@@ -1097,7 +1099,7 @@ package body GNAT.Command_Line is ...@@ -1097,7 +1099,7 @@ package body GNAT.Command_Line is
Config := new Command_Line_Configuration_Record; Config := new Command_Line_Configuration_Record;
end if; end if;
Append (Config.Prefixes, new String'(Prefix)); Add (Config.Prefixes, new String'(Prefix));
end Define_Prefix; end Define_Prefix;
------------------- -------------------
...@@ -1113,7 +1115,7 @@ package body GNAT.Command_Line is ...@@ -1113,7 +1115,7 @@ package body GNAT.Command_Line is
Config := new Command_Line_Configuration_Record; Config := new Command_Line_Configuration_Record;
end if; end if;
Append (Config.Switches, new String'(Switch)); Add (Config.Switches, new String'(Switch));
end Define_Switch; end Define_Switch;
-------------------- --------------------
...@@ -1129,7 +1131,7 @@ package body GNAT.Command_Line is ...@@ -1129,7 +1131,7 @@ package body GNAT.Command_Line is
Config := new Command_Line_Configuration_Record; Config := new Command_Line_Configuration_Record;
end if; end if;
Append (Config.Sections, new String'(Section)); Add (Config.Sections, new String'(Section));
end Define_Section; end Define_Section;
------------------ ------------------
...@@ -1576,12 +1578,14 @@ package body GNAT.Command_Line is ...@@ -1576,12 +1578,14 @@ package body GNAT.Command_Line is
Switch : String; Switch : String;
Parameter : String := ""; Parameter : String := "";
Separator : Character := ' '; Separator : Character := ' ';
Section : String := "") Section : String := "";
Add_Before : Boolean := False)
is is
Success : Boolean; Success : Boolean;
pragma Unreferenced (Success); pragma Unreferenced (Success);
begin begin
Add_Switch (Cmd, Switch, Parameter, Separator, Section, Success); Add_Switch
(Cmd, Switch, Parameter, Separator, Section, Add_Before, Success);
end Add_Switch; end Add_Switch;
---------------- ----------------
...@@ -1594,6 +1598,7 @@ package body GNAT.Command_Line is ...@@ -1594,6 +1598,7 @@ package body GNAT.Command_Line is
Parameter : String := ""; Parameter : String := "";
Separator : Character := ' '; Separator : Character := ' ';
Section : String := ""; Section : String := "";
Add_Before : Boolean := False;
Success : out Boolean) Success : out Boolean)
is is
procedure Add_Simple_Switch (Simple : String; Param : String); procedure Add_Simple_Switch (Simple : String; Param : String);
...@@ -1646,20 +1651,33 @@ package body GNAT.Command_Line is ...@@ -1646,20 +1651,33 @@ package body GNAT.Command_Line is
end loop; end loop;
-- Inserting at least one switch -- Inserting at least one switch
Success := True; Success := True;
Append (Cmd.Expanded, new String'(Simple)); Add (Cmd.Expanded, new String'(Simple), Add_Before);
if Param /= "" then if Param /= "" then
Append (Cmd.Params, new String'(Separator & Param)); Add
(Cmd.Params,
new String'(Separator & Param),
Add_Before);
else else
Append (Cmd.Params, null); Add
(Cmd.Params,
null,
Add_Before);
end if; end if;
if Section = "" then if Section = "" then
Append (Cmd.Sections, null); Add
(Cmd.Sections,
null,
Add_Before);
else else
Append (Cmd.Sections, new String'(Section)); Add
(Cmd.Sections,
new String'(Section),
Add_Before);
end if; end if;
end if; end if;
end Add_Simple_Switch; end Add_Simple_Switch;
...@@ -1702,22 +1720,35 @@ package body GNAT.Command_Line is ...@@ -1702,22 +1720,35 @@ package body GNAT.Command_Line is
-- Append -- -- Append --
------------ ------------
procedure Append procedure Add
(Line : in out Argument_List_Access; (Line : in out Argument_List_Access;
Str : String_Access) Str : String_Access;
Before : Boolean := False)
is is
Tmp : Argument_List_Access := Line; Tmp : Argument_List_Access := Line;
begin begin
if Tmp /= null then if Tmp /= null then
Line := new Argument_List (Tmp'First .. Tmp'Last + 1); 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; Line (Tmp'Range) := Tmp.all;
end if;
Unchecked_Free (Tmp); Unchecked_Free (Tmp);
else else
Line := new Argument_List (1 .. 1); Line := new Argument_List (1 .. 1);
end if; end if;
if Before then
Line (Line'First) := Str;
else
Line (Line'Last) := Str; Line (Line'Last) := Str;
end Append; end if;
end Add;
------------------- -------------------
-- Remove_Switch -- -- Remove_Switch --
...@@ -2126,7 +2157,7 @@ package body GNAT.Command_Line is ...@@ -2126,7 +2157,7 @@ package body GNAT.Command_Line is
end loop; end loop;
if not Found then if not Found then
Append (Sections_List, Sections (E)); Add (Sections_List, Sections (E));
end if; end if;
end if; end if;
end loop; 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