From: Emmanuel Briot Date: Thu, 4 Aug 2011 09:44:38 +0000 (+0000) Subject: g-comlin.adb, [...] (Add_Switch): Put back support for overriding the separator. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=afab164f736e5d4e746f2832f58f838e797d3bca;p=gcc.git g-comlin.adb, [...] (Add_Switch): Put back support for overriding the separator. 2011-08-04 Emmanuel Briot * g-comlin.adb, g-comlin.ads (Add_Switch): Put back support for overriding the separator. From-SVN: r177345 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ed0bfd7bc07..d8a2abe161e 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2011-08-04 Emmanuel Briot + + * g-comlin.adb, g-comlin.ads (Add_Switch): Put back support for + overriding the separator. + 2011-08-04 Robert Dewar * sem_aggr.adb, par_sco.adb, sem_type.adb, exp_util.adb, exp_ch9.adb, diff --git a/gcc/ada/g-comlin.adb b/gcc/ada/g-comlin.adb index b39c57ae200..0d7528946dc 100644 --- a/gcc/ada/g-comlin.adb +++ b/gcc/ada/g-comlin.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 diff --git a/gcc/ada/g-comlin.ads b/gcc/ada/g-comlin.ads index 590eab61923..3b5089428a6 100644 --- a/gcc/ada/g-comlin.ads +++ b/gcc/ada/g-comlin.ads @@ -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);