diff options
author | Dmitriy Anisimkov <anisimko@adacore.com> | 2019-08-12 09:01:53 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-08-12 09:01:53 +0000 |
commit | 4a2e9be1ac7c8f4c37b5deb4ce0b0f39925e56c9 (patch) | |
tree | aef6e2ce3f082e962168baaaeeab023dec9ac1a1 /gcc | |
parent | 68e4cc9854044a2f66623c5d8dd36bc27bd948f2 (diff) | |
download | gcc-4a2e9be1ac7c8f4c37b5deb4ce0b0f39925e56c9.zip gcc-4a2e9be1ac7c8f4c37b5deb4ce0b0f39925e56c9.tar.gz gcc-4a2e9be1ac7c8f4c37b5deb4ce0b0f39925e56c9.tar.bz2 |
[Ada] New parameter Quiet for procedure GNAT.Command_Line.Getopt
Getopt procedure is parsing the command line or set of strings. If the
command line contains unknown switch than the Getopt prints error
message to the console and raises the exception Invalid_Switch. The
printing can be inappropriate in some cases. The new parameter Quiet
allows avoiding console output.
2019-08-12 Dmitriy Anisimkov <anisimko@adacore.com>
gcc/ada/
* libgnat/g-comlin.ads, libgnat/g-comlin.adb (Getopt): Add
parameter Quiet. Need to do not output error messages to
console. Invalid_Switch exception generation surrounded by an
error message.
From-SVN: r274307
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ada/libgnat/g-comlin.adb | 23 | ||||
-rw-r--r-- | gcc/ada/libgnat/g-comlin.ads | 4 |
3 files changed, 24 insertions, 10 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index c62e621..8b8a944 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2019-08-12 Dmitriy Anisimkov <anisimko@adacore.com> + + * libgnat/g-comlin.ads, libgnat/g-comlin.adb (Getopt): Add + parameter Quiet. Need to do not output error messages to + console. Invalid_Switch exception generation surrounded by an + error message. + 2019-08-12 Ed Schonberg <schonberg@adacore.com> * exp_ch6.adb (Expand_Actuals. Add_Call_By_Copy_Code): Add code diff --git a/gcc/ada/libgnat/g-comlin.adb b/gcc/ada/libgnat/g-comlin.adb index 29100af..f567ddb 100644 --- a/gcc/ada/libgnat/g-comlin.adb +++ b/gcc/ada/libgnat/g-comlin.adb @@ -753,7 +753,8 @@ package body GNAT.Command_Line is Parser.Current_Index := End_Index + 1; - raise Invalid_Switch; + raise Invalid_Switch with + "Unrecognized option " & Full_Switch (Parser); end if; End_Index := Parser.Current_Index + Max_Length - 1; @@ -883,7 +884,8 @@ package body GNAT.Command_Line is Last => Arg'Last, Extra => Parser.Switch_Character); Parser.Current_Index := Arg'Last + 1; - raise Invalid_Switch; + raise Invalid_Switch with + "Unrecognized option " & Full_Switch (Parser); end if; end case; @@ -3365,7 +3367,8 @@ package body GNAT.Command_Line is (Config : Command_Line_Configuration; Callback : Switch_Handler := null; Parser : Opt_Parser := Command_Line_Parser; - Concatenate : Boolean := True) + Concatenate : Boolean := True; + Quiet : Boolean := False) is Local_Config : Command_Line_Configuration := Config; Getopt_Switches : String_Access; @@ -3575,12 +3578,14 @@ package body GNAT.Command_Line is -- Message inspired by "ls" on Unix - Put_Line (Standard_Error, - Base_Name (Ada.Command_Line.Command_Name) - & ": unrecognized option '" - & Full_Switch (Parser) - & "'"); - Try_Help; + if not Quiet then + Put_Line (Standard_Error, + Base_Name (Ada.Command_Line.Command_Name) + & ": unrecognized option '" + & Full_Switch (Parser) + & "'"); + Try_Help; + end if; raise; diff --git a/gcc/ada/libgnat/g-comlin.ads b/gcc/ada/libgnat/g-comlin.ads index f1251b6..3708c37 100644 --- a/gcc/ada/libgnat/g-comlin.ads +++ b/gcc/ada/libgnat/g-comlin.ads @@ -738,7 +738,8 @@ package GNAT.Command_Line is (Config : Command_Line_Configuration; Callback : Switch_Handler := null; Parser : Opt_Parser := Command_Line_Parser; - Concatenate : Boolean := True); + Concatenate : Boolean := True; + Quiet : Boolean := False); -- Similar to the standard Getopt function. For each switch found on the -- command line, this calls Callback, if the switch is not handled -- automatically. @@ -756,6 +757,7 @@ package GNAT.Command_Line is -- to display the help message and raises Exit_From_Command_Line. -- If an invalid switch is specified on the command line, this procedure -- will display an error message and raises Invalid_Switch again. + -- If the Quiet parameter is True then the error message is not displayed. -- -- This function automatically expands switches: -- |