diff options
Diffstat (limited to 'gcc/ada/osint.adb')
-rw-r--r-- | gcc/ada/osint.adb | 92 |
1 files changed, 72 insertions, 20 deletions
diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb index 04e2919cc24..770c499312b 100644 --- a/gcc/ada/osint.adb +++ b/gcc/ada/osint.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2008, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- -- -- GNAT 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- -- @@ -29,6 +29,8 @@ with System.Case_Util; use System.Case_Util; with GNAT.HTable; +with Alloc; +with Debug; with Fmap; use Fmap; with Gnatvsn; use Gnatvsn; with Hostparm; @@ -111,6 +113,9 @@ package body Osint is -- Converts a C String to an Ada String. Are we doing this to avoid withing -- Interfaces.C.Strings ??? + function Include_Dir_Default_Prefix return String_Access; + -- Same as exported version, except returns a String_Access + ------------------------------ -- Other Local Declarations -- ------------------------------ @@ -137,6 +142,20 @@ package body Osint is -- latest source, library and object files opened by Read_Source_File and -- Read_Library_Info. + package File_Name_Chars is new Table.Table ( + Table_Component_Type => Character, + Table_Index_Type => Int, + Table_Low_Bound => 1, + Table_Initial => Alloc.File_Name_Chars_Initial, + Table_Increment => Alloc.File_Name_Chars_Increment, + Table_Name => "File_Name_Chars"); + -- Table to store text to be printed by Dump_Source_File_Names + + The_Include_Dir_Default_Prefix : String_Access := null; + -- Value returned by Include_Dir_Default_Prefix. We don't initialize it + -- here, because that causes an elaboration cycle with Sdefault; we + -- initialize it lazily instead. + ------------------ -- Search Paths -- ------------------ @@ -717,6 +736,16 @@ package body Osint is end if; end Dir_In_Src_Search_Path; + ---------------------------- + -- Dump_Source_File_Names -- + ---------------------------- + + procedure Dump_Source_File_Names is + subtype Rng is Int range File_Name_Chars.First .. File_Name_Chars.Last; + begin + Write_Str (String (File_Name_Chars.Table (Rng))); + end Dump_Source_File_Names; + --------------------- -- Executable_Name -- --------------------- @@ -1392,22 +1421,19 @@ package body Osint is -- Include_Dir_Default_Prefix -- -------------------------------- - function Include_Dir_Default_Prefix return String is - Include_Dir : String_Access := - String_Access (Update_Path (Include_Dir_Default_Name)); - + function Include_Dir_Default_Prefix return String_Access is begin - if Include_Dir = null then - return ""; - - else - declare - Result : constant String := Include_Dir.all; - begin - Free (Include_Dir); - return Result; - end; + if The_Include_Dir_Default_Prefix = null then + The_Include_Dir_Default_Prefix := + String_Access (Update_Path (Include_Dir_Default_Name)); end if; + + return The_Include_Dir_Default_Prefix; + end Include_Dir_Default_Prefix; + + function Include_Dir_Default_Prefix return String is + begin + return Include_Dir_Default_Prefix.all; end Include_Dir_Default_Prefix; ---------------- @@ -2268,6 +2294,32 @@ package body Osint is return; end if; + -- Print out the file name, if requested, and if it's not part of the + -- runtimes, store it in File_Name_Chars. + + declare + Name : String renames Name_Buffer (1 .. Name_Len); + Inc : String renames Include_Dir_Default_Prefix.all; + + begin + if Debug.Debug_Flag_Dot_N then + Write_Line (Name); + end if; + + if Inc /= "" + and then Inc'Length < Name_Len + and then Name_Buffer (1 .. Inc'Length) = Inc + then + -- Part of runtimes, so ignore it + + null; + + else + File_Name_Chars.Append_All (File_Name_Chars.Table_Type (Name)); + File_Name_Chars.Append (ASCII.LF); + end if; + end; + -- Prepare to read data from the file Len := Integer (File_Length (Source_File_FD)); @@ -2292,9 +2344,9 @@ package body Osint is begin -- Allocate source buffer, allowing extra character at end for EOF - -- Some systems (e.g. VMS) have file types that require one - -- read per line, so read until we get the Len bytes or until - -- there are no more characters. + -- Some systems (e.g. VMS) have file types that require one read per + -- line, so read until we get the Len bytes or until there are no + -- more characters. Hi := Lo; loop @@ -2306,8 +2358,8 @@ package body Osint is Actual_Ptr (Hi) := EOF; -- Now we need to work out the proper virtual origin pointer to - -- return. This is exactly Actual_Ptr (0)'Address, but we have - -- to be careful to suppress checks to compute this address. + -- return. This is exactly Actual_Ptr (0)'Address, but we have to + -- be careful to suppress checks to compute this address. declare pragma Suppress (All_Checks); |