Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer short circuit #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gpr/src/gpr-ali.adb
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ package body GPR.ALI is
-- sensitive. This ensures that we handle names in the canonical
-- lower case format, regardless of the actual case.

if Lower and not File_Names_Case_Sensitive then
if Lower and then not File_Names_Case_Sensitive then
Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
return Name_Find;
else
Expand Down
2 changes: 1 addition & 1 deletion gpr/src/gpr-compilation-slave.adb
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ package body GPR.Compilation.Slave is
-- We are past the random slave and we have found one slave ready,
-- stop search here.

exit Search_Slaves when K > Index and Result /= No_Slave;
exit Search_Slaves when K > Index and then Result /= No_Slave;
end loop Search_Slaves;

return Result;
Expand Down
8 changes: 4 additions & 4 deletions gpr/src/gpr-compilation-sync.adb
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ package body GPR.Compilation.Sync is
---------

entry Get
(Job : out Gpr_Data;
Files : out File_Data_Set.Vector;
Stop : out Boolean) when Jobs.Length > 0 or No_More is
(Job : out Gpr_Data; Files : out File_Data_Set.Vector;
Stop : out Boolean)
when Jobs.Length > 0 or else No_More is
begin
if Jobs.Length = 0 and then No_More then
Stop := True;

else
Stop := False;
Job := Jobs.First_Element;
Job := Jobs.First_Element;
Jobs.Delete_First;

if not PF_Initialized then
Expand Down
2 changes: 1 addition & 1 deletion gpr/src/gpr-conf.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,7 @@ package body GPR.Conf is
-- at the compiler roots.

Config_Try_Again :=
Fallback_Try_Again or Project_Node_Tree.Incomplete_With;
Fallback_Try_Again or else Project_Node_Tree.Incomplete_With;

