Commit afab164f by Emmanuel Briot Committed by Arnaud Charlet

g-comlin.adb, [...] (Add_Switch): Put back support for overriding the separator.

2011-08-04  Emmanuel Briot  <briot@adacore.com>

	* g-comlin.adb, g-comlin.ads (Add_Switch): Put back support for
	overriding the separator.

From-SVN: r177345
parent fe0ec02f
2011-08-04 Emmanuel Briot <briot@adacore.com>
* g-comlin.adb, g-comlin.ads (Add_Switch): Put back support for
overriding the separator.
2011-08-04 Robert Dewar <dewar@adacore.com>
* sem_aggr.adb, par_sco.adb, sem_type.adb, exp_util.adb, exp_ch9.adb,
......
......@@ -2113,7 +2113,7 @@ package body GNAT.Command_Line is
(Cmd : in out Command_Line;
Switch : String;
Parameter : String := "";
Separator : Character := ' ';
Separator : Character := ASCII.NUL;
Section : String := "";
Add_Before : Boolean := False)
is
......@@ -2132,16 +2132,14 @@ package body GNAT.Command_Line is
(Cmd : in out Command_Line;
Switch : String;
Parameter : String := "";
Separator : Character := ' ';
Separator : Character := ASCII.NUL;
Section : String := "";
Add_Before : Boolean := False;
Success : out Boolean)
is
pragma Unreferenced (Separator); -- ??? Should be removed eventually
procedure Add_Simple_Switch
(Simple : String;
Separator : String;
Sepa : String;
Param : String;
Index : Integer);
-- Add a new switch that has had all its aliases expanded, and switches
......@@ -2153,7 +2151,7 @@ package body GNAT.Command_Line is
procedure Add_Simple_Switch
(Simple : String;
Separator : String;
Sepa : String;
Param : String;
Index : Integer)
is
......@@ -2168,10 +2166,13 @@ package body GNAT.Command_Line is
with "Invalid switch " & Simple;
end if;
if Separator = "" then
if Separator /= ASCII.NUL then
Sep := Separator;
elsif Sepa = "" then
Sep := ASCII.NUL;
else
Sep := Separator (Separator'First);
Sep := Sepa (Sepa'First);
end if;
if Cmd.Expanded = null then
......
......@@ -599,9 +599,8 @@ package GNAT.Command_Line is
-- format (trailing ':', '?', etc for defining a switch with parameters).
--
-- Switch should also start with the leading '-' (or any other characters).
-- They should all start with the same character, though. If this
-- character is not '-', you will need to call Initialize_Option_Scan to
-- set the proper character for the parser.
-- If this character is not '-', you will need to call
-- Initialize_Option_Scan to set the proper character for the parser.
--
-- The switches defined in the command_line_configuration object are used
-- when ungrouping switches with more that one character after the prefix.
......@@ -812,7 +811,7 @@ package GNAT.Command_Line is
(Cmd : in out Command_Line;
Switch : String;
Parameter : String := "";
Separator : Character := ' ';
Separator : Character := ASCII.NUL;
Section : String := "";
Add_Before : Boolean := False);
-- Add a new switch to the command line, and combine/group it with existing
......@@ -839,8 +838,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").
--
-- [Separator] is ignored, and kept for backward compatibility only.
-- ??? It might be removed in future versions.
-- [Separator], if specified, overrides the separator that was defined
-- through Define_Switch. For instance, if the switch was defined as
-- "-from:", the separator defaults to a space. But if your application
-- uses unusual separators not supported by GNAT.Command_Line (for instance
-- it requires ":"), you can specify this separator here.
-- For instance,
-- Add_Switch(Cmd, "-from", "bar", ':')
-- results in
-- -from:bar
-- rather than the default
-- -from bar
--
-- Note however that Getopt doesn't know how to handle ":" as a separator.
-- So the recommendation is to declare the switch as "-from!" (ie no
-- space between the switch and its parameter). Then Getopt will return
-- ":bar" as the parameter, and you can trim the ":" in your application.
--
-- Invalid_Section is raised if Section was not defined in the
-- configuration of the command line.
......@@ -852,7 +865,7 @@ package GNAT.Command_Line is
(Cmd : in out Command_Line;
Switch : String;
Parameter : String := "";
Separator : Character := ' ';
Separator : Character := ASCII.NUL;
Section : String := "";
Add_Before : Boolean := False;
Success : out Boolean);
......
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