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.
...@@ -125,7 +127,7 @@ package body GNAT.Command_Line is ...@@ -125,7 +127,7 @@ package body GNAT.Command_Line is
procedure For_Each_Simple_Switch procedure For_Each_Simple_Switch
(Cmd : Command_Line; (Cmd : Command_Line;
Switch : String; Switch : String;
Parameter : String := ""; Parameter : String := "";
Unalias : Boolean := True); Unalias : Boolean := True);
-- Breaks Switch into as simple switches as possible (expanding aliases and -- Breaks Switch into as simple switches as possible (expanding aliases and
-- ungrouping common prefixes when possible), and call Callback for each of -- ungrouping common prefixes when possible), and call Callback for each of
...@@ -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;
------------------ ------------------
...@@ -1572,16 +1574,18 @@ package body GNAT.Command_Line is ...@@ -1572,16 +1574,18 @@ package body GNAT.Command_Line is
---------------- ----------------
procedure Add_Switch procedure Add_Switch
(Cmd : in out Command_Line; (Cmd : in out Command_Line;
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;
---------------- ----------------
...@@ -1589,12 +1593,13 @@ package body GNAT.Command_Line is ...@@ -1589,12 +1593,13 @@ package body GNAT.Command_Line is
---------------- ----------------
procedure Add_Switch procedure Add_Switch
(Cmd : in out Command_Line; (Cmd : in out Command_Line;
Switch : String; Switch : String;
Parameter : String := ""; Parameter : String := "";
Separator : Character := ' '; Separator : Character := ' ';
Section : String := ""; Section : String := "";
Success : out Boolean) Add_Before : Boolean := False;
Success : out Boolean)
is is
procedure Add_Simple_Switch (Simple : String; Param : String); procedure Add_Simple_Switch (Simple : String; Param : String);
-- Add a new switch that has had all its aliases expanded, and switches -- Add a new switch that has had all its aliases expanded, and switches
...@@ -1632,34 +1637,47 @@ package body GNAT.Command_Line is ...@@ -1632,34 +1637,47 @@ package body GNAT.Command_Line is
if Cmd.Expanded (C).all = Simple if Cmd.Expanded (C).all = Simple
and then and then
((Cmd.Params (C) = null and then Param = "") ((Cmd.Params (C) = null and then Param = "")
or else or else
(Cmd.Params (C) /= null (Cmd.Params (C) /= null
and then Cmd.Params (C).all = Separator & Param)) and then Cmd.Params (C).all = Separator & Param))
and then and then
((Cmd.Sections (C) = null and then Section = "") ((Cmd.Sections (C) = null and then Section = "")
or else or else
(Cmd.Sections (C) /= null (Cmd.Sections (C) /= null
and then Cmd.Sections (C).all = Section)) and then Cmd.Sections (C).all = Section))
then then
return; return;
end if; end if;
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);
Line (Tmp'Range) := Tmp.all;
if Before then
Line (Tmp'First + 1 .. Tmp'Last + 1) := Tmp.all;
else
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;
Line (Line'Last) := Str; if Before then
end Append; Line (Line'First) := Str;
else
Line (Line'Last) := Str;
end if;
end Add;
------------------- -------------------
-- Remove_Switch -- -- Remove_Switch --
...@@ -1766,10 +1797,10 @@ package body GNAT.Command_Line is ...@@ -1766,10 +1797,10 @@ package body GNAT.Command_Line is
if Cmd.Expanded (C).all = Simple if Cmd.Expanded (C).all = Simple
and then and then
(Remove_All (Remove_All
or else (Cmd.Sections (C) = null or else (Cmd.Sections (C) = null
and then Section = "") and then Section = "")
or else (Cmd.Sections (C) /= null or else (Cmd.Sections (C) /= null
and then Section = Cmd.Sections (C).all)) and then Section = Cmd.Sections (C).all))
and then (not Has_Parameter or else Cmd.Params (C) /= null) and then (not Has_Parameter or else Cmd.Params (C) /= null)
then then
Remove (Cmd.Expanded, C); Remove (Cmd.Expanded, C);
...@@ -1789,7 +1820,7 @@ package body GNAT.Command_Line is ...@@ -1789,7 +1820,7 @@ package body GNAT.Command_Line is
end Remove_Simple_Switch; end Remove_Simple_Switch;
procedure Remove_Simple_Switches is procedure Remove_Simple_Switches is
new For_Each_Simple_Switch (Remove_Simple_Switch); new For_Each_Simple_Switch (Remove_Simple_Switch);
-- Start of processing for Remove_Switch -- Start of processing for Remove_Switch
...@@ -1826,10 +1857,10 @@ package body GNAT.Command_Line is ...@@ -1826,10 +1857,10 @@ package body GNAT.Command_Line is
if Cmd.Expanded (C).all = Simple if Cmd.Expanded (C).all = Simple
and then and then
((Cmd.Sections (C) = null ((Cmd.Sections (C) = null
and then Section = "") and then Section = "")
or else or else
(Cmd.Sections (C) /= null (Cmd.Sections (C) /= null
and then Section = Cmd.Sections (C).all)) and then Section = Cmd.Sections (C).all))
and then and then
((Cmd.Params (C) = null and then Param = "") ((Cmd.Params (C) = null and then Param = "")
or else or else
...@@ -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