This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] New function Ada.Environment_Variables.Value with default


Ada 2012 added a new function in Ada.Environment_Variable:

function Value (Name : in String; Default : in String) return String;

The test is to build this main procedure with the switch -gnat2012:

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Environment_Variables;
use Ada.Environment_Variables;

procedure Main is
   EV : constant String := "GNAT_TOTO";

begin
   Put_Line (Boolean'Image (Exists (EV)));
   Put_Line (Value (EV, "toto"));
   Set (EV, "tata");
   Put_Line (Boolean'Image (Exists (EV)));
   Put_Line (Value (EV, "toto"));
   Put_Line (Value (EV));
end Main;

The output of its execution should be:

FALSE
toto
TRUE
tata
tata

Tested on x86_64-pc-linux-gnu, committed on trunk

2013-04-23  Vincent Celier  <celier@adacore.com>

	* a-envvar.adb, a-envvar.ads (Value): New.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]