+2009-10-30 Robert Dewar <dewar@adacore.com>
+
+ * a-tideio.adb: Minor reformatting
+ * a-wtdeio.adb, a-ztdeio.adb: Update comments, code clean up.
+
+ * a-reatim.adb, a-tideau.adb, a-ngelfu.adb, a-ztdeau.adb, a-ngrear.adb,
+ a-wtedit.adb, a-ststio.adb, a-ztedit.adb: Minor code reorganization
+ (use conditional expressions).
+
+2009-10-30 Ed Schonberg <schonberg@adacore.com>
+
+ * gnat_ugn.texi: Additional info on gnatw.i and gnatw.I
+
+ * sem_case.adb: Improved error message.
+
+2009-10-30 Emmanuel Briot <briot@adacore.com>
+
+ * a-direct.adb, gnatcmd.adb, gnatname.adb, makeutl.adb, opt.ads,
+ osint.adb, prj-ext.adb, switch-m.adb (Follow_Links_For_Dirs): Now
+ defaults to False, and controlled by -eL.
+ * a-direct.adb: Add comments.
+ * osint.adb (File_Stamp): Avoid unneeded duplicate system call
+
2009-10-30 Robert Dewar <dewar@adacore.com>
* sem_res.adb (Resolve_Type_Conversion): Avoid false positive when
else
declare
+ -- We need to resolve links because of A.16(47), since we must not
+ -- return alternative names for files
Norm : constant String := Normalize_Pathname (Name);
Last_DS : constant Natural :=
Strings.Fixed.Index
Local_Get_Current_Dir (Buffer'Address, Path_Len'Address);
declare
+ -- We need to resolve links because of A.16(47), since we must not
+ -- return alternative names for files
Cur : constant String := Normalize_Pathname (Buffer (1 .. Path_Len));
begin
-- Use System.OS_Lib.Normalize_Pathname
declare
+ -- We need to resolve links because of A.16(47), since we must not
+ -- return alternative names for files
Value : constant String := Normalize_Pathname (Name);
subtype Result is String (1 .. Value'Length);
begin
Raw_Atan : Float_Type'Base;
begin
- if abs Y > abs X then
- Z := abs (X / Y);
- else
- Z := abs (Y / X);
- end if;
-
- if Z < Sqrt_Epsilon then
- Raw_Atan := Z;
+ Z := (if abs Y > abs X then abs (X / Y) else abs (Y / X));
- elsif Z = 1.0 then
- Raw_Atan := Pi / 4.0;
-
- else
- Raw_Atan := Float_Type'Base (Aux.Atan (Double (Z)));
- end if;
+ Raw_Atan :=
+ (if Z < Sqrt_Epsilon then Z
+ elsif Z = 1.0 then Pi / 4.0
+ else Float_Type'Base (Aux.Atan (Double (Z))));
if abs Y > abs X then
Raw_Atan := Half_Pi - Raw_Atan;
end if;
for J in 1 .. N loop
- if Piv (J) /= J then
- Det := -Det * LU (J, J);
- else
- Det := Det * LU (J, J);
- end if;
+ Det := (if Piv (J) /= J then -Det * LU (J, J) else Det * LU (J, J));
end loop;
return Det;
-- B o d y --
-- --
-- Copyright (C) 1991-1994, Florida State University --
--- Copyright (C) 1995-2006, AdaCore --
+-- Copyright (C) 1995-2009, AdaCore --
-- --
-- GNARL 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- --
-- Special-case for Time_First, whose absolute value is anomalous,
-- courtesy of two's complement.
- if T = Time_First then
- T_Val := abs (Time_Last);
- else
- T_Val := abs (T);
- end if;
+ T_Val := (if T = Time_First then abs (Time_Last) else abs (T));
-- Extract the integer part of T, truncating towards zero
- if T_Val < 0.5 then
- SC := 0;
- else
- SC := Seconds_Count (Time_Span'(T_Val - 0.5));
- end if;
+ SC :=
+ (if T_Val < 0.5 then 0 else Seconds_Count (Time_Span'(T_Val - 0.5)));
if T < 0.0 then
SC := -SC;
-- (and furthermore there are situations (such as the case of writing
-- a sequential Posix FIFO file) where the lseek would cause problems.
- if Mode = Out_File then
- File.Last_Op := Op_Write;
- else
- File.Last_Op := Op_Read;
- end if;
+ File.Last_Op := (if Mode = Out_File then Op_Write else Op_Read);
end Open;
----------
Ptr : Natural := 0;
begin
- if Exp = 0 then
- Fore := To'Length - 1 - Aft;
- else
- Fore := To'Length - 2 - Aft - Exp;
- end if;
+ Fore :=
+ (if Exp = 0 then To'Length - 1 - Aft else To'Length - 2 - Aft - Exp);
if Fore < 1 then
raise Layout_Error;
begin
if Num'Size > Integer'Size then
Item := Num'Fixed_Value (Aux.Get_LLD (File, Width, Scale));
-
else
Item := Num'Fixed_Value (Aux.Get_Dec (File, Width, Scale));
end if;
is
begin
if Num'Size > Integer'Size then
- Item := Num (Aux.Get_LLD (TFT (File), Width, Scale));
- -- Item := Num'Fixed_Value (Aux.Get_LLD (TFT (File), Width, Scale));
- -- above is what we should write, but gets assert error ???
-
+ Item := Num'Fixed_Value (Aux.Get_LLD (TFT (File), Width, Scale));
else
- Item := Num (Aux.Get_Dec (TFT (File), Width, Scale));
- -- Item := Num'Fixed_Value (Aux.Get_Dec (TFT (File), Width, Scale));
- -- above is what we should write, but gets assert error ???
+ Item := Num'Fixed_Value (Aux.Get_Dec (TFT (File), Width, Scale));
end if;
-
exception
when Constraint_Error => raise Data_Error;
end Get;
raise Layout_Error;
end if;
- if Pic.Radix_Position = Invalid_Position then
- Position := Answer'Last;
- else
- Position := Pic.Radix_Position - 1;
- end if;
+ Position :=
+ (if Pic.Radix_Position = Invalid_Position then Answer'Last
+ else Pic.Radix_Position - 1);
for J in reverse Attrs.Start_Of_Int .. Attrs.End_Of_Int loop
-
while Answer (Position) /= '9'
and then
Answer (Position) /= Pic.Floater
loop
if Answer (Position) = '_' then
Answer (Position) := Separator_Character;
-
elsif Answer (Position) = 'b' then
Answer (Position) := ' ';
end if;
-- No trailing digits, but now J may need to stick in a currency
-- symbol or sign.
- if Pic.Start_Currency = Invalid_Position then
- Position := Answer'Last + 1;
- else
- Position := Pic.Start_Currency;
- end if;
+ Position :=
+ (if Pic.Start_Currency = Invalid_Position then Answer'Last + 1
+ else Pic.Start_Currency);
end if;
for J in Position .. Answer'Last loop
-
if Pic.Start_Currency /= Invalid_Position and then
Answer (Pic.Start_Currency) = '#' then
Currency_Pos := 1;
end if;
- -- Note: There are some weird cases J can imagine with 'b' or '#'
- -- in currency strings where the following code will cause
- -- glitches. The trick is to tell when the character in the
- -- answer should be checked, and when to look at the original
- -- string. Some other time. RIE 11/26/96 ???
+ -- Note: There are some weird cases J can imagine with 'b' or '#' in
+ -- currency strings where the following code will cause glitches. The
+ -- trick is to tell when the character in the answer should be
+ -- checked, and when to look at the original string. Some other time.
+ -- RIE 11/26/96 ???
case Answer (J) is
when '*' =>
-- 1) Expand $, replace '.' with Radix_Point
- return Answer (1 .. Currency_Pos - 1) & Currency_Symbol &
- Answer (Currency_Pos + 1 .. Answer'Last);
+ return
+ Answer (1 .. Currency_Pos - 1) & Currency_Symbol &
+ Answer (Currency_Pos + 1 .. Answer'Last);
else
-- 2) No currency expansion, replace '.' with Radix_Point
Ptr : Natural := 0;
begin
- if Exp = 0 then
- Fore := To'Length - 1 - Aft;
- else
- Fore := To'Length - 2 - Aft - Exp;
- end if;
+ Fore :=
+ (if Exp = 0 then To'Length - 1 - Aft else To'Length - 2 - Aft - Exp);
if Fore < 1 then
raise Layout_Error;
is
begin
if Num'Size > Integer'Size then
- Item := Num (Aux.Get_LLD (TFT (File), Width, Scale));
- -- Item := Num'Fixed_Value (Aux.Get_LLD (TFT (File), Width, Scale));
- -- above is what we should write, but gets assert error ???
-
+ Item := Num'Fixed_Value (Aux.Get_LLD (TFT (File), Width, Scale));
else
- Item := Num (Aux.Get_Dec (TFT (File), Width, Scale));
- -- Item := Num'Fixed_Value (Aux.Get_Dec (TFT (File), Width, Scale));
- -- above is what we should write, but gets assert error ???
+ Item := Num'Fixed_Value (Aux.Get_Dec (TFT (File), Width, Scale));
end if;
-
exception
when Constraint_Error => raise Data_Error;
end Get;
raise Layout_Error;
end if;
- if Pic.Radix_Position = Invalid_Position then
- Position := Answer'Last;
- else
- Position := Pic.Radix_Position - 1;
- end if;
+ Position :=
+ (if Pic.Radix_Position = Invalid_Position then Answer'Last
+ else Pic.Radix_Position - 1);
for J in reverse Attrs.Start_Of_Int .. Attrs.End_Of_Int loop
-
while Answer (Position) /= '9'
and then
Answer (Position) /= Pic.Floater
loop
if Answer (Position) = '_' then
Answer (Position) := Separator_Character;
-
elsif Answer (Position) = 'b' then
Answer (Position) := ' ';
end if;
-- No trailing digits, but now J may need to stick in a currency
-- symbol or sign.
- if Pic.Start_Currency = Invalid_Position then
- Position := Answer'Last + 1;
- else
- Position := Pic.Start_Currency;
- end if;
+ Position :=
+ (if Pic.Start_Currency = Invalid_Position then Answer'Last + 1
+ else Pic.Start_Currency);
end if;
for J in Position .. Answer'Last loop
-
if Pic.Start_Currency /= Invalid_Position and then
Answer (Pic.Start_Currency) = '#' then
Currency_Pos := 1;
@item -gnatw.i
@emph{Activate warnings on overlapping actuals.}
@cindex @option{-gnatw.i} (@command{gcc})
-This switch enables a warning on statically detectable overlapping actuals
-in a subprogram call, when one of the actuals is an in-out parameter, and
-the types of the actuals are not by-copy types.
+This switch enables a warning on statically detectable overlapping actuals in
+a subprogram call, when one of the actuals is an in-out parameter, and the
+types of the actuals are not by-copy types. The warning is off by default,
+and is not included under -gnatwa.
+
+@item -gnatw.I
+@emph{Disable warnings on overlapping actuals.}
+@cindex @option{-gnatw.I} (@command{gcc})
+This switch disables warnings on overlapping actuals in a call..
@item -gnatwj
@emph{Activate warnings on obsolescent features (Annex J).}
elsif Argv.all = "-eL" then
Follow_Links_For_Files := True;
+ Follow_Links_For_Dirs := True;
Remove_Switch (Arg_Num);
elsif Arg = "-eL" then
Opt.Follow_Links_For_Files := True;
+ Opt.Follow_Links_For_Dirs := True;
-- -f
return "";
end if;
- return Normalize_Pathname (Exec (Exec'First .. Path_Last - 4))
+ return Normalize_Pathname
+ (Exec (Exec'First .. Path_Last - 4),
+ Resolve_Links => Opt.Follow_Links_For_Dirs)
& Directory_Separator;
end Get_Install_Dir;
-- still valid if they point to a file which is outside of the project),
-- and that no directory has a name which is a valid source name.
- Follow_Links_For_Dirs : Boolean := True;
+ Follow_Links_For_Dirs : Boolean := False;
-- PROJECT MANAGER
-- Set to True if directories can be links in this project, and therefore
-- additional system calls must be performed to ensure that we always see
-- Appends Suffix to Name and returns the new name
function OS_Time_To_GNAT_Time (T : OS_Time) return Time_Stamp_Type;
- -- Convert OS format time to GNAT format time stamp
+ -- Convert OS format time to GNAT format time stamp.
+ -- Returns Empty_Time_Stamp if T is Invalid_Time
function Executable_Prefix return String_Ptr;
-- Returns the name of the root directory where the executable is stored.
Get_Name_String (Name);
- if not Is_Regular_File (Name_Buffer (1 .. Name_Len)) then
- return Empty_Time_Stamp;
- else
- Name_Buffer (Name_Len + 1) := ASCII.NUL;
- return OS_Time_To_GNAT_Time (File_Time_Stamp (Name_Buffer));
- end if;
+ -- File_Time_Stamp will always return Invalid_Time if the file does not
+ -- exist, and that OS_Time_To_GNAT_Time will convert that to
+ -- Empty_Time_Stamp. Therefore we do not need to first test whether the
+ -- file actually exists, which saves a system call
+
+ return OS_Time_To_GNAT_Time
+ (File_Time_Stamp (Name_Buffer (1 .. Name_Len)));
end File_Stamp;
function File_Stamp (Name : Path_Name_Type) return Time_Stamp_Type is
S : Second_Type;
begin
+ if T = Invalid_Time then
+ return Empty_Time_Stamp;
+ end if;
+
GM_Split (T, Y, Mo, D, H, Mn, S);
Make_Time_Stamp
(Year => Nat (Y),
with System.OS_Lib; use System.OS_Lib;
with Hostparm;
with Makeutl; use Makeutl;
+with Opt;
with Osint; use Osint;
with Prj.Tree; use Prj.Tree;
with Sdefault;
declare
New_Dir : constant String :=
- Normalize_Pathname (Name_Buffer (First .. Last));
+ Normalize_Pathname
+ (Name_Buffer (First .. Last),
+ Resolve_Links => Opt.Follow_Links_For_Dirs);
begin
-- If the absolute path was resolved and is different from
" alternatives must cover base type", Expr, Expr);
else
- Error_Msg_N ("expression is not static," &
+ Error_Msg_N ("subtype of expression is not static," &
" alternatives must cover base type!", Expr);
end if;
elsif not Is_Entity_Name (Expr) then
Error_Msg_N
- ("expression is not static, alternatives must cover base type!",
- Expr);
+ ("subtype of expression is not static, " &
+ "alternatives must cover base type!", Expr);
end if;
end Explain_Non_Static_Bound;
else
Follow_Links_For_Files := True;
+ Follow_Links_For_Dirs := True;
end if;
-- Processing for eS switch