OSDN Git Service

* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Class_Wide_Type>: Fix
[pf3gnuchains/gcc-fork.git] / gcc / ada / mlib.adb
index 5a8a661..4c4d375 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                     Copyright (C) 1999-2008, AdaCore                     --
+--                     Copyright (C) 1999-2009, AdaCore                     --
 --                                                                          --
 -- 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- --
@@ -55,7 +55,7 @@ package body MLib is
          Write_Line (Output_File);
       end if;
 
-      Ar (Output_Dir & Directory_Separator &
+      Ar (Output_Dir &
           "lib" & Output_File & ".a", Objects => Ofiles);
    end Build_Library;
 
@@ -202,16 +202,21 @@ package body MLib is
                      if FD /= Invalid_FD then
                         Len := Integer (File_Length (FD));
 
+                        --  ??? Why "+3" here
+
                         S := new String (1 .. Len + 3);
 
                         --  Read the file. Note that the loop is not necessary
                         --  since the whole file is read at once except on VMS.
 
-                        Curr := 1;
-                        Actual_Len := Len;
-
-                        while Actual_Len /= 0 loop
+                        Curr := S'First;
+                        while Curr <= Len loop
                            Actual_Len := Read (FD, S (Curr)'Address, Len);
+
+                           --  Exit if we could not read for some reason
+
+                           exit when Actual_Len = 0;
+
                            Curr := Curr + Actual_Len;
                         end loop;
 
@@ -226,10 +231,10 @@ package body MLib is
                         --  at the beginning of the P line.
 
                         for Index in 1 .. Len - 3 loop
-                           if (S (Index) = ASCII.LF or else
-                                 S (Index) = ASCII.CR)
-                             and then
-                               S (Index + 1) = 'P'
+                           if (S (Index) = ASCII.LF
+                                 or else
+                               S (Index) = ASCII.CR)
+                             and then S (Index + 1) = 'P'
                            then
                               S (Index + 5 .. Len + 3) := S (Index + 2 .. Len);
                               S (Index + 2 .. Index + 4) := " SL";
@@ -442,6 +447,18 @@ package body MLib is
       end if;
    end Major_Id_Name;
 
+   -------------------------------
+   -- Separate_Run_Path_Options --
+   -------------------------------
+
+   function Separate_Run_Path_Options return Boolean is
+      Separate_Paths : Boolean;
+      for Separate_Paths'Size use Character'Size;
+      pragma Import (C, Separate_Paths, "__gnat_separate_run_path_options");
+   begin
+      return Separate_Paths;
+   end Separate_Run_Path_Options;
+
 --  Package elaboration
 
 begin