From 1637a1dc1365e167a2ba9b56f467c593a40046bf Mon Sep 17 00:00:00 2001 From: Pierre van de Laar Date: Thu, 22 Dec 2022 08:02:20 +0100 Subject: [PATCH] prefer membership tests --- gpr/src/gpr-ali.adb | 32 ++--- gpr/src/gpr-attr.adb | 4 +- gpr/src/gpr-conf.adb | 14 +- gpr/src/gpr-dect.adb | 64 ++++----- gpr/src/gpr-err-scanner.adb | 230 +++++++++++++++----------------- gpr/src/gpr-err.adb | 22 ++- gpr/src/gpr-erroutc.adb | 17 +-- gpr/src/gpr-knowledge.adb | 86 ++++++------ gpr/src/gpr-names.adb | 4 +- gpr/src/gpr-nmsc.adb | 76 +++++------ gpr/src/gpr-part.adb | 11 +- gpr/src/gpr-proc.adb | 4 +- gpr/src/gpr-sinput.adb | 5 +- gpr/src/gpr-tree.adb | 31 ++--- gpr/src/gpr-util-aux.adb | 22 ++- gpr/src/gpr-util.adb | 29 ++-- gpr/src/gpr_build_util.adb | 127 +++++++++--------- src/gprbind.adb | 18 +-- src/gprbuild-compile.adb | 3 +- src/gprbuild-link.adb | 14 +- src/gprbuild-main.adb | 45 +++---- src/gprbuild.adb | 20 ++- src/gprclean.adb | 24 ++-- src/gprconfig-main.adb | 4 +- src/gprinstall-main.adb | 2 +- src/gprlib-build_shared_lib.adb | 8 +- src/gprlib.adb | 11 +- src/gprls-main.adb | 3 +- src/gprname.adb | 14 +- 29 files changed, 407 insertions(+), 537 deletions(-) diff --git a/gpr/src/gpr-ali.adb b/gpr/src/gpr-ali.adb index 83fa40c73..dc9f2b599 100644 --- a/gpr/src/gpr-ali.adb +++ b/gpr/src/gpr-ali.adb @@ -277,7 +277,7 @@ package body GPR.ALI is while C not in 'A' .. 'Z' or else not Known_ALI_Lines (C) loop - if C = CR or else C = LF then + if C in CR | LF then Skip_Next_Line; C := Nextc; @@ -997,15 +997,15 @@ package body GPR.ALI is -- Version field - if C in '0' .. '9' or else C in 'a' .. 'f' then + if C in '0' .. '9' | 'a' .. 'f' then Units.Table (Units.Last).Version (1) := C; for J in 2 .. 8 loop - C := Getc; + C := Getc; Units.Table (Units.Last).Version (J) := C; end loop; - -- BD/BN parameters + -- BD/BN parameters elsif C = 'B' then C := Getc; @@ -1019,7 +1019,7 @@ package body GPR.ALI is Units.Table (Units.Last).Body_Needed_For_SAL := True; end if; - -- DE parameter (Dynamic elaboration checks) + -- DE parameter (Dynamic elaboration checks) elsif C = 'D' then C := Getc; @@ -1029,7 +1029,7 @@ package body GPR.ALI is Units.Table (Units.Last).Dynamic_Elab := True; end if; - -- EB/EE parameters + -- EB/EE parameters elsif C = 'E' then C := Getc; @@ -1042,7 +1042,7 @@ package body GPR.ALI is Check_At_End_Of_Field; - -- GE parameter (generic) + -- GE parameter (generic) elsif C = 'G' then C := Getc; @@ -1052,7 +1052,7 @@ package body GPR.ALI is Units.Table (Units.Last).Is_Generic := True; end if; - -- IL/IS/IU parameters + -- IL/IS/IU parameters elsif C = 'I' then C := Getc; @@ -1067,7 +1067,7 @@ package body GPR.ALI is Check_At_End_Of_Field; - -- KM/KU parameters + -- KM/KU parameters elsif C = 'K' then C := Getc; @@ -1080,7 +1080,7 @@ package body GPR.ALI is Check_At_End_Of_Field; - -- NE parameter + -- NE parameter elsif C = 'N' then C := Getc; @@ -1090,7 +1090,7 @@ package body GPR.ALI is Check_At_End_Of_Field; end if; - -- PF/PR/PU/PK parameters + -- PF/PR/PU/PK parameters elsif C = 'P' then C := Getc; @@ -1107,18 +1107,18 @@ package body GPR.ALI is Check_At_End_Of_Field; - -- OL/OO/OS/OT parameters + -- OL/OO/OS/OT parameters elsif C = 'O' then C := Getc; - if C = 'L' or else C = 'O' or else C = 'S' or else C = 'T' then + if C in 'L' | 'O' | 'S' | 'T' then Units.Table (Units.Last).Optimize_Alignment := C; end if; Check_At_End_Of_Field; - -- RC/RT parameters + -- RC/RT parameters elsif C = 'R' then C := Getc; @@ -1133,7 +1133,7 @@ package body GPR.ALI is Check_At_End_Of_Field; - -- SE/SP/SU parameters + -- SE/SP/SU parameters elsif C = 'S' then C := Getc; @@ -1161,7 +1161,7 @@ package body GPR.ALI is With_Loop : loop Check_Unknown_Line; - exit With_Loop when C /= 'W' and then C /= 'Y' and then C /= 'Z'; + exit With_Loop when C not in 'W' | 'Y' | 'Z'; if Ignore ('W') then Skip_Next_Line; diff --git a/gpr/src/gpr-attr.adb b/gpr/src/gpr-attr.adb index 9383cba70..ec58cbde0 100644 --- a/gpr/src/gpr-attr.adb +++ b/gpr/src/gpr-attr.adb @@ -1825,7 +1825,7 @@ package body GPR.Attr is (Pkg : Package_Node_Id) return Attribute_Node_Id is begin - if Pkg = Empty_Package or else Pkg = Unknown_Package then + if Pkg in Empty_Package | Unknown_Package then return Empty_Attribute; else return @@ -1839,7 +1839,7 @@ package body GPR.Attr is function Is_Package_Known (Pkg : Package_Node_Id) return Boolean is begin - if Pkg = Empty_Package or else Pkg = Unknown_Package then + if Pkg in Empty_Package | Unknown_Package then return False; else return Package_Attributes.Table (Pkg.Value).Known; diff --git a/gpr/src/gpr-conf.adb b/gpr/src/gpr-conf.adb index 3a017b4ed..2ee23b7b6 100644 --- a/gpr/src/gpr-conf.adb +++ b/gpr/src/gpr-conf.adb @@ -534,12 +534,12 @@ package body GPR.Conf is end if; OK := - Target = "" - or else Target = "native" - or else - (Tgt_Name /= No_Name - and then (Tgt_Name = Empty_String - or else Target = Get_Name_String (Tgt_Name))); + Target in "" | "native" + or else + (Tgt_Name /= No_Name + and then + (Tgt_Name = Empty_String + or else Target = Get_Name_String (Tgt_Name))); if not OK then if Autoconf_Specified then @@ -1423,7 +1423,7 @@ package body GPR.Conf is function Is_Base_Name (Path : String) return Boolean is begin for I in Path'Range loop - if Path (I) = Directory_Separator or else Path (I) = '/' then + if Path (I) in Directory_Separator | '/' then return False; end if; end loop; diff --git a/gpr/src/gpr-dect.adb b/gpr/src/gpr-dect.adb index e6281bca3..ef9e45d47 100644 --- a/gpr/src/gpr-dect.adb +++ b/gpr/src/gpr-dect.adb @@ -226,25 +226,18 @@ package body GPR.Dect is -- is not allowed in aggregate projects, but is allowed in aggregate -- library projects. - if ((Qualif = Aggregate - or else - Qualif = Aggregate_Library) - and then - (Name = Name_Naming or else - Name = Name_Compiler or else - Name = Name_Linker)) + if + ((Qualif in Aggregate | Aggregate_Library) + and then (Name in Name_Naming | Name_Compiler | Name_Linker)) or else - (Qualif = Aggregate - and then - (Name = Name_Install or else - Name = Name_Binder)) + (Qualif = Aggregate and then (Name in Name_Install | Name_Binder)) then Error_Msg_Name_1 := Name; Error_Msg (Flags, - "package %% cannot be used in aggregate" - & (if Qualif = Aggregate then "" else " library") & " projects", + "package %% cannot be used in aggregate" & + (if Qualif = Aggregate then "" else " library") & " projects", Location_Of (Current_Package, In_Tree)); end if; end Check_Package_Allowed; @@ -266,49 +259,40 @@ package body GPR.Dect is begin case Qualif is when Aggregate | Aggregate_Library => - if Name = Snames.Name_Languages - or else Name = Snames.Name_Source_Files - or else Name = Snames.Name_Source_List_File - or else Name = Snames.Name_Locally_Removed_Files - or else Name = Snames.Name_Excluded_Source_Files - or else Name = Snames.Name_Excluded_Source_List_File - or else Name = Snames.Name_Exec_Dir - or else Name = Snames.Name_Source_Dirs - or else Name = Snames.Name_Inherit_Source_Path + if Name in Snames.Name_Languages | Snames.Name_Source_Files | + Snames.Name_Source_List_File | + Snames.Name_Locally_Removed_Files | + Snames.Name_Excluded_Source_Files | + Snames.Name_Excluded_Source_List_File | + Snames.Name_Exec_Dir | Snames.Name_Source_Dirs | + Snames.Name_Inherit_Source_Path or else - (Qualif = Aggregate and then Name = Snames.Name_Interfaces) + (Qualif = Aggregate and then Name = Snames.Name_Interfaces) or else - (Qualif = Aggregate and then Name = Snames.Name_Library_Dir) + (Qualif = Aggregate and then Name = Snames.Name_Library_Dir) or else - (Qualif = Aggregate and then Name = Snames.Name_Library_Name) - or else Name = Snames.Name_Main - or else Name = Snames.Name_Roots + (Qualif = Aggregate and then Name = Snames.Name_Library_Name) + or else Name = Snames.Name_Main or else Name = Snames.Name_Roots or else Name = Snames.Name_Externally_Built or else Name = Snames.Name_Executable or else Name = Snames.Name_Executable_Suffix or else - (Qualif = Aggregate and then - Name = Snames.Name_Default_Switches) + (Qualif = Aggregate and then Name = Snames.Name_Default_Switches) then Error_Msg_Name_1 := Name; Error_Msg - (Flags, - "%% is not valid in aggregate projects", - Location_Of (Attribute, In_Tree), - Always => True); + (Flags, "%% is not valid in aggregate projects", + Location_Of (Attribute, In_Tree), Always => True); end if; when others => - if Name = Snames.Name_Project_Files - or else Name = Snames.Name_Project_Path - or else Name = Snames.Name_External + if Name in Snames.Name_Project_Files | Snames.Name_Project_Path | + Snames.Name_External then Error_Msg_Name_1 := Name; Error_Msg - (Flags, - "%% is only valid in aggregate projects", - Location_Of (Attribute, In_Tree), - Always => True); + (Flags, "%% is only valid in aggregate projects", + Location_Of (Attribute, In_Tree), Always => True); end if; end case; end Check_Attribute_Allowed; diff --git a/gpr/src/gpr-err-scanner.adb b/gpr/src/gpr-err-scanner.adb index ec5932e10..e8222856d 100644 --- a/gpr/src/gpr-err-scanner.adb +++ b/gpr/src/gpr-err-scanner.adb @@ -651,18 +651,15 @@ package body Scanner is -- bug otherwise arising from "x : integer range 1 .. 10:= 6;" elsif C = '#' - or else (C = ':' and then - (Source (Scan_Ptr + 1) = '.' - or else - Source (Scan_Ptr + 1) in '0' .. '9' - or else - Source (Scan_Ptr + 1) in 'A' .. 'Z' - or else - Source (Scan_Ptr + 1) in 'a' .. 'z')) + or else + (C = ':' + and then + (Source (Scan_Ptr + 1) in '.' | '0' .. '9' | 'A' .. 'Z' | + 'a' .. 'z')) then Accumulate_Checksum (C); Base_Char := C; - Base := Int_Value; + Base := Int_Value; if Base < 2 or else Base > 16 then Base := 16; @@ -672,9 +669,9 @@ package body Scanner is -- Scan out extended integer [. integer] - C := Source (Scan_Ptr); + C := Source (Scan_Ptr); Int_Value := 0; - Scale := 0; + Scale := 0; loop if C in '0' .. '9' then @@ -697,31 +694,31 @@ package body Scanner is end if; Int_Value := Max_Int (Int_Value * Base + Extended_Digit_Value); - Scale := Scale - 1; - Scan_Ptr := Scan_Ptr + 1; - C := Source (Scan_Ptr); + Scale := Scale - 1; + Scan_Ptr := Scan_Ptr + 1; + C := Source (Scan_Ptr); if C = '_' then loop Accumulate_Checksum ('_'); Scan_Ptr := Scan_Ptr + 1; - C := Source (Scan_Ptr); + C := Source (Scan_Ptr); exit when C /= '_'; end loop; elsif C = '.' then Accumulate_Checksum ('.'); - Scan_Ptr := Scan_Ptr + 1; - C := Source (Scan_Ptr); + Scan_Ptr := Scan_Ptr + 1; + C := Source (Scan_Ptr); Point_Scanned := True; - Scale := 0; + Scale := 0; elsif C = Base_Char then Accumulate_Checksum (C); Scan_Ptr := Scan_Ptr + 1; exit; - elsif C = '#' or else C = ':' then + elsif C in '#' | ':' then Scan_Ptr := Scan_Ptr + 1; exit; @@ -740,9 +737,9 @@ package body Scanner is Scale := 0; end if; - if Source (Scan_Ptr) = 'e' or else Source (Scan_Ptr) = 'E' then + if Source (Scan_Ptr) in 'e' | 'E' then Accumulate_Checksum ('e'); - Scan_Ptr := Scan_Ptr + 1; + Scan_Ptr := Scan_Ptr + 1; Exponent_Is_Negative := False; if Source (Scan_Ptr) = '+' then @@ -1369,32 +1366,29 @@ package body Scanner is -- cases, like A."abs"'Address, and also gives better error -- behavior for impossible cases like 123'xxx). - if Prev_Token = Tok_Identifier - or else Prev_Token = Tok_Right_Paren - or else Prev_Token = Tok_All - or else Prev_Token = Tok_Project - or else Prev_Token in Token_Class_Literal - then - Token := Tok_Apostrophe; - return; + if Prev_Token in Tok_Identifier | Tok_Right_Paren | Tok_All | + Tok_Project | Token_Class_Literal + then + Token := Tok_Apostrophe; + return; - -- Otherwise the apostrophe starts a character literal + -- Otherwise the apostrophe starts a character literal - else - -- Case of wide character literal + else + -- Case of wide character literal - if Start_Of_Wide_Character then - Wptr := Scan_Ptr; - Scan_Wide (Source, Scan_Ptr, Code, Err); - Accumulate_Checksum (Code); + if Start_Of_Wide_Character then + Wptr := Scan_Ptr; + Scan_Wide (Source, Scan_Ptr, Code, Err); + Accumulate_Checksum (Code); - if Err then - Code := Character'Pos (' '); - end if; + if Err then + Code := Character'Pos (' '); + end if; - if Source (Scan_Ptr) = ''' then - Scan_Ptr := Scan_Ptr + 1; - end if; + if Source (Scan_Ptr) = ''' then + Scan_Ptr := Scan_Ptr + 1; + end if; -- If we do not find a closing quote in the expected place then -- assume that we have a misguided attempt at a string literal. @@ -1402,39 +1396,39 @@ package body Scanner is -- However, if previous token is RANGE, then we return an -- apostrophe instead since this gives better error recovery - elsif Source (Scan_Ptr + 1) /= ''' then - if Prev_Token = Tok_Range then - Token := Tok_Apostrophe; - return; + elsif Source (Scan_Ptr + 1) /= ''' then + if Prev_Token = Tok_Range then + Token := Tok_Apostrophe; + return; - else - Scan_Ptr := Scan_Ptr - 1; - Error_Msg - ("strings are delimited by double quote character", - Scan_Ptr); - Slit; - Post_Scan; - return; - end if; + else + Scan_Ptr := Scan_Ptr - 1; + Error_Msg + ("strings are delimited by double quote character", + Scan_Ptr); + Slit; + Post_Scan; + return; + end if; - -- Otherwise we have a (non-wide) character literal + -- Otherwise we have a (non-wide) character literal - else - Accumulate_Checksum (Source (Scan_Ptr)); + else + Accumulate_Checksum (Source (Scan_Ptr)); - Code := Get_Char_Code (Source (Scan_Ptr)); - Scan_Ptr := Scan_Ptr + 2; - end if; + Code := Get_Char_Code (Source (Scan_Ptr)); + Scan_Ptr := Scan_Ptr + 2; + end if; -- Fall through here with Scan_Ptr updated past the closing -- quote, and Code set to the Char_Code value for the literal - Accumulate_Checksum ('''); - Token := Tok_Char_Literal; - Character_Code := Code; - Post_Scan; - return; - end if; + Accumulate_Checksum ('''); + Token := Tok_Char_Literal; + Character_Code := Code; + Post_Scan; + return; + end if; end Char_Literal_Case; -- Right parenthesis @@ -1534,37 +1528,35 @@ package body Scanner is begin -- OK literal if digit followed by digit or underscore - if C in '0' .. '9' or else C = '_' then - null; + if C in '0' .. '9' | '_' then + null; - -- OK literal if digit not followed by identifier char + -- OK literal if digit not followed by identifier char - elsif not Identifier_Char (C) then - null; + elsif not Identifier_Char (C) then + null; -- OK literal if digit followed by e/E followed by digit/sign. -- We also allow underscore after the E, which is an error, but -- better handled by Nlit than deciding this is an identifier. - elsif (C = 'e' or else C = 'E') - and then (Source (Scan_Ptr + 2) in '0' .. '9' - or else Source (Scan_Ptr + 2) = '+' - or else Source (Scan_Ptr + 2) = '-' - or else Source (Scan_Ptr + 2) = '_') - then - null; + elsif (C in 'e' | 'E') + and then + (Source (Scan_Ptr + 2) in '0' .. '9' | '+' | '-' | '_') + then + null; - -- Here we have what really looks like an identifier that - -- starts with a digit, so give error msg. + -- Here we have what really looks like an identifier that + -- starts with a digit, so give error msg. - else - Name_Len := 1; - Underline_Found := False; - Name_Buffer (1) := Source (Scan_Ptr); - Accumulate_Checksum (Name_Buffer (1)); - Scan_Ptr := Scan_Ptr + 1; - goto Scan_Identifier; - end if; + else + Name_Len := 1; + Underline_Found := False; + Name_Buffer (1) := Source (Scan_Ptr); + Accumulate_Checksum (Name_Buffer (1)); + Scan_Ptr := Scan_Ptr + 1; + goto Scan_Identifier; + end if; end; -- Here we have an OK integer literal @@ -1700,52 +1692,46 @@ package body Scanner is -- Skip to end of line loop - if Source (Scan_Ptr) in Graphic_Character - or else - Source (Scan_Ptr) = HT - then - Scan_Ptr := Scan_Ptr + 1; + if Source (Scan_Ptr) in Graphic_Character | HT then + Scan_Ptr := Scan_Ptr + 1; - -- Done if line terminator or EOF + -- Done if line terminator or EOF - elsif Source (Scan_Ptr) in Line_Terminator - or else - Source (Scan_Ptr) = EOF - then - exit; + elsif Source (Scan_Ptr) in Line_Terminator | EOF then + exit; -- If we have a wide character, we have to scan it out, -- because it might be a legitimate line terminator - elsif Start_Of_Wide_Character then - declare - Wptr : constant Source_Ptr := Scan_Ptr; - Code : Char_Code; - Err : Boolean; + elsif Start_Of_Wide_Character then + declare + Wptr : constant Source_Ptr := Scan_Ptr; + Code : Char_Code; + Err : Boolean; - begin - Scan_Wide (Source, Scan_Ptr, Code, Err); + begin + Scan_Wide (Source, Scan_Ptr, Code, Err); -- If not well formed wide character, then just skip -- past it and ignore it. - if Err then - Scan_Ptr := Wptr + 1; + if Err then + Scan_Ptr := Wptr + 1; - -- If UTF_32 terminator, terminate comment scan + -- If UTF_32 terminator, terminate comment scan - elsif Is_UTF_32_Line_Terminator (UTF_32 (Code)) then - Scan_Ptr := Wptr; - exit; - end if; - end; + elsif Is_UTF_32_Line_Terminator (UTF_32 (Code)) then + Scan_Ptr := Wptr; + exit; + end if; + end; -- Else keep going (don't worry about bad comment chars -- in this context, we just want to find the end of line. - else - Scan_Ptr := Scan_Ptr + 1; - end if; + else + Scan_Ptr := Scan_Ptr + 1; + end if; end loop; elsif Source (Scan_Ptr) = '$' then @@ -1913,9 +1899,7 @@ package body Scanner is -- digits, which we expect to be the most common characters. loop - if Source (Scan_Ptr) in 'a' .. 'z' - or else Source (Scan_Ptr) in '0' .. '9' - then + if Source (Scan_Ptr) in 'a' .. 'z' | '0' .. '9' then Name_Buffer (Name_Len + 1) := Source (Scan_Ptr); Accumulate_Checksum (Source (Scan_Ptr)); @@ -2350,8 +2334,8 @@ package body Scanner is elsif Chr = LF then P := P + 1; - elsif Chr = FF or else Chr = VT then - P := P + 1; + elsif Chr in FF | VT then + P := P + 1; Physical := False; return; diff --git a/gpr/src/gpr-err.adb b/gpr/src/gpr-err.adb index 883179594..b8c8f0e7d 100644 --- a/gpr/src/gpr-err.adb +++ b/gpr/src/gpr-err.adb @@ -522,7 +522,7 @@ package body GPR.Err is loop C := Source_Text (Sfile) (S); - exit when C = ASCII.LF or else C = ASCII.CR or else C = EOF; + exit when C in ASCII.LF | ASCII.CR | EOF; if Errs then Write_Char (C); @@ -550,9 +550,7 @@ package body GPR.Err is if Debug_Tokens then Write_Line (Token_Type'Image (Token)); - if Token = Tok_Identifier - or else Token = Tok_String_Literal - then + if Token in Tok_Identifier | Tok_String_Literal then Write_Line (" " & Get_Name_String (Token_Name)); end if; end if; @@ -665,10 +663,10 @@ package body GPR.Err is -- Warning message (? or < insertion sequence) - elsif Msg (J) = '?' or else Msg (J) = '<' then - Is_Warning_Msg := Msg (J) = '?' or else Error_Msg_Warn; + elsif Msg (J) in '?' | '<' then + Is_Warning_Msg := Msg (J) = '?' or else Error_Msg_Warn; Warning_Msg_Char := ' '; - J := J + 1; + J := J + 1; if Is_Warning_Msg then declare @@ -677,16 +675,14 @@ package body GPR.Err is if J <= Msg'Last then if Msg (J) = C then Warning_Msg_Char := '?'; - J := J + 1; + J := J + 1; elsif J < Msg'Last and then Msg (J + 1) = C - and then (Msg (J) in 'a' .. 'z' or else - Msg (J) in 'A' .. 'Z' or else - Msg (J) = '*' or else - Msg (J) = '$') + and then + (Msg (J) in 'a' .. 'z' | 'A' .. 'Z' | '*' | '$') then Warning_Msg_Char := Msg (J); - J := J + 2; + J := J + 2; end if; end if; end; diff --git a/gpr/src/gpr-erroutc.adb b/gpr/src/gpr-erroutc.adb index 85cd757c6..5a5902cde 100644 --- a/gpr/src/gpr-erroutc.adb +++ b/gpr/src/gpr-erroutc.adb @@ -252,14 +252,9 @@ package body GPR.Erroutc is -- legal Ada program. when WCEM_Brackets => - return P <= S'Last - 2 - and then S (P) = '[' - and then S (P + 1) = '"' - and then (S (P + 2) in '0' .. '9' - or else - S (P + 2) in 'a' .. 'f' - or else - S (P + 2) in 'A' .. 'F'); + return + P <= S'Last - 2 and then S (P) = '[' and then S (P + 1) = '"' + and then (S (P + 2) in '0' .. '9' | 'a' .. 'f' | 'A' .. 'F'); -- All other encoding methods use the upper bit set in the first -- character to uniquely represent a wide character. @@ -645,13 +640,11 @@ package body GPR.Erroutc is -- If operator name or character literal name, just print it as is -- Also print as is if it ends in a right paren (case of x'val(nnn)) - if Name_Buffer (1) = '"' - or else Name_Buffer (1) = ''' - or else Name_Buffer (Name_Len) = ')' + if Name_Buffer (1) in '"' | ''' or else Name_Buffer (Name_Len) = ')' then Set_Msg_Name_Buffer; - -- Else output with surrounding quotes in proper casing mode + -- Else output with surrounding quotes in proper casing mode else Set_Casing (Mixed_Case); diff --git a/gpr/src/gpr-knowledge.adb b/gpr/src/gpr-knowledge.adb index b1bc4bb43..2d5bcc6b4 100644 --- a/gpr/src/gpr-knowledge.adb +++ b/gpr/src/gpr-knowledge.adb @@ -567,9 +567,7 @@ package body GPR.Knowledge is begin for S in Static_Value'Range loop - if Static_Value (S) /= ' ' - and then Static_Value (S) /= ASCII.LF - then + if Static_Value (S) not in ' ' | ASCII.LF then Has_Static := True; exit; end if; @@ -2258,20 +2256,16 @@ package body GPR.Knowledge is if not Allow_Empty_Elements then while First <= Words'Last - and then (Words (First) = Separator1 - or else Words (First) = Separator2) + and then (Words (First) in Separator1 | Separator2) loop First := First + 1; end loop; end if; while First <= Words'Last loop - if Words (First) /= Separator1 - and then Words (First) /= Separator2 - then + if Words (First) not in Separator1 | Separator2 then Last := First + 1; - while Last <= Words'Last - and then Words (Last) /= Separator1 + while Last <= Words'Last and then Words (Last) /= Separator1 and then Words (Last) /= Separator2 loop Last := Last + 1; @@ -3164,18 +3158,20 @@ package body GPR.Knowledge is return False; end if; - if Filter.Path /= No_Name and then Filter.Path /= Comp.Path then + if Filter.Path not in No_Name | Comp.Path then if Current_Verbosity /= Default then - Put_Verbose ("Filter=" & To_String (Base, Filter, True) - & ": path does not match"); + Put_Verbose + ("Filter=" & To_String (Base, Filter, True) & + ": path does not match"); end if; return False; end if; - if Filter.Version /= No_Name and then Filter.Version /= Comp.Version then + if Filter.Version not in No_Name | Comp.Version then if Current_Verbosity /= Default then - Put_Verbose ("Filter=" & To_String (Base, Filter, True) - & ": version does not match"); + Put_Verbose + ("Filter=" & To_String (Base, Filter, True) & + ": version does not match"); end if; return False; end if; @@ -3208,12 +3204,11 @@ package body GPR.Knowledge is end if; - if Filter.Language_LC /= No_Name - and then Filter.Language_LC /= Comp.Language_LC - then + if Filter.Language_LC not in No_Name | Comp.Language_LC then if Current_Verbosity /= Default then - Put_Verbose ("Filter=" & To_String (Base, Filter, True) - & ": language does not match"); + Put_Verbose + ("Filter=" & To_String (Base, Filter, True) & + ": language does not match"); end if; return False; end if; @@ -3244,26 +3239,25 @@ package body GPR.Knowledge is Comp := Compiler_Lists.Element (C); if Comp.Selected - and then (Filter.Name = No_Name - or else - (Comp.Name /= No_Name - and then Match - (Filter.Name_Re.all, Get_Name_String (Comp.Name))) - or else Comp.Base_Name = Filter.Name) and then - (Filter.Version_Re = null - or else - (Comp.Version /= No_Name - and then Match - (Filter.Version_Re.all, Get_Name_String (Comp.Version)))) - and then (Filter.Runtime_Re = null - or else - (Comp.Runtime /= No_Name - and then Match - (Filter.Runtime_Re.all, - Runtime_Base_Name (Comp.Runtime)))) - and then (Filter.Language_LC = No_Name - or else Filter.Language_LC = Comp.Language_LC) + (Filter.Name = No_Name + or else + (Comp.Name /= No_Name + and then Match (Filter.Name_Re.all, Get_Name_String (Comp.Name))) + or else Comp.Base_Name = Filter.Name) + and then + (Filter.Version_Re = null + or else + (Comp.Version /= No_Name + and then Match + (Filter.Version_Re.all, Get_Name_String (Comp.Version)))) + and then + (Filter.Runtime_Re = null + or else + (Comp.Runtime /= No_Name + and then Match + (Filter.Runtime_Re.all, Runtime_Base_Name (Comp.Runtime)))) + and then (Filter.Language_LC in No_Name | Comp.Language_LC) then Matching_Compiler := Comp; Matched := True; @@ -3371,8 +3365,7 @@ package body GPR.Knowledge is procedure Skip_Spaces (Str : String; Index : in out Integer) is begin - while Index <= Str'Last - and then (Str (Index) = ' ' or else Str (Index) = ASCII.LF) + while Index <= Str'Last and then (Str (Index) in ' ' | ASCII.LF) loop Index := Index + 1; end loop; @@ -3380,8 +3373,7 @@ package body GPR.Knowledge is procedure Skip_Spaces_Backward (Str : String; Index : in out Integer) is begin - while Index >= Str'First - and then (Str (Index) = ' ' or else Str (Index) = ASCII.LF) + while Index >= Str'First and then (Str (Index) in ' ' | ASCII.LF) loop Index := Index - 1; end loop; @@ -3804,16 +3796,14 @@ package body GPR.Knowledge is Last : Natural := Name'Last; begin if Last > 7 and then - (Name (Last) = Directory_Separator or else - Name (Last) = '/') + (Name (Last) in Directory_Separator | '/') then Last := Last - 1; end if; if Last > 6 and then Name (Last - 5 .. Last) = "adalib" and then - (Name (Last - 6) = Directory_Separator or else - Name (Last - 6) = '/') + (Name (Last - 6) in Directory_Separator | '/') then Last := Last - 6; else diff --git a/gpr/src/gpr-names.adb b/gpr/src/gpr-names.adb index 83addf81a..be34b3826 100644 --- a/gpr/src/gpr-names.adb +++ b/gpr/src/gpr-names.adb @@ -573,11 +573,11 @@ package body GPR.Names is declare CC : constant Character := Get_Character (C); begin - if CC in 'a' .. 'z' or else CC in '0' .. '9' then + if CC in 'a' .. 'z' | '0' .. '9' then Name_Buffer (Name_Len) := CC; else Name_Buffer (Name_Len) := 'U'; - Name_Len := Name_Len + 2; + Name_Len := Name_Len + 2; Hex_Image (Word (C), Name_Buffer (Name_Len - 1 .. Name_Len)); end if; end; diff --git a/gpr/src/gpr-nmsc.adb b/gpr/src/gpr-nmsc.adb index 09f2c29f1..010e5a173 100644 --- a/gpr/src/gpr-nmsc.adb +++ b/gpr/src/gpr-nmsc.adb @@ -1632,15 +1632,15 @@ package body GPR.Nmsc is -- Attributes Required_Switches () and -- Leading_Required_Switches (. - elsif Current_Array.Name = Name_Required_Switches - or else - Current_Array.Name = Name_Leading_Required_Switches + elsif Current_Array.Name in Name_Required_Switches | + Name_Leading_Required_Switches then - Put (Into_List => - Lang_Index.Config. - Compiler_Leading_Required_Switches, - From_List => Element.Value.Values, - In_Tree => Data.Tree); + Put + (Into_List => + Lang_Index.Config + .Compiler_Leading_Required_Switches, + From_List => Element.Value.Values, + In_Tree => Data.Tree); -- Attribute Trailing_Required_Switches ( @@ -2022,30 +2022,26 @@ package body GPR.Nmsc is and then Element.Value.Kind = Single and then Element.Value.Value /= No_Name then - if Current_Array.Name = Name_Spec_Suffix - or else Current_Array.Name = Name_Specification_Suffix + if Current_Array.Name in Name_Spec_Suffix | + Name_Specification_Suffix then -- Attribute Spec_Suffix () Get_Name_String (Element.Value.Value); - Canonical_Case_File_Name - (Name_Buffer (1 .. Name_Len)); - Lang_Index.Config.Naming_Data.Spec_Suffix := - Name_Find; + Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len)); + Lang_Index.Config.Naming_Data.Spec_Suffix := Name_Find; - elsif Current_Array.Name = Name_Implementation_Suffix - or else Current_Array.Name = Name_Body_Suffix + elsif Current_Array.Name in Name_Implementation_Suffix | + Name_Body_Suffix then Get_Name_String (Element.Value.Value); - Canonical_Case_File_Name - (Name_Buffer (1 .. Name_Len)); + Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len)); -- Attribute Body_Suffix () - Lang_Index.Config.Naming_Data.Body_Suffix := - Name_Find; + Lang_Index.Config.Naming_Data.Body_Suffix := Name_Find; Lang_Index.Config.Naming_Data.Separate_Suffix := Lang_Index.Config.Naming_Data.Body_Suffix; end if; @@ -5893,9 +5889,7 @@ package body GPR.Nmsc is exit; end if; - elsif Last_Underscore - and then (The_Name (Index) = '_' or else The_Name (Index) = '.') - then + elsif Last_Underscore and then (The_Name (Index) in '_' | '.') then -- Two underscores are illegal, and a dot cannot follow -- an underscore. @@ -6802,7 +6796,7 @@ package body GPR.Nmsc is S3 : constant Character := Name_Buffer (3); begin - if S1 = 'a' or else S1 = 'g' or else S1 = 'i' or else S1 = 's' then + if S1 in 'a' | 'g' | 'i' | 's' then -- Children or separates of packages A, G, I or S. These names -- are x__ ... or x~... (where x is a, g, i, or s). Both @@ -6811,7 +6805,7 @@ package body GPR.Nmsc is -- processing of the project files. if S2 = '_' and then S3 = '_' then - Name_Buffer (2) := '.'; + Name_Buffer (2) := '.'; Name_Buffer (3 .. Name_Len - 1) := Name_Buffer (4 .. Name_Len); Name_Len := Name_Len - 1; @@ -6847,13 +6841,9 @@ package body GPR.Nmsc is Unit_Exceptions_Htable.Get (Project.Unit_Exceptions, Unit); if Kind = Spec then - Masked := Unit_Except.Spec /= No_File - and then - Unit_Except.Spec /= File_Name; + Masked := Unit_Except.Spec not in No_File | File_Name; else - Masked := Unit_Except.Impl /= No_File - and then - Unit_Except.Impl /= File_Name; + Masked := Unit_Except.Impl not in No_File | File_Name; end if; if Masked then @@ -8227,14 +8217,13 @@ package body GPR.Nmsc is Read (Dir, Name, Last); exit when Last = 0; - if Name (1 .. Last) /= "." and then Name (1 .. Last) /= ".." then + if Name (1 .. Last) not in "." | ".." then declare Path_Name : constant String := - Normalize_Pathname - (Name => Name (1 .. Last), - Directory => Path_Str, - Resolve_Links => Resolve_Links) - & Directory_Separator; + Normalize_Pathname + (Name => Name (1 .. Last), Directory => Path_Str, + Resolve_Links => Resolve_Links) & + Directory_Separator; Path2 : Path_Information; OK : Boolean := True; @@ -8243,7 +8232,7 @@ package body GPR.Nmsc is if Is_Directory (Path_Name) then if Ignore /= Nil_String then declare - Dir_Name : String := Name (1 .. Last); + Dir_Name : String := Name (1 .. Last); List : String_List_Id := Ignore; begin @@ -8256,11 +8245,12 @@ package body GPR.Nmsc is Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len)); - File_Pattern := Compile - (Name_Buffer (1 .. Name_Len), - Glob => True, - Case_Sensitive => File_Names_Case_Sensitive - ); + File_Pattern := + Compile + (Name_Buffer (1 .. Name_Len), + Glob => True, + Case_Sensitive => + File_Names_Case_Sensitive); OK := not Match (Dir_Name, File_Pattern); exit when not OK; diff --git a/gpr/src/gpr-part.adb b/gpr/src/gpr-part.adb index 120311d9f..22bd0280d 100644 --- a/gpr/src/gpr-part.adb +++ b/gpr/src/gpr-part.adb @@ -796,7 +796,7 @@ package body GPR.Part is -- If Token is not WITH or LIMITED, there is no context clause, or we -- have exhausted the with clauses. - while Token = Tok_With or else Token = Tok_Limited loop + while Token in Tok_With | Tok_Limited loop Current_With_Node := Default_Project_Node (Of_Kind => N_With_Clause, In_Tree => In_Tree); Limited_With := Token = Tok_Limited; @@ -828,10 +828,8 @@ package body GPR.Part is -- Store path and location in table Withs Current_With := - (Path => Path_Name_Type (Token_Name), - Location => Token_Ptr, - Limited_With => Limited_With, - Node => Current_With_Node, + (Path => Path_Name_Type (Token_Name), Location => Token_Ptr, + Limited_With => Limited_With, Node => Current_With_Node, Next => No_With); Append_Current_With; @@ -1732,8 +1730,7 @@ package body GPR.Part is begin -- Check if we already have a project with this name - while Project_Name /= No_Name - and then Project_Name /= Name_Of_Project + while Project_Name not in No_Name | Name_Of_Project loop Name_And_Node := Tree_Private_Part.Projects_Htable.Get_Next diff --git a/gpr/src/gpr-proc.adb b/gpr/src/gpr-proc.adb index 71836fc1c..85530091b 100644 --- a/gpr/src/gpr-proc.adb +++ b/gpr/src/gpr-proc.adb @@ -3402,9 +3402,9 @@ package body GPR.Proc is Is_Encapsulated := Name_Buffer (1 .. Name_Len) = "encapsulated"; if Is_Encapsulated then - while List /= null and then List /= Mark loop + while List not in null | Mark loop List.From_Encapsulated_Lib := Is_Encapsulated; - List := List.Next; + List := List.Next; end loop; end if; diff --git a/gpr/src/gpr-sinput.adb b/gpr/src/gpr-sinput.adb index 47344bd24..e5c54ee45 100644 --- a/gpr/src/gpr-sinput.adb +++ b/gpr/src/gpr-sinput.adb @@ -710,9 +710,8 @@ package body GPR.Sinput is -- PRIVATE. The reason for ignoring PRIVATE is that it handles some -- error situations, and also to handle PRIVATE WITH in Ada 2005 mode. - while Token = Tok_With - or else Token = Tok_Private - or else (Token not in Token_Class_Cunit and then Token /= Tok_EOF) + while Token in Tok_With | Tok_Private + or else (Token not in Token_Class_Cunit | Tok_EOF) loop Err.Scanner.Scan; end loop; diff --git a/gpr/src/gpr-tree.adb b/gpr/src/gpr-tree.adb index d12750f8c..a4d616730 100644 --- a/gpr/src/gpr-tree.adb +++ b/gpr/src/gpr-tree.adb @@ -128,8 +128,7 @@ package body GPR.Tree is -- Create new N_Comment node - if (Where = After or else Where = After_End) - and then Token /= Tok_EOF + if (Where in After | After_End) and then Token /= Tok_EOF and then Comments.Table (J).Follows_Empty_Line then Comments.Table (1 .. Comments.Last - J + 1) := @@ -389,7 +388,7 @@ package body GPR.Tree is if not Node_With_Comments (Of_Kind) then Unkept_Comments := True; - elsif Of_Kind /= N_Comment and then Of_Kind /= N_Comment_Zones then + elsif Of_Kind not in N_Comment | N_Comment_Zones then Project_Node_Table.Increment_Last (In_Tree.Project_Nodes); In_Tree.Project_Nodes.Table @@ -407,11 +406,10 @@ package body GPR.Tree is Project_Node_Table.Increment_Last (In_Tree.Project_Nodes); In_Tree.Project_Nodes.Table (Project_Node_Table.Last (In_Tree.Project_Nodes)) := - (Kind => N_Comment, - Flag1 => Comments.Table (J).Follows_Empty_Line, - Flag2 => Comments.Table (J).Is_Followed_By_Empty_Line, - Value => Comments.Table (J).Value, - others => <>); + (Kind => N_Comment, + Flag1 => Comments.Table (J).Follows_Empty_Line, + Flag2 => Comments.Table (J).Is_Followed_By_Empty_Line, + Value => Comments.Table (J).Value, others => <>); -- Link it to the N_Comment_Zones node, if it is the first, -- otherwise to the previous one. @@ -1639,28 +1637,25 @@ package body GPR.Tree is when Tok_Comment => -- If this is a line comment, add it to the comment table - if Prev_Token = Tok_End_Of_Line - or else Prev_Token = No_Token - then + if Prev_Token in Tok_End_Of_Line | No_Token then Comments.Increment_Last; Comments.Table (Comments.Last) := - (Value => Comment_Id, - Follows_Empty_Line => Empty_Line, + (Value => Comment_Id, Follows_Empty_Line => Empty_Line, Is_Followed_By_Empty_Line => False); - -- Otherwise, it is an end of line comment. If there is an - -- end of line node specified, associate the comment with - -- this node. + -- Otherwise, it is an end of line comment. If there is an + -- end of line node specified, associate the comment with + -- this node. elsif Present (End_Of_Line_Node) then declare Zones : constant Project_Node_Id := - Comment_Zones_Of (End_Of_Line_Node, In_Tree); + Comment_Zones_Of (End_Of_Line_Node, In_Tree); begin In_Tree.Project_Nodes.Table (Zones).Value := Comment_Id; end; - -- Otherwise, this end of line node cannot be kept + -- Otherwise, this end of line node cannot be kept else Unkept_Comments := True; diff --git a/gpr/src/gpr-util-aux.adb b/gpr/src/gpr-util-aux.adb index b79e03f7d..e30de4a1e 100644 --- a/gpr/src/gpr-util-aux.adb +++ b/gpr/src/gpr-util-aux.adb @@ -342,7 +342,7 @@ package body GPR.Util.Aux is begin for J in Arg'Range loop - if Arg (J) = '\' or else Arg (J) = ' ' or else Arg (J) = '"' then + if Arg (J) in '\' | ' ' | '"' then Add ('\'); end if; @@ -357,12 +357,12 @@ package body GPR.Util.Aux is Tempdir.Create_Temp_File (Resp_File, Name => Name_1); Record_Temp_File (null, Name_1); - if Format = GNU or else Format = GCC_GNU then + if Format in GNU | GCC_GNU then Status := Write (Resp_File, GNU_Header'Address, GNU_Header'Length); end if; for Object of Objects loop - if Format = GNU or else Format = GCC_GNU then + if Format in GNU | GCC_GNU then Status := Write (Resp_File, GNU_Opening'Address, GNU_Opening'Length); end if; @@ -370,17 +370,16 @@ package body GPR.Util.Aux is Status := Write (Resp_File, Object (1)'Address, Object'Length); - if Format = GNU or else Format = GCC_GNU then + if Format in GNU | GCC_GNU then Status := Write (Resp_File, GNU_Closing'Address, GNU_Closing'Length); else - Status := - Write (Resp_File, ASCII.LF'Address, 1); + Status := Write (Resp_File, ASCII.LF'Address, 1); end if; end loop; - if Format = GNU or else Format = GCC_GNU then + if Format in GNU | GCC_GNU then Status := Write (Resp_File, GNU_Footer'Address, GNU_Footer'Length); end if; @@ -419,15 +418,10 @@ package body GPR.Util.Aux is Close (Resp_File, Closing_Status); end case; - if Format = GCC - or else Format = GCC_GNU - or else Format = GCC_Object_List - or else Format = GCC_Option_List - then + if Format in GCC | GCC_GNU | GCC_Object_List | GCC_Option_List then for Argument of Other_Arguments loop declare - Arg : constant String := - Modified_Argument (Argument); + Arg : constant String := Modified_Argument (Argument); begin Status := Write (Resp_File, Arg (1)'Address, Arg'Length); diff --git a/gpr/src/gpr-util.adb b/gpr/src/gpr-util.adb index cd3ad67c0..0ab4d3913 100644 --- a/gpr/src/gpr-util.adb +++ b/gpr/src/gpr-util.adb @@ -1736,7 +1736,7 @@ package body GPR.Util is if not File.End_Of_File_Reached then loop C := File.Buffer (File.Cursor); - exit when C = ASCII.CR or else C = ASCII.LF; + exit when C in ASCII.CR | ASCII.LF; Last := Last + 1; Line (Last) := C; Advance; @@ -1748,7 +1748,7 @@ package body GPR.Util is exit when Last = Line'Last; end loop; - if C = ASCII.CR or else C = ASCII.LF then + if C in ASCII.CR | ASCII.LF then Advance; if File.End_Of_File_Reached then @@ -2217,22 +2217,13 @@ package body GPR.Util is -- Definitely predefined if prefix is a- i- or s- followed by letter - if Name_Len >= 3 - and then Name_Buffer (2) = '-' - and then (Name_Buffer (1) = 'a' - or else - Name_Buffer (1) = 'g' - or else - Name_Buffer (1) = 'i' - or else - Name_Buffer (1) = 's') - and then (Name_Buffer (3) in 'a' .. 'z' - or else - Name_Buffer (3) in 'A' .. 'Z') + if Name_Len >= 3 and then Name_Buffer (2) = '-' + and then (Name_Buffer (1) in 'a' | 'g' | 'i' | 's') + and then (Name_Buffer (3) in 'a' .. 'z' | 'A' .. 'Z') then return True; - -- Definitely false if longer than 12 characters (8.3) + -- Definitely false if longer than 12 characters (8.3) elsif Name_Len > 8 then return False; @@ -2377,9 +2368,7 @@ package body GPR.Util is procedure Check_Project (P : Project_Id) is begin - if P.Qualifier = Aggregate - or else P.Qualifier = Aggregate_Library - then + if P.Qualifier in Aggregate | Aggregate_Library then declare List : Aggregated_Project_List := P.Aggregated_Projects; begin @@ -4376,7 +4365,7 @@ package body GPR.Util is is TS : constant Time_Stamp_Type := File_Stamp (Get_Path_Name_Id (Path)); begin - if TS /= Empty_Time_Stamp and then TS /= Stamp then + if TS not in Empty_Time_Stamp | Stamp then if Opt.Verbosity_Level > Opt.Low then Put_Line (" -> different time stamp for " & Path); @@ -5839,7 +5828,7 @@ package body GPR.Util is Verbose_Mode := False; Verbosity_Level := Opt.None; - elsif Verbosity = "verbose" or else Verbosity = "verbose_low" then + elsif Verbosity in "verbose" | "verbose_low" then Quiet_Output := False; Verbose_Mode := True; Verbosity_Level := Opt.Low; diff --git a/gpr/src/gpr_build_util.adb b/gpr/src/gpr_build_util.adb index 364d1796e..9fa15b4ee 100644 --- a/gpr/src/gpr_build_util.adb +++ b/gpr/src/gpr_build_util.adb @@ -304,13 +304,7 @@ package body Gpr_Build_Util is if Name_Len < 3 or else Name_Buffer (2) /= '-' or else - (Name_Buffer (1) /= 'a' - and then - Name_Buffer (1) /= 'g' - and then - Name_Buffer (1) /= 'i' - and then - Name_Buffer (1) /= 's') + (Name_Buffer (1) not in 'a' | 'g' | 'i' | 's') then if Opt.Verbosity_Level > Opt.Low then @@ -2447,15 +2441,12 @@ package body Gpr_Build_Util is (Builder_Package).Decl.Arrays, Shared => Project_Tree.Shared); - if Main_Project.Qualifier = Aggregate or else - Main_Project.Qualifier = Aggregate_Library - then - Other_Switches := GPR.Util.Value_Of - (Name => All_Other_Names, - Index => 0, - Attribute_Or_Array_Name => Name_Switches, - In_Package => Builder_Package, - Shared => Project_Tree.Shared); + if Main_Project.Qualifier in Aggregate | Aggregate_Library then + Other_Switches := + GPR.Util.Value_Of + (Name => All_Other_Names, Index => 0, + Attribute_Or_Array_Name => Name_Switches, + In_Package => Builder_Package, Shared => Project_Tree.Shared); else Mains.Reset; @@ -2470,8 +2461,8 @@ package body Gpr_Build_Util is begin while Language /= No_Language_Index loop - if Language.Config.Compiler_Driver - not in No_File | Empty_File + if Language.Config.Compiler_Driver not in No_File | + Empty_File then if Lang /= No_Name then Lang := No_Name; @@ -2493,13 +2484,14 @@ package body Gpr_Build_Util is if Source /= No_Source then if Switches_For_Main = Nil_Variable_Value then - Switches_For_Main := Value_Of - (Name => Name_Id (Source.File), - Attribute_Or_Array_Name => Name_Switches, - In_Package => Builder_Package, - Shared => Project_Tree.Shared, - Force_Lower_Case_Index => False, - Allow_Wildcards => True); + Switches_For_Main := + Value_Of + (Name => Name_Id (Source.File), + Attribute_Or_Array_Name => Name_Switches, + In_Package => Builder_Package, + Shared => Project_Tree.Shared, + Force_Lower_Case_Index => False, + Allow_Wildcards => True); -- If not found, try without extension. -- That's because gnatmake accepts truncated file @@ -2508,13 +2500,14 @@ package body Gpr_Build_Util is if Switches_For_Main = Nil_Variable_Value and then Source.Unit /= null then - Switches_For_Main := Value_Of - (Name => Source.Unit.Name, - Attribute_Or_Array_Name => Name_Switches, - In_Package => Builder_Package, - Shared => Project_Tree.Shared, - Force_Lower_Case_Index => False, - Allow_Wildcards => True); + Switches_For_Main := + Value_Of + (Name => Source.Unit.Name, + Attribute_Or_Array_Name => Name_Switches, + In_Package => Builder_Package, + Shared => Project_Tree.Shared, + Force_Lower_Case_Index => False, + Allow_Wildcards => True); end if; end if; @@ -2537,38 +2530,38 @@ package body Gpr_Build_Util is while Default_Switches_Array /= No_Array and then - Project_Tree.Shared.Arrays.Table - (Default_Switches_Array).Name /= Name_Default_Switches + Project_Tree.Shared.Arrays.Table (Default_Switches_Array) + .Name /= + Name_Default_Switches loop Default_Switches_Array := - Project_Tree.Shared.Arrays.Table - (Default_Switches_Array).Next; + Project_Tree.Shared.Arrays.Table (Default_Switches_Array) + .Next; end loop; if Lang /= No_Name then - Switches_For_Lang := GPR.Util.Value_Of - (Name => Lang, - Index => 0, - Attribute_Or_Array_Name => Name_Switches, - In_Package => Builder_Package, - Shared => Project_Tree.Shared, - Force_Lower_Case_Index => True); - - Defaults := GPR.Util.Value_Of - (Name => Lang, - Index => 0, - Attribute_Or_Array_Name => Name_Default_Switches, - In_Package => Builder_Package, - Shared => Project_Tree.Shared, - Force_Lower_Case_Index => True); + Switches_For_Lang := + GPR.Util.Value_Of + (Name => Lang, Index => 0, + Attribute_Or_Array_Name => Name_Switches, + In_Package => Builder_Package, + Shared => Project_Tree.Shared, + Force_Lower_Case_Index => True); + + Defaults := + GPR.Util.Value_Of + (Name => Lang, Index => 0, + Attribute_Or_Array_Name => Name_Default_Switches, + In_Package => Builder_Package, + Shared => Project_Tree.Shared, + Force_Lower_Case_Index => True); end if; - Other_Switches := GPR.Util.Value_Of - (Name => All_Other_Names, - Index => 0, - Attribute_Or_Array_Name => Name_Switches, - In_Package => Builder_Package, - Shared => Project_Tree.Shared); + Other_Switches := + GPR.Util.Value_Of + (Name => All_Other_Names, Index => 0, + Attribute_Or_Array_Name => Name_Switches, + In_Package => Builder_Package, Shared => Project_Tree.Shared); if not Quiet_Output and then Mains.Number_Of_Mains (Project_Tree) > 1 @@ -2579,24 +2572,24 @@ package body Gpr_Build_Util is if Switches_For_Lang /= Nil_Variable_Value then Put_Line - ("Warning: using Builder'Switches(""" - & Get_Name_String (Lang) - & """), as there are several mains"); + ("Warning: using Builder'Switches(""" & + Get_Name_String (Lang) & + """), as there are several mains"); elsif Other_Switches /= Nil_Variable_Value then Put_Line - ("Warning: using Builder'Switches(others), " - & "as there are several mains"); + ("Warning: using Builder'Switches(others), " & + "as there are several mains"); elsif Defaults /= Nil_Variable_Value then Put_Line - ("Warning: using Builder'Default_Switches(""" - & Get_Name_String (Lang) - & """), as there are several mains"); + ("Warning: using Builder'Default_Switches(""" & + Get_Name_String (Lang) & + """), as there are several mains"); else Put_Line - ("Warning: using no switches from package " - & "Builder, as there are several mains"); + ("Warning: using no switches from package " & + "Builder, as there are several mains"); end if; end if; end if; diff --git a/src/gprbind.adb b/src/gprbind.adb index cc28345dc..8f07a155e 100644 --- a/src/gprbind.adb +++ b/src/gprbind.adb @@ -775,7 +775,7 @@ begin for J in Option'Range loop Ch := Option (J); - if Ch = ' ' or else Ch = ASCII.HT or else Ch = '"' then + if Ch in ' ' | ASCII.HT | '"' then Quotes_Needed := True; exit; end if; @@ -1141,20 +1141,20 @@ begin begin Set_Name_Buffer (Line (3 .. Last)); - while Name_Buffer (Name_Len) = Directory_Separator - or else Name_Buffer (Name_Len) = '/' + while Name_Buffer (Name_Len) in Directory_Separator | + '/' loop Name_Len := Name_Len - 1; end loop; - while Name_Buffer (Name_Len) /= Directory_Separator - and then Name_Buffer (Name_Len) /= '/' + while Name_Buffer (Name_Len) not in + Directory_Separator | '/' loop Name_Len := Name_Len - 1; end loop; - while Name_Buffer (Name_Len) = Directory_Separator - or else Name_Buffer (Name_Len) = '/' + while Name_Buffer (Name_Len) in Directory_Separator | + '/' loop Name_Len := Name_Len - 1; end loop; @@ -1179,8 +1179,8 @@ begin exit Dir_Loop when First <= 3; Dir_Last := First - 1; - while Name_Buffer (Dir_Last) = Directory_Separator - or else Name_Buffer (Dir_Last) = '/' + while Name_Buffer (Dir_Last) in + Directory_Separator | '/' loop Dir_Last := Dir_Last - 1; end loop; diff --git a/src/gprbuild-compile.adb b/src/gprbuild-compile.adb index 464cc63c8..3206f0167 100644 --- a/src/gprbuild-compile.adb +++ b/src/gprbuild-compile.adb @@ -3115,8 +3115,7 @@ package body Gprbuild.Compile is Get_Name_String (Directories.Table (Index)); while Name_Len > 1 - and then (Name_Buffer (Name_Len) = Directory_Separator - or else Name_Buffer (Name_Len) = '/') + and then (Name_Buffer (Name_Len) in Directory_Separator | '/') loop Name_Len := Name_Len - 1; end loop; diff --git a/src/gprbuild-link.adb b/src/gprbuild-link.adb index 5b52c8c2e..2e1d3374f 100644 --- a/src/gprbuild-link.adb +++ b/src/gprbuild-link.adb @@ -3288,13 +3288,8 @@ package body Gprbuild.Link is Path => Response_2); end if; - if Main_Proj.Config.Resp_File_Format = GCC - or else - Main_Proj.Config.Resp_File_Format = GCC_GNU - or else - Main_Proj.Config.Resp_File_Format = GCC_Object_List - or else - Main_Proj.Config.Resp_File_Format = GCC_Option_List + if Main_Proj.Config.Resp_File_Format in GCC | GCC_GNU | + GCC_Object_List | GCC_Option_List then Add_Argument (Arguments, @@ -3321,10 +3316,9 @@ package body Gprbuild.Link is Resp_File_Options.Replace_Element (Resp_File_Options.Last_Index, Resp_File_Options.Last_Element & - Get_Name_String (Response_File_Name)); + Get_Name_String (Response_File_Name)); Add_Arguments - (Arguments, - Resp_File_Options, + (Arguments, Resp_File_Options, Opt.Verbose_Mode); Objects.Clear; end if; diff --git a/src/gprbuild-main.adb b/src/gprbuild-main.adb index 24892c43f..f97773d3e 100644 --- a/src/gprbuild-main.adb +++ b/src/gprbuild-main.adb @@ -694,9 +694,7 @@ procedure Gprbuild.Main is elsif Arg = "-kargs" then Current_Processor := Gprconfig; - elsif Arg = "-gargs" - or else Arg = "-margs" - then + elsif Arg in "-gargs" | "-margs" then Current_Processor := None; -- A special test is needed for the -o switch within a -largs since @@ -740,10 +738,10 @@ procedure Gprbuild.Main is Complete_Output := True; No_Complete_Output := False; - elsif Arg = No_Complete_Output_Option or else Arg = "-n" then + elsif Arg in No_Complete_Output_Option | "-n" then Forbidden_In_Package_Builder; No_Complete_Output := True; - Complete_Output := False; + Complete_Output := False; elsif Arg = No_Project_Option then Forbidden_In_Package_Builder; @@ -1453,7 +1451,7 @@ procedure Gprbuild.Main is Output_File_Name_Expected := True; end if; - elsif Arg = "-p" or else Arg = "--create-missing-dirs" then + elsif Arg in "-p" | "--create-missing-dirs" then Forbidden_In_Package_Builder; Opt.Create_Dirs := Create_All_Dirs; @@ -1515,7 +1513,7 @@ procedure Gprbuild.Main is Unique_Compile_All_Projects := True; Unique_Compile := True; - elsif Arg = "-v" or else Arg = "-vl" then + elsif Arg in "-v" | "-vl" then Opt.Verbose_Mode := True; Opt.Verbosity_Level := Opt.Low; Opt.Quiet_Output := False; @@ -1604,8 +1602,7 @@ procedure Gprbuild.Main is null; - elsif (Language = No_Name or else Language = Name_Ada) - and then (not Command_Line) + elsif (Language in No_Name | Name_Ada) and then (not Command_Line) and then Arg = "-x" then -- For compatibility with gnatmake, ignore -x if found in the @@ -1613,14 +1610,11 @@ procedure Gprbuild.Main is null; - elsif (Language = No_Name or else Language = Name_Ada) - and then not Subst_Switch_Present - and then - (Arg = "-fstack-check" - or else Arg = "-fno-inline" - or else - (Arg'Length >= 2 - and then (Arg (2) = 'O' or else Arg (2) = 'g'))) + elsif (Language in No_Name | Name_Ada) + and then not Subst_Switch_Present + and then + (Arg in "-fstack-check" | "-fno-inline" + or else (Arg'Length >= 2 and then (Arg (2) in 'O' | 'g'))) then -- For compatibility with gnatmake, use switch to compile Ada -- code. We don't do this if the --compiler-pkg-subst switch was @@ -1632,8 +1626,8 @@ procedure Gprbuild.Main is Compiling_Options_HTable.Get (Name_Ada); if Current_Comp_Option_Table = No_Comp_Option_Table then - Current_Comp_Option_Table := new String_Vectors.Vector' - (String_Vectors.Empty_Vector); + Current_Comp_Option_Table := + new String_Vectors.Vector'(String_Vectors.Empty_Vector); Compiling_Options_HTable.Set (Name_Ada, Current_Comp_Option_Table); end if; @@ -1643,7 +1637,7 @@ procedure Gprbuild.Main is Builder_Compiling_Options_HTable.Get (Name_Ada); if Current_Builder_Comp_Option_Table = - No_Builder_Comp_Option_Table + No_Builder_Comp_Option_Table then Current_Builder_Comp_Option_Table := new String_Vectors.Vector'(String_Vectors.Empty_Vector); @@ -1656,21 +1650,18 @@ procedure Gprbuild.Main is Add_Option (Arg, Command_Line); Current_Processor := None; - elsif (Language = No_Name or else Language = Name_Ada) - and then - (Arg = "-nostdlib" or else Arg = "-nostdinc") + elsif (Language in No_Name | Name_Ada) + and then (Arg in "-nostdlib" | "-nostdinc") then -- For compatibility with gnatmake, use switch to bind Ada code -- code and for -nostdlib to link. - Current_Bind_Option_Table := - Binder_Options_HTable.Get (Name_Ada); + Current_Bind_Option_Table := Binder_Options_HTable.Get (Name_Ada); if Current_Bind_Option_Table = No_Bind_Option_Table then Current_Bind_Option_Table := new String_Vectors.Vector'(String_Vectors.Empty_Vector); - Binder_Options_HTable.Set - (Name_Ada, Current_Bind_Option_Table); + Binder_Options_HTable.Set (Name_Ada, Current_Bind_Option_Table); end if; Current_Processor := Binder; diff --git a/src/gprbuild.adb b/src/gprbuild.adb index 681a75104..914274080 100644 --- a/src/gprbuild.adb +++ b/src/gprbuild.adb @@ -206,23 +206,20 @@ package body Gprbuild is Proj : constant Project_Id := Object_Project (Project, Must_Be_Writable); begin if Proj = No_Project then - if Project.Qualifier = Aggregate - or else Project.Qualifier = Aggregate_Library - then + if Project.Qualifier in Aggregate | Aggregate_Library then Fail_Program (Project_Tree, - "no project with writable object directory for project " - & Get_Name_String (Project.Name), + "no project with writable object directory for project " & + Get_Name_String (Project.Name), Exit_Code => E_General); else Fail_Program (Project_Tree, - "object directory """ - & Get_Name_String (Project.Object_Directory.Display_Name) - & """ for project """ - & Get_Name_String (Project.Name) - & """ is not writable", + "object directory """ & + Get_Name_String (Project.Object_Directory.Display_Name) & + """ for project """ & Get_Name_String (Project.Name) & + """ is not writable", Exit_Code => E_General); end if; end if; @@ -445,8 +442,7 @@ package body Gprbuild is Get_Name_String (Directories.Table (Index)); while Name_Len > 1 - and then (Name_Buffer (Name_Len) = Directory_Separator - or else Name_Buffer (Name_Len) = '/') + and then (Name_Buffer (Name_Len) in Directory_Separator | '/') loop Name_Len := Name_Len - 1; end loop; diff --git a/src/gprclean.adb b/src/gprclean.adb index 7d1cd564f..f00f68858 100644 --- a/src/gprclean.adb +++ b/src/gprclean.adb @@ -286,11 +286,9 @@ package body Gprclean is if Last > 0 then if Name (1) = '[' then In_Generated := - Name (1 .. Last) = - Library_Label (Generated_Object_Files) - or else - Name (1 .. Last) = - Library_Label (Generated_Source_Files); + Name (1 .. Last) in + Library_Label (Generated_Object_Files) | + Library_Label (Generated_Source_Files); elsif In_Generated then if Is_Regular_File (Name (1 .. Last)) then @@ -329,9 +327,9 @@ package body Gprclean is if (Is_Static (Project) and then Name (1 .. Last) = Archive_Name) or else - ((Project.Library_Kind = Dynamic - or else Project.Library_Kind = Relocatable) - and then Name (1 .. Last) = DLL_Name) + + ((Project.Library_Kind in Dynamic | Relocatable) + and then Name (1 .. Last) = DLL_Name) then Delete (Lib_Directory, Name (1 .. Last)); end if; @@ -341,8 +339,7 @@ package body Gprclean is Close (Direc); if Project.Config.Symbolic_Link_Supported then - if (Project.Library_Kind = Dynamic - or else Project.Library_Kind = Relocatable) + if (Project.Library_Kind in Dynamic | Relocatable) and then Project.Lib_Internal_Name /= No_Name then declare @@ -371,9 +368,10 @@ package body Gprclean is Read (Direc, Name, Last); exit when Last = 0; - if (Is_Regular_File (Name (1 .. Last)) - or else - Is_Symbolic_Link (Name (1 .. Last))) + if + (Is_Regular_File (Name (1 .. Last)) + or else Is_Symbolic_Link + (Name (1 .. Last))) and then Name (1 .. Last) = Maj_Version then Delete diff --git a/src/gprconfig-main.adb b/src/gprconfig-main.adb index cf979724c..44a319cf3 100644 --- a/src/gprconfig-main.adb +++ b/src/gprconfig-main.adb @@ -601,9 +601,7 @@ begin Get_Name_String (Runtime_Dir_Of (Comp)); Last : Natural := RTS'Last; begin - if RTS (Last) = '/' or else - RTS (Last) = Directory_Separator - then + if RTS (Last) in '/' | Directory_Separator then Last := Last - 1; end if; diff --git a/src/gprinstall-main.adb b/src/gprinstall-main.adb index 7045127ee..7ea12bc44 100644 --- a/src/gprinstall-main.adb +++ b/src/gprinstall-main.adb @@ -272,7 +272,7 @@ procedure Gprinstall.Main is elsif Arg = "-h" then Usage_Needed := True; - elsif Arg = "-p" or else Arg = "--create-missing-dirs" then + elsif Arg in "-p" | "--create-missing-dirs" then Create_Dest_Dir := True; elsif Arg'Length >= 2 and then Arg (2) = 'P' then diff --git a/src/gprlib-build_shared_lib.adb b/src/gprlib-build_shared_lib.adb index 1b25f6d29..2d523ab0e 100644 --- a/src/gprlib-build_shared_lib.adb +++ b/src/gprlib-build_shared_lib.adb @@ -308,10 +308,8 @@ procedure Build_Shared_Lib is Arguments.Delete_Last; end loop; - if Resp_File_Format = GCC - or else Resp_File_Format = GCC_GNU - or else Resp_File_Format = GCC_Object_List - or else Resp_File_Format = GCC_Option_List + if Resp_File_Format in GCC | GCC_GNU | GCC_Object_List | + GCC_Option_List then Arguments.Append ("@" & Get_Name_String (Response_File_Name)); @@ -322,7 +320,7 @@ procedure Build_Shared_Lib is Response_File_Switches.Replace_Element (Response_File_Switches.Last_Index, Response_File_Switches.Last_Element & - Get_Name_String (Response_File_Name)); + Get_Name_String (Response_File_Name)); Arguments.Append_Vector (Response_File_Switches); end if; diff --git a/src/gprlib.adb b/src/gprlib.adb index 8155f7b9a..880927b75 100644 --- a/src/gprlib.adb +++ b/src/gprlib.adb @@ -534,12 +534,12 @@ procedure Gprlib is -- beginning of the P line. for Index in 1 .. Len - 3 loop - if (S (Index) = ASCII.LF or else S (Index) = ASCII.CR) + if (S (Index) in ASCII.LF | ASCII.CR) and then S (Index + 1) = 'P' then - S (Index + 5 .. Len + 3) := S (Index + 2 .. Len); + S (Index + 5 .. Len + 3) := S (Index + 2 .. Len); S (Index + 2 .. Index + 4) := " SL"; - P_Line_Found := True; + P_Line_Found := True; exit; end if; end loop; @@ -1101,10 +1101,7 @@ procedure Gprlib is Quotes_Needed := False; for Ch of Arg loop - if Ch = ' ' or else - Ch = ASCII.HT or else - Ch = '"' - then + if Ch in ' ' | ASCII.HT | '"' then Quotes_Needed := True; exit; end if; diff --git a/src/gprls-main.adb b/src/gprls-main.adb index 2b463091a..72c44f689 100644 --- a/src/gprls-main.adb +++ b/src/gprls-main.adb @@ -758,8 +758,7 @@ procedure Gprls.Main is -- Find the beginning of the next line Index := Last; - while Buffer (Index) = ASCII.CR or else - Buffer (Index) = ASCII.LF + while Buffer (Index) in ASCII.CR | ASCII.LF loop Index := Index + 1; end loop; diff --git a/src/gprname.adb b/src/gprname.adb index 42d1a1617..1315a9724 100644 --- a/src/gprname.adb +++ b/src/gprname.adb @@ -1229,16 +1229,13 @@ package body GPRName is Kind_Of_Node := Kind_Of (Current_Node, Tree); - if Kind_Of_Node = N_Attribute_Declaration or else - Kind_Of_Node = N_Package_Declaration + if Kind_Of_Node in N_Attribute_Declaration | + N_Package_Declaration then Name := GPR.Tree.Name_Of (Current_Node, Tree); - if Name in Name_Source_Files - | Name_Source_List_File - | Name_Source_Dirs - | Name_Languages - | Name_Naming + if Name in Name_Source_Files | Name_Source_List_File | + Name_Source_Dirs | Name_Languages | Name_Naming then Comments := Tree.Project_Nodes.Table (Current_Node).Comments; @@ -1261,8 +1258,7 @@ package body GPRName is if No (Previous) then Set_First_Declarative_Item_Of - (Project_Declaration_Of (Project_Node, Tree), - Tree, + (Project_Declaration_Of (Project_Node, Tree), Tree, To => Next_Declarative_Item (Declaration, Tree)); else