Process_Project_And_Apply_Config
(Main_Project => Main_Project,
Expand Down
5 changes: 2 additions & 3 deletions gpr/src/gpr-dect.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1021,10 +1021,9 @@ package body GPR.Dect is
end loop When_Loop;

End_Case_Construction
(Check_All_Labels => not When_Others and not Quiet_Output,
(Check_All_Labels => not When_Others and then not Quiet_Output,
Case_Location => Location_Of (Case_Construction, In_Tree),
Flags => Flags,
String_Type => Present (String_Type));
Flags => Flags, String_Type => Present (String_Type));

Expect (Tok_End, "`END CASE`");
Remove_Next_End_Node;
Expand Down
4 changes: 2 additions & 2 deletions gpr/src/gpr-env.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,7 @@ package body GPR.Env is
-- For the object path, we make a distinction depending on
-- Including_Libraries.

if Objects_Path and Including_Libraries then
if Objects_Path and then Including_Libraries then
if Project.Objects_Path_File_With_Libs = No_Path then
Object_Path_Table.Init (Object_Paths);
Process_Object_Dirs := True;
Expand All @@ -1752,7 +1752,7 @@ package body GPR.Env is
-- If there is something to do, set Seen to False for all projects,
-- then call the recursive procedure Add for Project.

if Process_Source_Dirs or Process_Object_Dirs then
if Process_Source_Dirs or else Process_Object_Dirs then
For_All_Projects (Project, In_Tree, Dummy);
end if;

Expand Down
4 changes: 2 additions & 2 deletions gpr/src/gpr-err.adb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ package body GPR.Err is

-- Kill continuation if parent message killed

if Continuation and Last_Killed then
if Continuation and then Last_Killed then
return;
end if;

Expand Down Expand Up @@ -281,7 +281,7 @@ package body GPR.Err is

-- Brief Error mode

if Brief_Output or not Verbose_Mode then
if Brief_Output or else not Verbose_Mode then
E := First_Error_Msg;
Set_Standard_Error;

Expand Down
34 changes: 16 additions & 18 deletions gpr/src/gpr-knowledge.adb
Original file line number Diff line number Diff line change
Expand Up @@ -3962,44 +3962,42 @@ package body GPR.Knowledge is

if (not From_Extra_Dir or else El.Path = Comp.Path)
and then Filter_Match (Base, Comp => Comp, Filter => El.all)
and then (not Runtime_Specified or El.Runtime_Dir /= No_Name)
and then
(not Runtime_Specified or else El.Runtime_Dir /= No_Name)
then
Ncomp := new Compiler'(Comp);
if El.Runtime_Dir /= No_Name then
Ncomp.Runtime_Dir := El.Runtime_Dir;
Ncomp.Runtime := El.Runtime;
Ncomp.Runtime := El.Runtime;
end if;

if not Ncomp.Any_Runtime
and then Ncomp.Runtime = No_Name
if not Ncomp.Any_Runtime and then Ncomp.Runtime = No_Name
and then El.Runtime /= No_Name
then
Ncomp.Runtime := El.Runtime;
Ncomp.Runtime := El.Runtime;
end if;

Append (Iterator.Compilers, Ncomp);

if Current_Verbosity /= Default then
Put_Verbose
("Saving compiler for possible backtracking: "
& To_String (Base, Ncomp.all, As_Config_Arg => True)
& " (matches --config "
& To_String (Base, El.all, As_Config_Arg => True)
& ")");
("Saving compiler for possible backtracking: " &
To_String (Base, Ncomp.all, As_Config_Arg => True) &
" (matches --config " &
To_String (Base, El.all, As_Config_Arg => True) & ")");
end if;

if Iterator.Matched (Index) = Compiler_Lists.No_Element then
Iterator.Found := Iterator.Found + 1;

Put_Verbose
("Selecting it since this filter was not matched yet "
& Iterator.Found'Img & "/" & Iterator.Count'Img);
("Selecting it since this filter was not matched yet " &
Iterator.Found'Img & "/" & Iterator.Count'Img);

Iterator.Matched (Index) := Last (Iterator.Compilers);
Iterator.Matched (Index) := Last (Iterator.Compilers);
Iterator.Found_One (Index) := True;
Set_Selection
(Iterator.Compilers, Iterator.Matched (Index),
True);
(Iterator.Compilers, Iterator.Matched (Index), True);

-- Only keep those compilers that are not incompatible
-- (according to the knowledge base). It might happen that
Expand All @@ -4013,10 +4011,10 @@ package body GPR.Knowledge is
Set_Selection
(Iterator.Compilers, Iterator.Matched (Index), False);
Put_Verbose
("Compilers are not compatible, cancelling last"
& " compiler found");
("Compilers are not compatible, cancelling last" &
" compiler found");
Iterator.Matched (Index) := Compiler_Lists.No_Element;
Iterator.Found := Iterator.Found - 1;
Iterator.Found := Iterator.Found - 1;
end if;
end if;
end if;
Expand Down
44 changes: 20 additions & 24 deletions gpr/src/gpr-nmsc.adb
Original file line number Diff line number Diff line change
Expand Up @@ -4514,12 +4514,11 @@ package body GPR.Nmsc is
Check_Aggregate_Library_Dirs;
end if;

if Project.Library and not Data.In_Aggregate_Lib then
if Project.Library and then not Data.In_Aggregate_Lib then
-- Record the library name

Lib_Data_Table.Append
((Name => Project.Library_Name,
Proj => Project,
((Name => Project.Library_Name, Proj => Project,
Tree => Data.Tree));
end if;
end Check_Library_Attributes;
Expand Down Expand Up @@ -5513,7 +5512,7 @@ package body GPR.Nmsc is
end if;
end loop;

OK := OK and not Underline;
OK := OK and then not Underline;

if not OK then
Error_Msg
Expand Down Expand Up @@ -7130,28 +7129,25 @@ package body GPR.Nmsc is

Dir_Exists := Is_Directory (Full_Path_Name.all);

if not Must_Exist or Dir_Exists then
if not Must_Exist or else Dir_Exists then
declare
Normed : constant String :=
Normalize_Pathname
(Full_Path_Name.all,
Directory =>
The_Parent (The_Parent'First .. The_Parent_Last),
Resolve_Links => False,
Case_Sensitive => True);
Normalize_Pathname
(Full_Path_Name.all,
Directory =>
The_Parent (The_Parent'First .. The_Parent_Last),
Resolve_Links => False, Case_Sensitive => True);

Canonical_Path : constant String :=
Normalize_Pathname
(Normed,
Directory =>
The_Parent
(The_Parent'First .. The_Parent_Last),
Resolve_Links =>
Opt.Follow_Links_For_Dirs,
Case_Sensitive => False);
Normalize_Pathname
(Normed,
Directory =>
The_Parent (The_Parent'First .. The_Parent_Last),
Resolve_Links => Opt.Follow_Links_For_Dirs,
Case_Sensitive => False);

begin
Name_Len := Normed'Length;
Name_Len := Normed'Length;
Name_Buffer (1 .. Name_Len) := Normed;

-- Directories should always end with a directory separator
Expand All @@ -7162,7 +7158,7 @@ package body GPR.Nmsc is

Path.Display_Name := Name_Find;

Name_Len := Canonical_Path'Length;
Name_Len := Canonical_Path'Length;
Name_Buffer (1 .. Name_Len) := Canonical_Path;

if Name_Buffer (Name_Len) /= Directory_Separator then
Expand Down Expand Up @@ -8219,7 +8215,7 @@ package body GPR.Nmsc is

Recursive_Dirs.Set (Visited, Path.Name, True);

Success := Subdirectory_Matches (Path, Rank) or Success;
Success := Subdirectory_Matches (Path, Rank) or else Success;

Open (Dir, Path_Str);

Expand Down Expand Up @@ -8277,7 +8273,7 @@ package body GPR.Nmsc is
Path2.Name := Name_Find;

Success :=
Recursive_Find_Dirs (Path2, Rank) or Success;
Recursive_Find_Dirs (Path2, Rank) or else Success;
end if;
end if;
end;
Expand Down Expand Up @@ -9427,7 +9423,7 @@ package body GPR.Nmsc is
-- it as it has no sources by itself and so interface won't be
-- found.

if Project.Library and not In_Aggregate_Lib then
if Project.Library and then not In_Aggregate_Lib then
Check_Stand_Alone_Library (Project, Data);
end if;

Expand Down
18 changes: 7 additions & 11 deletions gpr/src/gpr-part.adb
Original file line number Diff line number Diff line change
Expand Up @@ -999,14 +999,14 @@ package body GPR.Part is
-- If we have one, get the project id of the limited
-- imported project file, and do not parse it.

if (In_Limited or Limited_Withs)
if (In_Limited or else Limited_Withs)
and then Project_Stack.Last > 1
then
declare
Canonical_Path_Name : Path_Name_Type;

begin
Name_Len := Resolved_Path'Length;
Name_Len := Resolved_Path'Length;
Name_Buffer (1 .. Name_Len) := Resolved_Path;
Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
Canonical_Path_Name := Name_Find;
Expand All @@ -1029,18 +1029,14 @@ package body GPR.Part is

if No (Withed_Project) then
Parse_Single_Project
(In_Tree => In_Tree,
Project => Withed_Project,
(In_Tree => In_Tree, Project => Withed_Project,
Extends_All => Extends_All,
Path_Name_Id => Imported_Path_Name_Id,
Extended => False,
From_Extended => From_Extended,
In_Limited => In_Limited or Limited_Withs,
Packages_To_Check => Packages_To_Check,
Depth => Depth,
Extended => False, From_Extended => From_Extended,
In_Limited => In_Limited or else Limited_Withs,
Packages_To_Check => Packages_To_Check, Depth => Depth,
Current_Dir => Current_Dir,
Is_Config_File => Is_Config_File,
Env => Env);
Is_Config_File => Is_Config_File, Env => Env);

else
Extends_All := Is_Extending_All (Withed_Project, In_Tree);
Expand Down
4 changes: 2 additions & 2 deletions gpr/src/gpr-util.adb
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ package body GPR.Util is
No_Message : Boolean := False;
Command : String := "") is
begin
if Flush_Messages and not No_Message then
if Flush_Messages and then not No_Message then
if Total_Errors_Detected /= 0 or else Warnings_Detected /= 0 then
Err.Finalize;
end if;
Expand Down Expand Up @@ -2015,7 +2015,7 @@ package body GPR.Util is
begin
-- Nothing to do if source record has already been fully initialized

if Source.Initialized and not Always then
if Source.Initialized and then not Always then
return;
end if;

Expand Down
10 changes: 5 additions & 5 deletions gpr/src/gpr_build_util.adb
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ package body Gpr_Build_Util is

Close (Mapping_FD, Status);

OK := OK and Status;
OK := OK and then Status;
end if;

-- If the creation of the mapping file was successful, we add the switch
Expand Down Expand Up @@ -2369,10 +2369,10 @@ package body Gpr_Build_Util is
Has_Mains
or else (Root_Project.Library
and then Root_Project.Standalone_Library /= No);
Data.Need_Compilation := All_Phases or Option_Compile_Only;
Data.Need_Binding := All_Phases or Option_Bind_Only;
Data.Need_Linking := (All_Phases or Option_Link_Only)
and Has_Mains;
Data.Need_Compilation := All_Phases or else Option_Compile_Only;
Data.Need_Binding := All_Phases or else Option_Bind_Only;
Data.Need_Linking :=
(All_Phases or else Option_Link_Only) and then Has_Mains;
end if;

if Current_Verbosity = High then
Expand Down
2 changes: 1 addition & 1 deletion src/gprbind.adb
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ begin
end if;

if Return_Code /= 0 then
if Delete_Temp_Files and not Dash_O_File_Specified then
if Delete_Temp_Files and then not Dash_O_File_Specified then
Delete_File (Get_Name_String (Objects_Path), Success);
end if;

Expand Down
4 changes: 2 additions & 2 deletions src/gprbuild-compile.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1933,7 +1933,7 @@ package body Gprbuild.Compile is
end if;
end if;

if Compilation_OK and Dep_File_OK then
if Compilation_OK and then Dep_File_OK then
Create (Dep_File, Dep_Path);
Put (Dep_File, Object_Path.all);
Put (Dep_File, ": ");
Expand Down Expand Up @@ -2143,7 +2143,7 @@ package body Gprbuild.Compile is
Add_Option_Internal_Codepeer
(Value => Get_Name_String (Nam_Nod.Name),
To => Compilation_Options,
Display => First or Opt.Verbose_Mode);
Display => First or else Opt.Verbose_Mode);
First := False;
end if;

Expand Down
Loading