Commit e4b631a5 by Simon Wright Committed by Eric Botcazou

re PR ada/71358 (GNAT.Command_Line.Getopt fails if there are no switches)

	PR ada/71358
	* g-comlin.adb (Display_Section_Help): Do not dereference
	Config.Switches if it's null.
	(Getopt): Likewise.

From-SVN: r236975
parent 827cf695
2016-06-01 Simon Wright <simon@pushface.org>
PR ada/71358
* g-comlin.adb (Display_Section_Help): Do not dereference
Config.Switches if it's null.
(Getopt): Likewise.
2016-05-31 Eric Botcazou <ebotcazou@adacore.com> 2016-05-31 Eric Botcazou <ebotcazou@adacore.com>
* s-osinte-kfreebsd-gnu.ads (clock_getres): Define. * s-osinte-kfreebsd-gnu.ads (clock_getres): Define.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1999-2015, Free Software Foundation, Inc. -- -- Copyright (C) 1999-2016, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -3151,16 +3151,18 @@ package body GNAT.Command_Line is ...@@ -3151,16 +3151,18 @@ package body GNAT.Command_Line is
New_Line; New_Line;
if Section /= "" then if Section /= "" and then Config.Switches /= null then
Put_Line ("Switches after " & Section); Put_Line ("Switches after " & Section);
end if; end if;
-- Compute size of the switches column -- Compute size of the switches column
if Config.Switches /= null then
for S in Config.Switches'Range loop for S in Config.Switches'Range loop
Max_Len := Natural'Max Max_Len := Natural'Max
(Max_Len, Switch_Name (Config.Switches (S), Section)'Length); (Max_Len, Switch_Name (Config.Switches (S), Section)'Length);
end loop; end loop;
end if;
if Config.Aliases /= null then if Config.Aliases /= null then
for A in Config.Aliases'Range loop for A in Config.Aliases'Range loop
...@@ -3173,6 +3175,7 @@ package body GNAT.Command_Line is ...@@ -3173,6 +3175,7 @@ package body GNAT.Command_Line is
-- Display the switches -- Display the switches
if Config.Switches /= null then
for S in Config.Switches'Range loop for S in Config.Switches'Range loop
declare declare
N : constant String := N : constant String :=
...@@ -3192,6 +3195,7 @@ package body GNAT.Command_Line is ...@@ -3192,6 +3195,7 @@ package body GNAT.Command_Line is
end if; end if;
end; end;
end loop; end loop;
end if;
-- Display the aliases -- Display the aliases
...@@ -3454,6 +3458,7 @@ package body GNAT.Command_Line is ...@@ -3454,6 +3458,7 @@ package body GNAT.Command_Line is
-- Initialize output values for automatically handled switches -- Initialize output values for automatically handled switches
if Config.Switches /= null then
for S in Config.Switches'Range loop for S in Config.Switches'Range loop
case Config.Switches (S).Typ is case Config.Switches (S).Typ is
when Switch_Untyped => when Switch_Untyped =>
...@@ -3473,6 +3478,7 @@ package body GNAT.Command_Line is ...@@ -3473,6 +3478,7 @@ package body GNAT.Command_Line is
end if; end if;
end case; end case;
end loop; end loop;
end if;
-- For all sections, and all switches within those sections -- For all sections, and all switches within those sections
......
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