diff options
Diffstat (limited to 'gcc/ada/osint-c.adb')
-rw-r--r-- | gcc/ada/osint-c.adb | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/gcc/ada/osint-c.adb b/gcc/ada/osint-c.adb index d925abf7f77..7914b1b3805 100644 --- a/gcc/ada/osint-c.adb +++ b/gcc/ada/osint-c.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2003 Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2004 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- -- @@ -43,8 +43,7 @@ package body Osint.C is function Create_Auxiliary_File (Src : File_Name_Type; - Suffix : String) - return File_Name_Type; + Suffix : String) return File_Name_Type; -- Common processing for Creat_Repinfo_File and Create_Debug_File. -- Src is the file name used to create the required output file and -- Suffix is the desired suffic (dg/rep for debug/repinfo file). @@ -52,7 +51,8 @@ package body Osint.C is procedure Set_Library_Info_Name; -- Sets a default ali file name from the main compiler source name. -- This is used by Create_Output_Library_Info, and by the version of - -- Read_Library_Info that takes a default file name. + -- Read_Library_Info that takes a default file name. The name is in + -- Name_Buffer (with length in Name_Len) on return from the call ---------------------- -- Close_Debug_File -- @@ -60,6 +60,7 @@ package body Osint.C is procedure Close_Debug_File is Status : Boolean; + begin Close (Output_FD, Status); @@ -76,6 +77,7 @@ package body Osint.C is procedure Close_Output_Library_Info is Status : Boolean; + begin Close (Output_FD, Status); @@ -92,6 +94,7 @@ package body Osint.C is procedure Close_Repinfo_File is Status : Boolean; + begin Close (Output_FD, Status); @@ -108,8 +111,7 @@ package body Osint.C is function Create_Auxiliary_File (Src : File_Name_Type; - Suffix : String) - return File_Name_Type + Suffix : String) return File_Name_Type is Result : File_Name_Type; @@ -256,18 +258,36 @@ package body Osint.C is -- To compare them, remove file name directories and extensions. if Output_Object_File_Name /= null then + -- Make sure there is a dot at Dot_Index. This may not be the case -- if the source file name has no extension. Name_Buffer (Dot_Index) := '.'; + -- If we are in multiple unit per file mode, then add ~nnn + -- extension to the name before doing the comparison. + + if Multiple_Unit_Index /= 0 then + declare + Exten : constant String := Name_Buffer (Dot_Index .. Name_Len); + begin + Name_Len := Dot_Index - 1; + Add_Char_To_Name_Buffer ('~'); + Add_Nat_To_Name_Buffer (Multiple_Unit_Index); + Dot_Index := Name_Len + 1; + Add_Str_To_Name_Buffer (Exten); + end; + end if; + + -- Remove extension preparing to replace it + declare Name : constant String := Name_Buffer (1 .. Dot_Index); Len : constant Natural := Dot_Index; begin - Name_Buffer (1 .. Output_Object_File_Name'Length) - := Output_Object_File_Name.all; + Name_Buffer (1 .. Output_Object_File_Name'Length) := + Output_Object_File_Name.all; Dot_Index := 0; for J in reverse Output_Object_File_Name'Range loop @@ -277,8 +297,11 @@ package body Osint.C is end if; end loop; + -- Dot_Index should be zero now (we check for extension elsewhere) + pragma Assert (Dot_Index /= 0); - -- We check for the extension elsewhere + + -- Check name of object file is what we expect if Name /= Name_Buffer (Dot_Index - Len + 1 .. Dot_Index) then Fail ("incorrect object file name"); |