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 9fb5084..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;
 
@@ -70,20 +70,22 @@ package body MLib is
       end if;
 
       if Name'Length > Max_Characters_In_Library_Name then
-         Prj.Com.Fail ("illegal library name """, Name, """: too long");
+         Prj.Com.Fail ("illegal library name """
+                       & Name
+                       & """: too long");
       end if;
 
       if not Is_Letter (Name (Name'First)) then
-         Prj.Com.Fail ("illegal library name """,
-                       Name,
-                       """: should start with a letter");
+         Prj.Com.Fail ("illegal library name """
+                       & Name
+                       """: should start with a letter");
       end if;
 
       for Index in Name'Range loop
          if not Is_Alphanumeric (Name (Index)) then
-            Prj.Com.Fail ("illegal library name """,
-                          Name,
-                          """: should include only letters and digits");
+            Prj.Com.Fail ("illegal library name """
+                          & Name
+                          """: should include only letters and digits");
          end if;
       end loop;
    end Check_Library_Name;
@@ -200,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;
 
@@ -224,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";
@@ -263,12 +270,13 @@ package body MLib is
                               --  Set Success to True only if the newly
                               --  created file has been correctly written.
 
-                              Success := Status and Actual_Len = Len + 3;
+                              Success := Status and then Actual_Len = Len + 3;
 
                               if Success then
-                                 --  Set_Read_Only is used here, not
-                                 --  Set_Non_Writable, so that gprbuild can be
-                                 --  compiled with older compilers.
+
+                                 --  Set_Read_Only is used here, rather than
+                                 --  Set_Non_Writable, so that gprbuild can
+                                 --  he compiled with older compilers.
 
                                  Set_Read_Only
                                    (Name_Buffer (1 .. Name_Len - 1));
@@ -439,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