diff options
Diffstat (limited to 'gcc/ada/g-comlin.adb')
-rw-r--r-- | gcc/ada/g-comlin.adb | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/gcc/ada/g-comlin.adb b/gcc/ada/g-comlin.adb index 95b1fbe2367..d661978bd59 100644 --- a/gcc/ada/g-comlin.adb +++ b/gcc/ada/g-comlin.adb @@ -114,11 +114,11 @@ package body GNAT.Command_Line is function Args_From_Expanded (Args : Boolean_Chars) return String; -- Return the string made of all characters with True in Args - type Callback_Procedure is access procedure (Simple_Switch : String); + generic + with procedure Callback (Simple_Switch : String); procedure For_Each_Simple_Switch - (Cmd : Command_Line; - Switch : String; - Callback : Callback_Procedure); + (Cmd : Command_Line; + Switch : String); -- Breaks Switch into as simple switches as possible (expanding aliases and -- ungrouping common prefixes when possible), and call Callback for each of -- these. @@ -1185,9 +1185,8 @@ package body GNAT.Command_Line is ---------------------------- procedure For_Each_Simple_Switch - (Cmd : Command_Line; - Switch : String; - Callback : Callback_Procedure) + (Cmd : Command_Line; + Switch : String) is begin -- Are we adding a switch that can in fact be expanded through aliases ? @@ -1204,7 +1203,7 @@ package body GNAT.Command_Line is for A in Cmd.Config.Aliases'Range loop if Cmd.Config.Aliases (A).all = Switch then For_Each_Simple_Switch - (Cmd, Cmd.Config.Expansions (A).all, Callback); + (Cmd, Cmd.Config.Expansions (A).all); return; end if; end loop; @@ -1227,7 +1226,7 @@ package body GNAT.Command_Line is .. Switch'Last loop For_Each_Simple_Switch - (Cmd, Cmd.Config.Prefixes (P).all & Switch (S), Callback); + (Cmd, Cmd.Config.Prefixes (P).all & Switch (S)); end loop; return; end if; @@ -1291,11 +1290,13 @@ package body GNAT.Command_Line is end if; end Add_Simple_Switch; + procedure Add_Simple_Switches is + new For_Each_Simple_Switch (Add_Simple_Switch); + -- Start of processing for Add_Switch begin - For_Each_Simple_Switch - (Cmd, Switch, Add_Simple_Switch'Unrestricted_Access); + Add_Simple_Switches (Cmd, Switch); Free (Cmd.Coalesce); end Add_Switch; @@ -1381,11 +1382,13 @@ package body GNAT.Command_Line is end if; end Remove_Simple_Switch; + procedure Remove_Simple_Switches is + new For_Each_Simple_Switch (Remove_Simple_Switch); + -- Start of processing for Remove_Switch begin - For_Each_Simple_Switch - (Cmd, Switch, Remove_Simple_Switch'Unrestricted_Access); + Remove_Simple_Switches (Cmd, Switch); Free (Cmd.Coalesce); end Remove_Switch; @@ -1440,11 +1443,13 @@ package body GNAT.Command_Line is end if; end Remove_Simple_Switch; + procedure Remove_Simple_Switches is + new For_Each_Simple_Switch (Remove_Simple_Switch); + -- Start of processing for Remove_Switch begin - For_Each_Simple_Switch - (Cmd, Switch, Remove_Simple_Switch'Unrestricted_Access); + Remove_Simple_Switches (Cmd, Switch); Free (Cmd.Coalesce); end Remove_Switch; @@ -1566,6 +1571,9 @@ package body GNAT.Command_Line is end loop; end Remove_Cb; + procedure Check_All is new For_Each_Simple_Switch (Check_Cb); + procedure Remove_All is new For_Each_Simple_Switch (Remove_Cb); + -- Start of processing for Alias_Switches begin @@ -1582,15 +1590,11 @@ package body GNAT.Command_Line is -- then check whether the expanded command line has all of them. Found := True; - For_Each_Simple_Switch - (Cmd, Cmd.Config.Expansions (A).all, - Check_Cb'Unrestricted_Access); + Check_All (Cmd, Cmd.Config.Expansions (A).all); if Found then First := Integer'Last; - For_Each_Simple_Switch - (Cmd, Cmd.Config.Expansions (A).all, - Remove_Cb'Unrestricted_Access); + Remove_All (Cmd, Cmd.Config.Expansions (A).all); Result (First) := new String'(Cmd.Config.Aliases (A).all); end if; end loop; |