[multiple changes]
2011-09-06 Robert Dewar <dewar@adacore.com> * exp_ch7.adb, g-comlin.adb: Minor reformatting. 2011-09-06 Steve Baird <baird@adacore.com> * exp_ch4.adb (Expand_Allocator_Expression): Look through derived subprograms in checking for presence of an Extra_Accessibility_Of_Result formal parameter. * exp_ch6.adb (Expand_Call): Look through derived subprograms in checking for presence of an Extra_Accessibility_Of_Result formal parameter. (Expand_Call.Add_Actual_Parameter): Fix a bug in the case where the Parameter_Associatiations attribute is already set, but set to an empty list. (Needs_Result_Accessibility_Level): Unconditionally return False. This is a temporary change, disabling the Extra_Accessibility_Of_Result mechanism. (Expand_Simple_Function_Return): Check for Extra_Accessibility_Of_Result parameter's presence instead of testing Ada_Version when generating a runtime accessibility check which makes use of the parameter. From-SVN: r178571
This commit is contained in:
parent
eaed0c3777
commit
57a3fca931
@ -1,3 +1,27 @@
|
|||||||
|
2011-09-06 Robert Dewar <dewar@adacore.com>
|
||||||
|
|
||||||
|
* exp_ch7.adb, g-comlin.adb: Minor reformatting.
|
||||||
|
|
||||||
|
2011-09-06 Steve Baird <baird@adacore.com>
|
||||||
|
|
||||||
|
* exp_ch4.adb (Expand_Allocator_Expression): Look through
|
||||||
|
derived subprograms in checking for presence of an
|
||||||
|
Extra_Accessibility_Of_Result formal parameter.
|
||||||
|
* exp_ch6.adb (Expand_Call): Look through derived subprograms in
|
||||||
|
checking for presence of an Extra_Accessibility_Of_Result formal
|
||||||
|
parameter.
|
||||||
|
(Expand_Call.Add_Actual_Parameter): Fix a bug in the
|
||||||
|
case where the Parameter_Associatiations attribute is already set,
|
||||||
|
but set to an empty list.
|
||||||
|
(Needs_Result_Accessibility_Level):
|
||||||
|
Unconditionally return False. This is a temporary
|
||||||
|
change, disabling the Extra_Accessibility_Of_Result
|
||||||
|
mechanism.
|
||||||
|
(Expand_Simple_Function_Return): Check for
|
||||||
|
Extra_Accessibility_Of_Result parameter's presence instead of
|
||||||
|
testing Ada_Version when generating a runtime accessibility
|
||||||
|
check which makes use of the parameter.
|
||||||
|
|
||||||
2011-09-06 Ed Schonberg <schonberg@adacore.com>
|
2011-09-06 Ed Schonberg <schonberg@adacore.com>
|
||||||
|
|
||||||
* exp_ch4.adb (Expand_N_Case_Expression): Actions created for the
|
* exp_ch4.adb (Expand_N_Case_Expression): Actions created for the
|
||||||
|
@ -783,6 +783,8 @@ package body Exp_Ch4 is
|
|||||||
Subp := Entity (Name (Exp));
|
Subp := Entity (Name (Exp));
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
Subp := Ultimate_Alias (Subp);
|
||||||
|
|
||||||
if Present (Extra_Accessibility_Of_Result (Subp)) then
|
if Present (Extra_Accessibility_Of_Result (Subp)) then
|
||||||
Add_Extra_Actual_To_Call
|
Add_Extra_Actual_To_Call
|
||||||
(Subprogram_Call => Exp,
|
(Subprogram_Call => Exp,
|
||||||
|
@ -1847,8 +1847,10 @@ package body Exp_Ch6 is
|
|||||||
if No (Prev) then
|
if No (Prev) then
|
||||||
if No (Parameter_Associations (Call_Node)) then
|
if No (Parameter_Associations (Call_Node)) then
|
||||||
Set_Parameter_Associations (Call_Node, New_List);
|
Set_Parameter_Associations (Call_Node, New_List);
|
||||||
Append (Insert_Param, Parameter_Associations (Call_Node));
|
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
Append (Insert_Param, Parameter_Associations (Call_Node));
|
||||||
|
|
||||||
else
|
else
|
||||||
Insert_After (Prev, Insert_Param);
|
Insert_After (Prev, Insert_Param);
|
||||||
end if;
|
end if;
|
||||||
@ -2754,7 +2756,8 @@ package body Exp_Ch6 is
|
|||||||
-- passed in to it, then pass it in.
|
-- passed in to it, then pass it in.
|
||||||
|
|
||||||
if Ekind_In (Subp, E_Function, E_Operator, E_Subprogram_Type)
|
if Ekind_In (Subp, E_Function, E_Operator, E_Subprogram_Type)
|
||||||
and then Present (Extra_Accessibility_Of_Result (Subp))
|
and then
|
||||||
|
Present (Extra_Accessibility_Of_Result (Ultimate_Alias (Subp)))
|
||||||
then
|
then
|
||||||
declare
|
declare
|
||||||
Ancestor : Node_Id := Parent (Call_Node);
|
Ancestor : Node_Id := Parent (Call_Node);
|
||||||
@ -2763,15 +2766,19 @@ package body Exp_Ch6 is
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
-- Unimplemented: if Subp returns an anonymous access type, then
|
-- Unimplemented: if Subp returns an anonymous access type, then
|
||||||
|
|
||||||
-- a) if the call is the operand of an explict conversion, then
|
-- a) if the call is the operand of an explict conversion, then
|
||||||
-- the target type of the conversion (a named access type)
|
-- the target type of the conversion (a named access type)
|
||||||
-- determines the accessibility level pass in;
|
-- determines the accessibility level pass in;
|
||||||
|
|
||||||
-- b) if the call defines an access discriminant of an object
|
-- b) if the call defines an access discriminant of an object
|
||||||
-- (e.g., the discriminant of an object being created by an
|
-- (e.g., the discriminant of an object being created by an
|
||||||
-- allocator, or the discriminant of a function result),
|
-- allocator, or the discriminant of a function result),
|
||||||
-- then the accessibility level to pass in is that of the
|
-- then the accessibility level to pass in is that of the
|
||||||
-- discriminated object being initialized).
|
-- discriminated object being initialized).
|
||||||
|
|
||||||
|
-- ???
|
||||||
|
|
||||||
while Nkind (Ancestor) = N_Qualified_Expression
|
while Nkind (Ancestor) = N_Qualified_Expression
|
||||||
loop
|
loop
|
||||||
Ancestor := Parent (Ancestor);
|
Ancestor := Parent (Ancestor);
|
||||||
@ -2851,7 +2858,9 @@ package body Exp_Ch6 is
|
|||||||
Scope_Depth (Current_Scope) + 1);
|
Scope_Depth (Current_Scope) + 1);
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
Add_Extra_Actual (Level, Extra_Accessibility_Of_Result (Subp));
|
Add_Extra_Actual
|
||||||
|
(Level,
|
||||||
|
Extra_Accessibility_Of_Result (Ultimate_Alias (Subp)));
|
||||||
end if;
|
end if;
|
||||||
end;
|
end;
|
||||||
end if;
|
end if;
|
||||||
@ -6742,7 +6751,7 @@ package body Exp_Ch6 is
|
|||||||
-- ensure that the function result does not outlive an
|
-- ensure that the function result does not outlive an
|
||||||
-- object designated by one of it discriminants.
|
-- object designated by one of it discriminants.
|
||||||
|
|
||||||
if Ada_Version >= Ada_2012
|
if Present (Extra_Accessibility_Of_Result (Scope_Id))
|
||||||
and then Has_Unconstrained_Access_Discriminants (R_Type)
|
and then Has_Unconstrained_Access_Discriminants (R_Type)
|
||||||
then
|
then
|
||||||
declare
|
declare
|
||||||
@ -8320,6 +8329,9 @@ package body Exp_Ch6 is
|
|||||||
return False;
|
return False;
|
||||||
end Has_Unconstrained_Access_Discriminant_Component;
|
end Has_Unconstrained_Access_Discriminant_Component;
|
||||||
|
|
||||||
|
Feature_Disabled : constant Boolean := True;
|
||||||
|
-- Temporary
|
||||||
|
|
||||||
-- Start of processing for Needs_Result_Accessibility_Level
|
-- Start of processing for Needs_Result_Accessibility_Level
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -8328,6 +8340,9 @@ package body Exp_Ch6 is
|
|||||||
if not Present (Func_Typ) then
|
if not Present (Func_Typ) then
|
||||||
return False;
|
return False;
|
||||||
|
|
||||||
|
elsif Feature_Disabled then
|
||||||
|
return False;
|
||||||
|
|
||||||
-- False if not a function, also handle enum-lit renames case
|
-- False if not a function, also handle enum-lit renames case
|
||||||
|
|
||||||
elsif Func_Typ = Standard_Void_Type
|
elsif Func_Typ = Standard_Void_Type
|
||||||
|
@ -1807,10 +1807,10 @@ package body Exp_Ch7 is
|
|||||||
(Available_View (Designated_Type (Obj_Typ)))
|
(Available_View (Designated_Type (Obj_Typ)))
|
||||||
and then Present (Expr)
|
and then Present (Expr)
|
||||||
and then
|
and then
|
||||||
(Is_Null_Access_BIP_Func_Call (Expr)
|
(Is_Null_Access_BIP_Func_Call (Expr)
|
||||||
or else
|
or else
|
||||||
(Is_Non_BIP_Func_Call (Expr)
|
(Is_Non_BIP_Func_Call (Expr)
|
||||||
and then not Is_Related_To_Func_Return (Obj_Id)))
|
and then not Is_Related_To_Func_Return (Obj_Id)))
|
||||||
then
|
then
|
||||||
Processing_Actions (Has_No_Init => True);
|
Processing_Actions (Has_No_Init => True);
|
||||||
|
|
||||||
@ -7035,17 +7035,14 @@ package body Exp_Ch7 is
|
|||||||
|
|
||||||
function Alignment_Of (Typ : Entity_Id) return Node_Id;
|
function Alignment_Of (Typ : Entity_Id) return Node_Id;
|
||||||
-- Subsidiary routine, generate the following attribute reference:
|
-- Subsidiary routine, generate the following attribute reference:
|
||||||
--
|
|
||||||
-- Typ'Alignment
|
-- Typ'Alignment
|
||||||
|
|
||||||
function Size_Of (Typ : Entity_Id) return Node_Id;
|
function Size_Of (Typ : Entity_Id) return Node_Id;
|
||||||
-- Subsidiary routine, generate the following attribute reference:
|
-- Subsidiary routine, generate the following attribute reference:
|
||||||
--
|
|
||||||
-- Typ'Size / Storage_Unit
|
-- Typ'Size / Storage_Unit
|
||||||
|
|
||||||
function Double_Size_Of (Typ : Entity_Id) return Node_Id;
|
function Double_Size_Of (Typ : Entity_Id) return Node_Id;
|
||||||
-- Subsidiary routine, generate the following expression:
|
-- Subsidiary routine, generate the following expression:
|
||||||
--
|
|
||||||
-- 2 * Typ'Size / Storage_Unit
|
-- 2 * Typ'Size / Storage_Unit
|
||||||
|
|
||||||
------------------
|
------------------
|
||||||
|
@ -119,9 +119,9 @@ package body GNAT.Command_Line is
|
|||||||
(Config : in out Command_Line_Configuration;
|
(Config : in out Command_Line_Configuration;
|
||||||
Switch : Switch_Definition);
|
Switch : Switch_Definition);
|
||||||
procedure Add
|
procedure Add
|
||||||
(Def : in out Alias_Definitions_List;
|
(Def : in out Alias_Definitions_List;
|
||||||
Alias : Alias_Definition);
|
Alias : Alias_Definition);
|
||||||
-- Add a new element to Def.
|
-- Add a new element to Def
|
||||||
|
|
||||||
procedure Initialize_Switch_Def
|
procedure Initialize_Switch_Def
|
||||||
(Def : out Switch_Definition;
|
(Def : out Switch_Definition;
|
||||||
@ -226,9 +226,8 @@ package body GNAT.Command_Line is
|
|||||||
for J in S'Range loop
|
for J in S'Range loop
|
||||||
if S (J) in 'A' .. 'Z' then
|
if S (J) in 'A' .. 'Z' then
|
||||||
S (J) := Character'Val
|
S (J) := Character'Val
|
||||||
(Character'Pos (S (J)) +
|
(Character'Pos (S (J)) +
|
||||||
Character'Pos ('a') -
|
(Character'Pos ('a') - Character'Pos ('A')));
|
||||||
Character'Pos ('A'));
|
|
||||||
end if;
|
end if;
|
||||||
end loop;
|
end loop;
|
||||||
end if;
|
end if;
|
||||||
@ -277,7 +276,8 @@ package body GNAT.Command_Line is
|
|||||||
-- go to the next level.
|
-- go to the next level.
|
||||||
|
|
||||||
elsif Is_Directory
|
elsif Is_Directory
|
||||||
(It.Dir_Name (1 .. It.Levels (Current).Name_Last) & S (1 .. Last))
|
(It.Dir_Name (1 .. It.Levels (Current).Name_Last) &
|
||||||
|
S (1 .. Last))
|
||||||
and then S (1 .. Last) /= "."
|
and then S (1 .. Last) /= "."
|
||||||
and then S (1 .. Last) /= ".."
|
and then S (1 .. Last) /= ".."
|
||||||
then
|
then
|
||||||
@ -402,6 +402,7 @@ package body GNAT.Command_Line is
|
|||||||
loop
|
loop
|
||||||
Parser.Current_Argument := Parser.Current_Argument + 1;
|
Parser.Current_Argument := Parser.Current_Argument + 1;
|
||||||
end loop;
|
end loop;
|
||||||
|
|
||||||
else
|
else
|
||||||
return String'(1 .. 0 => ' ');
|
return String'(1 .. 0 => ' ');
|
||||||
end if;
|
end if;
|
||||||
@ -533,8 +534,8 @@ package body GNAT.Command_Line is
|
|||||||
Length := Length + 1;
|
Length := Length + 1;
|
||||||
end loop;
|
end loop;
|
||||||
|
|
||||||
-- Length now marks the separator after the current switch
|
-- Length now marks the separator after the current switch. Last will
|
||||||
-- Last will mark the last character of the name of the switch
|
-- mark the last character of the name of the switch.
|
||||||
|
|
||||||
if Length = Index + 1 then
|
if Length = Index + 1 then
|
||||||
P := Parameter_None;
|
P := Parameter_None;
|
||||||
@ -584,7 +585,7 @@ package body GNAT.Command_Line is
|
|||||||
|
|
||||||
-- If we have finished parsing the current command line item (there
|
-- If we have finished parsing the current command line item (there
|
||||||
-- might be multiple switches in a single item), then go to the next
|
-- might be multiple switches in a single item), then go to the next
|
||||||
-- element
|
-- element.
|
||||||
|
|
||||||
if Parser.Current_Argument > Parser.Arg_Count
|
if Parser.Current_Argument > Parser.Arg_Count
|
||||||
or else (Parser.Current_Index >
|
or else (Parser.Current_Index >
|
||||||
@ -615,7 +616,7 @@ package body GNAT.Command_Line is
|
|||||||
|
|
||||||
-- If it isn't a switch, return it immediately. We also know it
|
-- If it isn't a switch, return it immediately. We also know it
|
||||||
-- isn't the parameter to a previous switch, since that has
|
-- isn't the parameter to a previous switch, since that has
|
||||||
-- already been handled
|
-- already been handled.
|
||||||
|
|
||||||
if Switches (Switches'First) = '*' then
|
if Switches (Switches'First) = '*' then
|
||||||
Set_Parameter
|
Set_Parameter
|
||||||
@ -754,6 +755,7 @@ package body GNAT.Command_Line is
|
|||||||
First => End_Index + 2,
|
First => End_Index + 2,
|
||||||
Last => Arg'Last);
|
Last => Arg'Last);
|
||||||
Dummy := Goto_Next_Argument_In_Section (Parser);
|
Dummy := Goto_Next_Argument_In_Section (Parser);
|
||||||
|
|
||||||
else
|
else
|
||||||
Parser.Current_Index := End_Index + 1;
|
Parser.Current_Index := End_Index + 1;
|
||||||
raise Invalid_Parameter;
|
raise Invalid_Parameter;
|
||||||
@ -993,9 +995,9 @@ package body GNAT.Command_Line is
|
|||||||
Parser.Stop_At_First := Stop_At_First_Non_Switch;
|
Parser.Stop_At_First := Stop_At_First_Non_Switch;
|
||||||
Parser.Section := (others => 1);
|
Parser.Section := (others => 1);
|
||||||
|
|
||||||
-- If we are using sections, we have to preprocess the command line
|
-- If we are using sections, we have to preprocess the command line to
|
||||||
-- to delimit them. A section can be repeated, so we just give each
|
-- delimit them. A section can be repeated, so we just give each item
|
||||||
-- item on the command line a section number
|
-- on the command line a section number
|
||||||
|
|
||||||
Section_Num := 1;
|
Section_Num := 1;
|
||||||
Section_Index := Section_Delimiters'First;
|
Section_Index := Section_Delimiters'First;
|
||||||
@ -1014,8 +1016,8 @@ package body GNAT.Command_Line is
|
|||||||
if Argument (Parser, Index)(1) = Parser.Switch_Character
|
if Argument (Parser, Index)(1) = Parser.Switch_Character
|
||||||
and then
|
and then
|
||||||
Argument (Parser, Index) = Parser.Switch_Character &
|
Argument (Parser, Index) = Parser.Switch_Character &
|
||||||
Section_Delimiters
|
Section_Delimiters
|
||||||
(Section_Index .. Last - 1)
|
(Section_Index .. Last - 1)
|
||||||
then
|
then
|
||||||
Parser.Section (Index) := 0;
|
Parser.Section (Index) := 0;
|
||||||
Delimiter_Found := True;
|
Delimiter_Found := True;
|
||||||
@ -1164,8 +1166,8 @@ package body GNAT.Command_Line is
|
|||||||
----------
|
----------
|
||||||
|
|
||||||
procedure Free (Parser : in out Opt_Parser) is
|
procedure Free (Parser : in out Opt_Parser) is
|
||||||
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
|
procedure Unchecked_Free is new
|
||||||
(Opt_Parser_Data, Opt_Parser);
|
Ada.Unchecked_Deallocation (Opt_Parser_Data, Opt_Parser);
|
||||||
begin
|
begin
|
||||||
if Parser /= null
|
if Parser /= null
|
||||||
and then Parser /= Command_Line_Parser
|
and then Parser /= Command_Line_Parser
|
||||||
@ -1217,11 +1219,13 @@ package body GNAT.Command_Line is
|
|||||||
-- Add --
|
-- Add --
|
||||||
---------
|
---------
|
||||||
|
|
||||||
procedure Add (Config : in out Command_Line_Configuration;
|
procedure Add
|
||||||
Switch : Switch_Definition)
|
(Config : in out Command_Line_Configuration;
|
||||||
|
Switch : Switch_Definition)
|
||||||
is
|
is
|
||||||
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
|
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
|
||||||
(Switch_Definitions, Switch_Definitions_List);
|
(Switch_Definitions, Switch_Definitions_List);
|
||||||
|
|
||||||
Tmp : Switch_Definitions_List;
|
Tmp : Switch_Definitions_List;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -1253,8 +1257,10 @@ package body GNAT.Command_Line is
|
|||||||
procedure Add (Def : in out Alias_Definitions_List;
|
procedure Add (Def : in out Alias_Definitions_List;
|
||||||
Alias : Alias_Definition)
|
Alias : Alias_Definition)
|
||||||
is
|
is
|
||||||
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
|
procedure Unchecked_Free is new
|
||||||
(Alias_Definitions, Alias_Definitions_List);
|
Ada.Unchecked_Deallocation
|
||||||
|
(Alias_Definitions, Alias_Definitions_List);
|
||||||
|
|
||||||
Tmp : Alias_Definitions_List := Def;
|
Tmp : Alias_Definitions_List := Def;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -1433,7 +1439,7 @@ package body GNAT.Command_Line is
|
|||||||
if (Section = "" and then Config.Switches (J).Section = null)
|
if (Section = "" and then Config.Switches (J).Section = null)
|
||||||
or else
|
or else
|
||||||
(Config.Switches (J).Section /= null
|
(Config.Switches (J).Section /= null
|
||||||
and then Config.Switches (J).Section.all = Section)
|
and then Config.Switches (J).Section.all = Section)
|
||||||
then
|
then
|
||||||
exit when Config.Switches (J).Switch /= null
|
exit when Config.Switches (J).Switch /= null
|
||||||
and then not Callback (Config.Switches (J).Switch.all, J);
|
and then not Callback (Config.Switches (J).Switch.all, J);
|
||||||
@ -1475,6 +1481,7 @@ package body GNAT.Command_Line is
|
|||||||
else
|
else
|
||||||
Append (Ret, " " & S);
|
Append (Ret, " " & S);
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
end Add_Switch;
|
end Add_Switch;
|
||||||
|
|
||||||
@ -1768,12 +1775,12 @@ package body GNAT.Command_Line is
|
|||||||
function Is_In_Config
|
function Is_In_Config
|
||||||
(Config_Switch : String; Index : Integer) return Boolean;
|
(Config_Switch : String; Index : Integer) return Boolean;
|
||||||
-- If Switch is the same as Config_Switch, run the callback and sets
|
-- If Switch is the same as Config_Switch, run the callback and sets
|
||||||
-- Found_In_Config to True
|
-- Found_In_Config to True.
|
||||||
|
|
||||||
function Starts_With
|
function Starts_With
|
||||||
(Config_Switch : String; Index : Integer) return Boolean;
|
(Config_Switch : String; Index : Integer) return Boolean;
|
||||||
-- if Switch starts with Config_Switch, sets Found_In_Config to True.
|
-- if Switch starts with Config_Switch, sets Found_In_Config to True.
|
||||||
-- The return value is for the Foreach_Switch iterator
|
-- The return value is for the Foreach_Switch iterator.
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
-- Group_Analysis --
|
-- Group_Analysis --
|
||||||
@ -1832,9 +1839,7 @@ package body GNAT.Command_Line is
|
|||||||
end loop;
|
end loop;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
if not Require_Parameter (Switch)
|
if not Require_Parameter (Switch) or else Last >= Param then
|
||||||
or else Last >= Param
|
|
||||||
then
|
|
||||||
if Idx = Group'First
|
if Idx = Group'First
|
||||||
and then Last = Group'Last
|
and then Last = Group'Last
|
||||||
and then Last < Param
|
and then Last < Param
|
||||||
@ -1860,6 +1865,7 @@ package body GNAT.Command_Line is
|
|||||||
Section,
|
Section,
|
||||||
Prefix & Group (Idx .. Param - 1),
|
Prefix & Group (Idx .. Param - 1),
|
||||||
Group (Param .. Last));
|
Group (Param .. Last));
|
||||||
|
|
||||||
else
|
else
|
||||||
For_Each_Simple_Switch
|
For_Each_Simple_Switch
|
||||||
(Config, Section, Prefix & Group (Idx .. Last), "");
|
(Config, Section, Prefix & Group (Idx .. Last), "");
|
||||||
@ -1881,7 +1887,6 @@ package body GNAT.Command_Line is
|
|||||||
Idx := Group'First;
|
Idx := Group'First;
|
||||||
while Idx <= Group'Last loop
|
while Idx <= Group'Last loop
|
||||||
Found := False;
|
Found := False;
|
||||||
|
|
||||||
Foreach (Config, Section);
|
Foreach (Config, Section);
|
||||||
|
|
||||||
if not Found then
|
if not Found then
|
||||||
@ -1960,7 +1965,8 @@ package body GNAT.Command_Line is
|
|||||||
Decompose_Switch (Config_Switch, P, Last);
|
Decompose_Switch (Config_Switch, P, Last);
|
||||||
|
|
||||||
if Looking_At
|
if Looking_At
|
||||||
(Switch, Switch'First, Config_Switch (Config_Switch'First .. Last))
|
(Switch, Switch'First,
|
||||||
|
Config_Switch (Config_Switch'First .. Last))
|
||||||
then
|
then
|
||||||
-- Set first char of Param, and last char of Switch
|
-- Set first char of Param, and last char of Switch
|
||||||
|
|
||||||
@ -2546,7 +2552,9 @@ package body GNAT.Command_Line is
|
|||||||
if Result (C) /= null
|
if Result (C) /= null
|
||||||
and then Compatible_Parameter (Params (C))
|
and then Compatible_Parameter (Params (C))
|
||||||
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
|
||||||
-- If we are still in the same section, group the switches
|
-- If we are still in the same section, group the switches
|
||||||
|
|
||||||
@ -2589,8 +2597,8 @@ package body GNAT.Command_Line is
|
|||||||
Group :=
|
Group :=
|
||||||
Ada.Strings.Unbounded.To_Unbounded_String
|
Ada.Strings.Unbounded.To_Unbounded_String
|
||||||
(Result (C)
|
(Result (C)
|
||||||
(Result (C)'First + Cmd.Config.Prefixes (P)'Length ..
|
(Result (C)'First + Cmd.Config.Prefixes (P)'Length ..
|
||||||
Result (C)'Last));
|
Result (C)'Last));
|
||||||
First := C;
|
First := C;
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
@ -2642,8 +2650,8 @@ package body GNAT.Command_Line is
|
|||||||
if Result (E) /= null
|
if Result (E) /= null
|
||||||
and then
|
and then
|
||||||
(Params (E) = null
|
(Params (E) = null
|
||||||
or else Params (E) (Params (E)'First + 1
|
or else Params (E) (Params (E)'First + 1 ..
|
||||||
.. Params (E)'Last) = Param)
|
Params (E)'Last) = Param)
|
||||||
and then Result (E).all = Switch
|
and then Result (E).all = Switch
|
||||||
then
|
then
|
||||||
return;
|
return;
|
||||||
@ -2866,16 +2874,19 @@ package body GNAT.Command_Line is
|
|||||||
|
|
||||||
function Is_New_Section (Iter : Command_Line_Iterator) return Boolean is
|
function Is_New_Section (Iter : Command_Line_Iterator) return Boolean is
|
||||||
Section : constant String := Current_Section (Iter);
|
Section : constant String := Current_Section (Iter);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if Iter.Sections = null then
|
if Iter.Sections = null then
|
||||||
return False;
|
return False;
|
||||||
|
|
||||||
elsif Iter.Current = Iter.Sections'First
|
elsif Iter.Current = Iter.Sections'First
|
||||||
or else Iter.Sections (Iter.Current - 1) = null
|
or else Iter.Sections (Iter.Current - 1) = null
|
||||||
then
|
then
|
||||||
return Section /= "";
|
return Section /= "";
|
||||||
end if;
|
|
||||||
|
|
||||||
return Section /= Iter.Sections (Iter.Current - 1).all;
|
else
|
||||||
|
return Section /= Iter.Sections (Iter.Current - 1).all;
|
||||||
|
end if;
|
||||||
end Is_New_Section;
|
end Is_New_Section;
|
||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
@ -2933,12 +2944,11 @@ package body GNAT.Command_Line is
|
|||||||
return "";
|
return "";
|
||||||
|
|
||||||
else
|
else
|
||||||
|
-- Return result, skipping separator
|
||||||
|
|
||||||
declare
|
declare
|
||||||
P : constant String := Iter.Params (Iter.Current).all;
|
P : constant String := Iter.Params (Iter.Current).all;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
-- Skip separator
|
|
||||||
|
|
||||||
return P (P'First + 1 .. P'Last);
|
return P (P'First + 1 .. P'Last);
|
||||||
end;
|
end;
|
||||||
end if;
|
end if;
|
||||||
@ -2972,10 +2982,14 @@ package body GNAT.Command_Line is
|
|||||||
----------
|
----------
|
||||||
|
|
||||||
procedure Free (Config : in out Command_Line_Configuration) is
|
procedure Free (Config : in out Command_Line_Configuration) is
|
||||||
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
|
procedure Unchecked_Free is new
|
||||||
(Switch_Definitions, Switch_Definitions_List);
|
Ada.Unchecked_Deallocation
|
||||||
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
|
(Switch_Definitions, Switch_Definitions_List);
|
||||||
(Alias_Definitions, Alias_Definitions_List);
|
|
||||||
|
procedure Unchecked_Free is new
|
||||||
|
Ada.Unchecked_Deallocation
|
||||||
|
(Alias_Definitions, Alias_Definitions_List);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if Config /= null then
|
if Config /= null then
|
||||||
Free (Config.Prefixes);
|
Free (Config.Prefixes);
|
||||||
@ -2990,6 +3004,7 @@ package body GNAT.Command_Line is
|
|||||||
Free (Config.Aliases (A).Expansion);
|
Free (Config.Aliases (A).Expansion);
|
||||||
Free (Config.Aliases (A).Section);
|
Free (Config.Aliases (A).Section);
|
||||||
end loop;
|
end loop;
|
||||||
|
|
||||||
Unchecked_Free (Config.Aliases);
|
Unchecked_Free (Config.Aliases);
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
@ -3040,6 +3055,7 @@ package body GNAT.Command_Line is
|
|||||||
Free (Config.Usage);
|
Free (Config.Usage);
|
||||||
Free (Config.Help);
|
Free (Config.Help);
|
||||||
Free (Config.Help_Msg);
|
Free (Config.Help_Msg);
|
||||||
|
|
||||||
Config.Usage := new String'(Usage);
|
Config.Usage := new String'(Usage);
|
||||||
Config.Help := new String'(Help);
|
Config.Help := new String'(Help);
|
||||||
Config.Help_Msg := new String'(Help_Msg);
|
Config.Help_Msg := new String'(Help_Msg);
|
||||||
@ -3070,6 +3086,7 @@ package body GNAT.Command_Line is
|
|||||||
|
|
||||||
procedure Display_Section_Help (Section : String) is
|
procedure Display_Section_Help (Section : String) is
|
||||||
Max_Len : Natural := 0;
|
Max_Len : Natural := 0;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
-- ??? Special display for "*"
|
-- ??? Special display for "*"
|
||||||
|
|
||||||
@ -3100,7 +3117,8 @@ package body GNAT.Command_Line is
|
|||||||
for S in Config.Switches'Range loop
|
for S in Config.Switches'Range loop
|
||||||
declare
|
declare
|
||||||
N : constant String :=
|
N : constant String :=
|
||||||
Switch_Name (Config.Switches (S), Section);
|
Switch_Name (Config.Switches (S), Section);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if N /= "" then
|
if N /= "" then
|
||||||
Put (" ");
|
Put (" ");
|
||||||
@ -3176,9 +3194,7 @@ package body GNAT.Command_Line is
|
|||||||
if (Section = "" and then Def.Section = null)
|
if (Section = "" and then Def.Section = null)
|
||||||
or else (Def.Section /= null and then Def.Section.all = Section)
|
or else (Def.Section /= null and then Def.Section.all = Section)
|
||||||
then
|
then
|
||||||
if Def.Switch /= null
|
if Def.Switch /= null and then Def.Switch.all = "*" then
|
||||||
and then Def.Switch.all = "*"
|
|
||||||
then
|
|
||||||
return "[any switch]";
|
return "[any switch]";
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
@ -3229,8 +3245,10 @@ package body GNAT.Command_Line is
|
|||||||
|
|
||||||
if Config.Help_Msg /= null and then Config.Help_Msg.all /= "" then
|
if Config.Help_Msg /= null and then Config.Help_Msg.all /= "" then
|
||||||
Put_Line (Config.Help_Msg.all);
|
Put_Line (Config.Help_Msg.all);
|
||||||
|
|
||||||
else
|
else
|
||||||
Display_Section_Help ("");
|
Display_Section_Help ("");
|
||||||
|
|
||||||
if Config.Sections /= null and then Config.Switches /= null then
|
if Config.Sections /= null and then Config.Switches /= null then
|
||||||
for S in Config.Sections'Range loop
|
for S in Config.Sections'Range loop
|
||||||
Display_Section_Help (Config.Sections (S).all);
|
Display_Section_Help (Config.Sections (S).all);
|
||||||
@ -3395,13 +3413,15 @@ package body GNAT.Command_Line is
|
|||||||
|
|
||||||
elsif C /= ASCII.NUL then
|
elsif C /= ASCII.NUL then
|
||||||
if Full_Switch (Parser) = "h"
|
if Full_Switch (Parser) = "h"
|
||||||
or else Full_Switch (Parser) = "-help"
|
or else
|
||||||
|
Full_Switch (Parser) = "-help"
|
||||||
then
|
then
|
||||||
Display_Help (Config);
|
Display_Help (Config);
|
||||||
raise Exit_From_Command_Line;
|
raise Exit_From_Command_Line;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
-- Do switch expansion if needed
|
-- Do switch expansion if needed
|
||||||
|
|
||||||
For_Each_Simple
|
For_Each_Simple
|
||||||
(Config,
|
(Config,
|
||||||
Section => Section_Name.all,
|
Section => Section_Name.all,
|
||||||
@ -3482,8 +3502,7 @@ package body GNAT.Command_Line is
|
|||||||
Start (Line, Iter, Expanded => Expanded);
|
Start (Line, Iter, Expanded => Expanded);
|
||||||
while Has_More (Iter) loop
|
while Has_More (Iter) loop
|
||||||
if Is_New_Section (Iter) then
|
if Is_New_Section (Iter) then
|
||||||
Args (Count) := new String'
|
Args (Count) := new String'(Switch_Char & Current_Section (Iter));
|
||||||
(Switch_Char & Current_Section (Iter));
|
|
||||||
Count := Count + 1;
|
Count := Count + 1;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user