summaryrefslogtreecommitdiff
path: root/gcc/ada/g-comlin.ads
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2008-08-06 08:33:21 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2008-08-06 08:33:21 +0000
commitbc0d729a9c81483e2aa77dfe943976b83a926736 (patch)
treebf253ff6c0ad14f839a0965ef719d58c602a7055 /gcc/ada/g-comlin.ads
parentbabc1edf43a7fb89bc8da3264c090cb2b36f1022 (diff)
downloadgcc-bc0d729a9c81483e2aa77dfe943976b83a926736.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138775 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/g-comlin.ads')
-rw-r--r--gcc/ada/g-comlin.ads50
1 files changed, 46 insertions, 4 deletions
diff --git a/gcc/ada/g-comlin.ads b/gcc/ada/g-comlin.ads
index d92c157e3f1..738afe96a69 100644
--- a/gcc/ada/g-comlin.ads
+++ b/gcc/ada/g-comlin.ads
@@ -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;