Commit c18b3a99 by Jerome Lambourg Committed by Arnaud Charlet

g-comlin.adb (Group_Switches): Preserve the switch order when grouping and allow…

g-comlin.adb (Group_Switches): Preserve the switch order when grouping and allow switch grouping of switches...

2008-08-04  Jerome Lambourg  <lambourg@adacore.com>

	* g-comlin.adb (Group_Switches): Preserve the switch order when
	grouping and allow switch grouping of switches with more than one
	character extension (e.g. gnatw.x).
	(Args_From_Expanded): Remove this now obsolete method.

From-SVN: r138596
parent d5d33d09
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation; with Ada.Unchecked_Deallocation;
with Ada.Strings.Unbounded;
with GNAT.OS_Lib; use GNAT.OS_Lib; with GNAT.OS_Lib; use GNAT.OS_Lib;
package body GNAT.Command_Line is package body GNAT.Command_Line is
...@@ -101,8 +102,6 @@ package body GNAT.Command_Line is ...@@ -101,8 +102,6 @@ package body GNAT.Command_Line is
procedure Unchecked_Free is new Ada.Unchecked_Deallocation procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Command_Line_Configuration_Record, Command_Line_Configuration); (Command_Line_Configuration_Record, Command_Line_Configuration);
type Boolean_Chars is array (Character) of Boolean;
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
...@@ -111,9 +110,6 @@ package body GNAT.Command_Line is ...@@ -111,9 +110,6 @@ package body GNAT.Command_Line is
Str : String_Access); Str : String_Access);
-- Append a new element to Line -- Append a new element to Line
function Args_From_Expanded (Args : Boolean_Chars) return String;
-- Return the string made of all characters with True in Args
generic generic
with procedure Callback (Simple_Switch : String); with procedure Callback (Simple_Switch : String);
procedure For_Each_Simple_Switch procedure For_Each_Simple_Switch
...@@ -1050,25 +1046,6 @@ package body GNAT.Command_Line is ...@@ -1050,25 +1046,6 @@ package body GNAT.Command_Line is
end if; end if;
end Free; end Free;
------------------------
-- Args_From_Expanded --
------------------------
function Args_From_Expanded (Args : Boolean_Chars) return String is
Result : String (1 .. Args'Length);
Index : Natural := Result'First;
begin
for A in Args'Range loop
if Args (A) then
Result (Index) := A;
Index := Index + 1;
end if;
end loop;
return Result (1 .. Index - 1);
end Args_From_Expanded;
------------------ ------------------
-- Define_Alias -- -- Define_Alias --
------------------ ------------------
...@@ -1470,12 +1447,9 @@ package body GNAT.Command_Line is ...@@ -1470,12 +1447,9 @@ package body GNAT.Command_Line is
Result : Argument_List_Access; Result : Argument_List_Access;
Params : Argument_List_Access) Params : Argument_List_Access)
is is
type Boolean_Array is array (Result'Range) of Boolean; Group : Ada.Strings.Unbounded.Unbounded_String;
Matched : Boolean_Array;
Count : Natural;
First : Natural; First : Natural;
From_Args : Boolean_Chars; use type Ada.Strings.Unbounded.Unbounded_String;
begin begin
if Cmd.Config = null if Cmd.Config = null
...@@ -1485,8 +1459,8 @@ package body GNAT.Command_Line is ...@@ -1485,8 +1459,8 @@ package body GNAT.Command_Line is
end if; end if;
for P in Cmd.Config.Prefixes'Range loop for P in Cmd.Config.Prefixes'Range loop
Matched := (others => False); Group := Ada.Strings.Unbounded.Null_Unbounded_String;
Count := 0; First := 0;
for C in Result'Range loop for C in Result'Range loop
if Result (C) /= null if Result (C) /= null
...@@ -1494,32 +1468,22 @@ package body GNAT.Command_Line is ...@@ -1494,32 +1468,22 @@ package body GNAT.Command_Line is
and then Looking_At and then Looking_At
(Result (C).all, Result (C)'First, Cmd.Config.Prefixes (P).all) (Result (C).all, Result (C)'First, Cmd.Config.Prefixes (P).all)
then then
Matched (C) := True; Group := Group &
Count := Count + 1; Result (C)
end if; (Result (C)'First + Cmd.Config.Prefixes (P)'Length ..
end loop; Result (C)'Last);
if Count > 1 then
From_Args := (others => False);
First := 0;
for M in Matched'Range loop
if Matched (M) then
if First = 0 then if First = 0 then
First := M; First := C;
end if; end if;
for A in Result (M)'First + Cmd.Config.Prefixes (P)'Length Free (Result (C));
.. Result (M)'Last
loop
From_Args (Result (M)(A)) := True;
end loop;
Free (Result (M));
end if; end if;
end loop; end loop;
if First > 0 then
Result (First) := new String' Result (First) := new String'
(Cmd.Config.Prefixes (P).all & Args_From_Expanded (From_Args)); (Cmd.Config.Prefixes (P).all &
Ada.Strings.Unbounded.To_String (Group));
end if; end if;
end loop; end loop;
end Group_Switches; end Group_Switches;
......
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