summaryrefslogtreecommitdiff
path: root/gcc/ada/g-comlin.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2008-08-04 09:49:33 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2008-08-04 09:49:33 +0000
commitfe8546504f2fc67065998e5ab0f99e12fe91220a (patch)
tree322b8d7b25962293d192473481e0357708e14a7f /gcc/ada/g-comlin.adb
parent5e640318a2c8c8e86d722e27683ad9cfac60348b (diff)
downloadgcc-fe8546504f2fc67065998e5ab0f99e12fe91220a.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138596 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/g-comlin.adb')
-rw-r--r--gcc/ada/g-comlin.adb72
1 files changed, 18 insertions, 54 deletions
diff --git a/gcc/ada/g-comlin.adb b/gcc/ada/g-comlin.adb
index c9cb4dbad25..195e63026ae 100644
--- a/gcc/ada/g-comlin.adb
+++ b/gcc/ada/g-comlin.adb
@@ -32,7 +32,8 @@
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
-with GNAT.OS_Lib; use GNAT.OS_Lib;
+with Ada.Strings.Unbounded;
+with GNAT.OS_Lib; use GNAT.OS_Lib;
package body GNAT.Command_Line is
@@ -101,8 +102,6 @@ package body GNAT.Command_Line is
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(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);
-- Remove a specific element from Line
@@ -111,9 +110,6 @@ package body GNAT.Command_Line is
Str : String_Access);
-- 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
with procedure Callback (Simple_Switch : String);
procedure For_Each_Simple_Switch
@@ -1050,25 +1046,6 @@ package body GNAT.Command_Line is
end if;
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 --
------------------
@@ -1470,12 +1447,9 @@ package body GNAT.Command_Line is
Result : Argument_List_Access;
Params : Argument_List_Access)
is
- type Boolean_Array is array (Result'Range) of Boolean;
-
- Matched : Boolean_Array;
- Count : Natural;
+ Group : Ada.Strings.Unbounded.Unbounded_String;
First : Natural;
- From_Args : Boolean_Chars;
+ use type Ada.Strings.Unbounded.Unbounded_String;
begin
if Cmd.Config = null
@@ -1485,8 +1459,8 @@ package body GNAT.Command_Line is
end if;
for P in Cmd.Config.Prefixes'Range loop
- Matched := (others => False);
- Count := 0;
+ Group := Ada.Strings.Unbounded.Null_Unbounded_String;
+ First := 0;
for C in Result'Range loop
if Result (C) /= null
@@ -1494,32 +1468,22 @@ package body GNAT.Command_Line is
and then Looking_At
(Result (C).all, Result (C)'First, Cmd.Config.Prefixes (P).all)
then
- Matched (C) := True;
- Count := Count + 1;
+ Group := Group &
+ Result (C)
+ (Result (C)'First + Cmd.Config.Prefixes (P)'Length ..
+ Result (C)'Last);
+ if First = 0 then
+ First := C;
+ end if;
+
+ Free (Result (C));
end if;
end loop;
- if Count > 1 then
- From_Args := (others => False);
- First := 0;
-
- for M in Matched'Range loop
- if Matched (M) then
- if First = 0 then
- First := M;
- end if;
-
- for A in Result (M)'First + Cmd.Config.Prefixes (P)'Length
- .. Result (M)'Last
- loop
- From_Args (Result (M)(A)) := True;
- end loop;
- Free (Result (M));
- end if;
- end loop;
-
+ if First > 0 then
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 loop;
end Group_Switches;