comparison gcc/ada/osint.adb @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
4 -- -- 4 -- --
5 -- O S I N T -- 5 -- O S I N T --
6 -- -- 6 -- --
7 -- B o d y -- 7 -- B o d y --
8 -- -- 8 -- --
9 -- Copyright (C) 1992-2017, Free Software Foundation, Inc. -- 9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
10 -- -- 10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under -- 11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- -- 12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- -- 13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- 14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
248 type File_Info_Cache is record 248 type File_Info_Cache is record
249 File : File_Name_Type; 249 File : File_Name_Type;
250 Attr : aliased File_Attributes; 250 Attr : aliased File_Attributes;
251 end record; 251 end record;
252 252
253 No_File_Info_Cache : constant File_Info_Cache := 253 No_File_Info_Cache : constant File_Info_Cache := (No_File, (others => 0));
254 (No_File, Unknown_Attributes);
255 254
256 package File_Name_Hash_Table is new GNAT.HTable.Simple_HTable ( 255 package File_Name_Hash_Table is new GNAT.HTable.Simple_HTable (
257 Header_Num => File_Hash_Num, 256 Header_Num => File_Hash_Num,
258 Element => File_Info_Cache, 257 Element => File_Info_Cache,
259 No_Element => No_File_Info_Cache, 258 No_Element => No_File_Info_Cache,
829 for J in reverse 1 .. Name_Len loop 828 for J in reverse 1 .. Name_Len loop
830 if Name_Buffer (J) = '.' then 829 if Name_Buffer (J) = '.' then
831 Add_Suffix := False; 830 Add_Suffix := False;
832 exit; 831 exit;
833 832
834 elsif Name_Buffer (J) = '/' or else 833 elsif Is_Directory_Separator (Name_Buffer (J)) then
835 Name_Buffer (J) = Directory_Separator
836 then
837 exit; 834 exit;
838 end if; 835 end if;
839 end loop; 836 end loop;
840 end if; 837 end if;
841 838
904 for J in reverse Canonical_Name'Range loop 901 for J in reverse Canonical_Name'Range loop
905 if Canonical_Name (J) = '.' then 902 if Canonical_Name (J) = '.' then
906 Add_Suffix := False; 903 Add_Suffix := False;
907 exit; 904 exit;
908 905
909 elsif Canonical_Name (J) = '/' or else 906 elsif Is_Directory_Separator (Canonical_Name (J)) then
910 Canonical_Name (J) = Directory_Separator
911 then
912 exit; 907 exit;
913 end if; 908 end if;
914 end loop; 909 end loop;
915 end if; 910 end if;
916 911
1500 1495
1501 begin 1496 begin
1502 -- Add a directory separator at the end of the directory if necessary 1497 -- Add a directory separator at the end of the directory if necessary
1503 -- so that we can directly append a file to the directory 1498 -- so that we can directly append a file to the directory
1504 1499
1505 if Search_Dir (Search_Dir'Last) /= Directory_Separator then 1500 if not Is_Directory_Separator (Search_Dir (Search_Dir'Last)) then
1506 Local_Search_Dir := 1501 Local_Search_Dir :=
1507 new String'(Search_Dir & String'(1 => Directory_Separator)); 1502 new String'(Search_Dir & String'(1 => Directory_Separator));
1508 else 1503 else
1509 Local_Search_Dir := new String'(Search_Dir); 1504 Local_Search_Dir := new String'(Search_Dir);
1510 end if; 1505 end if;
1552 1547
1553 if Path_Len = 0 then 1548 if Path_Len = 0 then
1554 raise Program_Error; 1549 raise Program_Error;
1555 end if; 1550 end if;
1556 1551
1557 if Buffer (Path_Len) /= Directory_Separator then 1552 if not Is_Directory_Separator (Buffer (Path_Len)) then
1558 Path_Len := Path_Len + 1; 1553 Path_Len := Path_Len + 1;
1559 Buffer (Path_Len) := Directory_Separator; 1554 Buffer (Path_Len) := Directory_Separator;
1560 end if; 1555 end if;
1561 1556
1562 Current_Dir := new String'(Buffer (1 .. Path_Len)); 1557 Current_Dir := new String'(Buffer (1 .. Path_Len));
1963 1958
1964 File_Name := File_Names (Current_File_Name_Index); 1959 File_Name := File_Names (Current_File_Name_Index);
1965 Fptr := File_Name'First; 1960 Fptr := File_Name'First;
1966 1961
1967 for J in reverse File_Name'Range loop 1962 for J in reverse File_Name'Range loop
1968 if File_Name (J) = Directory_Separator 1963 if Is_Directory_Separator (File_Name (J)) then
1969 or else File_Name (J) = '/'
1970 then
1971 if J = File_Name'Last then 1964 if J = File_Name'Last then
1972 Fail ("File name missing"); 1965 Fail ("File name missing");
1973 end if; 1966 end if;
1974 1967
1975 Fptr := J + 1; 1968 Fptr := J + 1;
2220 -- For instance in "powerpc-elf-gcc" the target prefix is 2213 -- For instance in "powerpc-elf-gcc" the target prefix is
2221 -- "powerpc-elf-" 2214 -- "powerpc-elf-"
2222 -- Ditto for suffix, e.g. in "gcc-4.1", the suffix is "-4.1" 2215 -- Ditto for suffix, e.g. in "gcc-4.1", the suffix is "-4.1"
2223 2216
2224 for J in reverse 1 .. Name_Len loop 2217 for J in reverse 1 .. Name_Len loop
2225 if Name_Buffer (J) = '/' 2218 if Is_Directory_Separator (Name_Buffer (J))
2226 or else Name_Buffer (J) = Directory_Separator
2227 or else Name_Buffer (J) = ':' 2219 or else Name_Buffer (J) = ':'
2228 then 2220 then
2229 Start_Of_Prefix := J + 1; 2221 Start_Of_Prefix := J + 1;
2230 exit; 2222 exit;
2231 end if; 2223 end if;