Commit f9325b03 by Arnaud Charlet

g-comlin.adb (Define_Switch, [...]): New.

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

	* g-comlin.adb (Define_Switch, Get_Switches): New.
	(Can_Have_Parameter, Require_Parameter, Actual_Switch): New, used when
	ungrouping switches.
	(For_Each_Simple_Switch): Allow more control over parameters handling.
	This generic method now allows ungrouping of switches with parameters
	and switches with more than one letter after the prefix.
	(Set_Command_Line): Take care of switches that are prefixed with a
	switch handling parameters without delimiter (-gnatya and -gnaty3 for
	example).
	(Add_Switch, Remove_Switch): Handle parameters possibly present inside
	a group, as in gnaty3aM80 (3 and 80 are parameters). Report status of
	the operation.
	(Start, Alias_Switches, Group_Switches): Take care of parameters
	possibly present inside a group.

	* g-comlin.ads (Define_Switch): New method used to define a list of
	expected switches, that are necessary for correctly ungrouping switches
	with more that one character after the prefix.
	(Get_Switches): Method that builds a getopt string from the list of
	switches as set previously by Define_Switch.
	(Add_Switch, Remove_Switch): New versions of the methods, reporting the
	status of the operation. Also allow the removal of switches with
	parameters only.
	(Command_Line_Configuration_Record): Maintain a list of expected
	switches.

From-SVN: r138775
parent 1c5a12b4
2008-08-06 Thomas Quinot <quinot@adacore.com>
* xnmake.adb: Use new XUtil package for platform independent text
output.
2008-08-06 Vincent Celier <celier@adacore.com>
* gnat_ugn.texi: Document compiler switch -gnateG
2008-08-06 Quentin Ochem <ochem@adacore.com>
* s-stausa.adb (Fill_Stack): Fixed pragma assert and top pattern mark
in the case of an empty pattern size.
(Compute_Result): Do not do any computation in the case of an empty
pattern size.
(Report_Result): Fixed computation of the overflow guard.
2008-08-06 Ed Schonberg <schonberg@adacore.com>
* g-awk.adb (Finalize): Do not use directly objects of the type in the
finalization routine to prevent elaboration order anomalies in new
finalization scheme.
2008-08-06 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Find_Type_Name): protect against duplicate incomplete
declaration for the same type.
2008-08-06 Thomas Quinot <quinot@adacore.com>
* sem.adb: Minor rewording (comment)
2008-08-06 Jerome Lambourg <lambourg@adacore.com>
* g-comlin.adb (Define_Switch, Get_Switches): New.
(Can_Have_Parameter, Require_Parameter, Actual_Switch): New, used when
ungrouping switches.
(For_Each_Simple_Switch): Allow more control over parameters handling.
This generic method now allows ungrouping of switches with parameters
and switches with more than one letter after the prefix.
(Set_Command_Line): Take care of switches that are prefixed with a
switch handling parameters without delimiter (-gnatya and -gnaty3 for
example).
(Add_Switch, Remove_Switch): Handle parameters possibly present inside
a group, as in gnaty3aM80 (3 and 80 are parameters). Report status of
the operation.
(Start, Alias_Switches, Group_Switches): Take care of parameters
possibly present inside a group.
* g-comlin.ads (Define_Switch): New method used to define a list of
expected switches, that are necessary for correctly ungrouping switches
with more that one character after the prefix.
(Get_Switches): Method that builds a getopt string from the list of
switches as set previously by Define_Switch.
(Add_Switch, Remove_Switch): New versions of the methods, reporting the
status of the operation. Also allow the removal of switches with
parameters only.
(Command_Line_Configuration_Record): Maintain a list of expected
switches.
2008-08-06 Doug Rupp <rupp@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_param): Force 32bit descriptor if
......@@ -513,6 +513,14 @@ package GNAT.Command_Line is
-- characters whose order is irrelevant. In fact, this package will sort
-- them alphabetically.
procedure Define_Switch
(Config : in out Command_Line_Configuration;
Switch : String);
-- Indicates a new switch. The format of this switch follows the getopt
-- format (trailing ':', '?', etc for defining a switch with parameters).
-- The switches defined in the command_line_configuration object are used
-- when ungrouping switches with more that one character after the prefix.
procedure Define_Section
(Config : in out Command_Line_Configuration;
Section : String);
......@@ -520,6 +528,13 @@ package GNAT.Command_Line is
-- section are ordered together, preceded by the section. They are placed
-- at the end of the command line (as in 'gnatmake somefile.adb -cargs -g')
function Get_Switches
(Config : Command_Line_Configuration;
Switch_Char : Character)
return String;
-- Get the switches list as expected by getopt. This list is built using
-- all switches defined previously via Define_Switch above.
procedure Free (Config : in out Command_Line_Configuration);
-- Free the memory used by Config
......@@ -595,11 +610,22 @@ package GNAT.Command_Line is
-- added if not already present. For example, to add the -g switch into the
-- -cargs section, you need to call (Cmd, "-g", Section => "-cargs")
procedure Add_Switch
(Cmd : in out Command_Line;
Switch : String;
Parameter : String := "";
Separator : Character := ' ';
Section : String := "";
Success : out Boolean);
-- Same as above, returning the status of
-- the operation
procedure Remove_Switch
(Cmd : in out Command_Line;
Switch : String;
Remove_All : Boolean := False;
Section : String := "");
(Cmd : in out Command_Line;
Switch : String;
Remove_All : Boolean := False;
Has_Parameter : Boolean := False;
Section : String := "");
-- Remove Switch from the command line, and ungroup existing switches if
-- necessary.
--
......@@ -610,6 +636,9 @@ package GNAT.Command_Line is
-- If Remove_All is True, then all matching switches are removed, otherwise
-- only the first matching one is removed.
--
-- if Has_Parameter is set to True, then only switches having a parameter
-- are removed.
--
-- If the switch belongs to a section, then this section should be
-- specified: Remove_Switch (Cmd_Line, "-g", Section => "-cargs") called
-- on the command line "-g -cargs -g" will result in "-g", while if
......@@ -617,6 +646,16 @@ package GNAT.Command_Line is
-- If Remove_All is set, then both "-g" will be removed.
procedure Remove_Switch
(Cmd : in out Command_Line;
Switch : String;
Remove_All : Boolean := False;
Has_Parameter : Boolean := False;
Section : String := "";
Success : out Boolean);
-- Same as above, reporting the success of the operation (Success is False
-- if no switch was removed).
procedure Remove_Switch
(Cmd : in out Command_Line;
Switch : String;
Parameter : String;
......@@ -774,6 +813,9 @@ private
Aliases : GNAT.OS_Lib.Argument_List_Access;
Expansions : GNAT.OS_Lib.Argument_List_Access;
-- The aliases. Both arrays have the same indices
Switches : GNAT.OS_Lib.Argument_List_Access;
-- List of expected switches. Used when expanding switch groups.
end record;
type Command_Line_Configuration is access Command_Line_Configuration_Record;
......
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