This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[Ada] Fix GNAT project files problem on Interix


Applied for Vincent.

2001-10-26  Vincent Celier <celier@gnat.com>

	* g-os_lib.adb (Normalize_Pathname): Preserve the double slash 
        ("//") that precede the drive letter on Interix.

*** g-os_lib.adb	2001/08/30 09:42:27	1.74
--- g-os_lib.adb	2001/10/04 06:01:12	1.75
***************
*** 813,818 ****
--- 813,821 ----
        Canonical_File_Addr : System.Address;
        Canonical_File_Len  : Integer;
  
+       Need_To_Check_Drive_Letter : Boolean := False;
+       --  Set to true if Name is an absolute path that starts with "//"
+ 
        function Strlen (S : System.Address) return Integer;
        pragma Import (C, Strlen, "strlen");
  
***************
*** 821,826 ****
--- 824,836 ----
        --  if not already present, otherwise return current working directory
        --  with terminating directory separator.
  
+       function Final_Value (S : String) return String;
+       --  Make final adjustment to the returned string.
+       --  To compensate for non standard path name in Interix,
+       --  if S is "/x" or starts with "/x", where x is a capital
+       --  letter 'A' to 'Z', add an additional '/' at the beginning
+       --  so that the returned value starts with "//x".
+ 
        -------------------
        -- Get_Directory --
        -------------------
***************
*** 866,871 ****
--- 876,910 ----
        Reference_Dir : constant String := Get_Directory;
        --  Current directory name specified
  
+       function Final_Value (S : String) return String is
+       begin
+          --  Interix has the non standard notion of disk drive
+          --  indicated by two '/' followed by a capital letter
+          --  'A' .. 'Z'. One of the two '/' may have been removed
+          --  by Normalize_Pathname. It has to be added again.
+          --  For other OSes, this should not make no difference.
+ 
+          if Need_To_Check_Drive_Letter
+            and then S'Length >= 2
+            and then S (S'First) = '/'
+            and then S (S'First + 1) in 'A' .. 'Z'
+            and then (S'Length = 2 or else S (S'First + 2) = '/')
+          then
+             declare
+                Result : String (1 .. S'Length + 1);
+ 
+             begin
+                Result (1) := '/';
+                Result (2 .. Result'Last) := S;
+                return Result;
+             end;
+ 
+          else
+             return S;
+          end if;
+ 
+       end Final_Value;
+ 
     --  Start of processing for Normalize_Pathname
  
     begin
***************
*** 942,961 ****
              Last := Reference_Dir'Length;
           end if;
  
           Start  := Last + 1;
           Finish := Last;
  
           --  If we have traversed the full pathname, return it
  
           if Start > End_Path then
!             return Path_Buffer (1 .. End_Path);
           end if;
  
           --  Remove duplicate directory separators
  
           while Path_Buffer (Start) = Directory_Separator loop
              if Start = End_Path then
!                return Path_Buffer (1 .. End_Path - 1);
  
              else
                 Path_Buffer (Start .. End_Path - 1) :=
--- 981,1006 ----
              Last := Reference_Dir'Length;
           end if;
  
+          --  If name starts with "//", we may have a drive letter on Interix
+ 
+          if Last = 1 and then End_Path >= 3 then
+             Need_To_Check_Drive_Letter := (Path_Buffer (1 .. 2)) = "//";
+          end if;
+ 
           Start  := Last + 1;
           Finish := Last;
  
           --  If we have traversed the full pathname, return it
  
           if Start > End_Path then
!             return Final_Value (Path_Buffer (1 .. End_Path));
           end if;
  
           --  Remove duplicate directory separators
  
           while Path_Buffer (Start) = Directory_Separator loop
              if Start = End_Path then
!                return Final_Value (Path_Buffer (1 .. End_Path - 1));
  
              else
                 Path_Buffer (Start .. End_Path - 1) :=
***************
*** 1014,1020 ****
  
              else
                 if Finish = End_Path then
!                   return Path_Buffer (1 .. Start - 1);
  
                 else
                    Path_Buffer (Start + 1 .. Start + End_Path - Finish - 1) :=
--- 1059,1065 ----
  
              else
                 if Finish = End_Path then
!                   return Final_Value (Path_Buffer (1 .. Start - 1));
  
                 else
                    Path_Buffer (Start + 1 .. Start + End_Path - Finish - 1) :=


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]