OSDN Git Service

PR bootstrap/11932
[pf3gnuchains/gcc-fork.git] / gcc / ada / fname-uf.adb
index 5f4fb9a..9852688 100644 (file)
@@ -6,9 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                            $Revision$
---                                                                          --
---          Copyright (C) 1992-2001, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-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- --
@@ -22,7 +20,7 @@
 -- MA 02111-1307, USA.                                                      --
 --                                                                          --
 -- GNAT was originally developed  by the GNAT team at  New York University. --
--- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
+-- Extensive contributions were provided by Ada Core Technologies Inc.      --
 --                                                                          --
 ------------------------------------------------------------------------------
 
@@ -125,9 +123,9 @@ package body Fname.UF is
    -------------------
 
    function Get_File_Name
-     (Uname   : Unit_Name_Type;
-      Subunit : Boolean)
-      return    File_Name_Type
+     (Uname    : Unit_Name_Type;
+      Subunit  : Boolean;
+      May_Fail : Boolean := False) return File_Name_Type
    is
       Unit_Char : Character;
       --  Set to 's' or 'b' for spec or body or to 'u' for a subunit
@@ -223,6 +221,9 @@ package body Fname.UF is
          Dot  : String_Ptr;
          Dotl : Natural;
 
+         Is_Predef : Boolean;
+         --  Set True for predefined file
+
          function C (N : Natural) return Character;
          --  Return N'th character of pattern
 
@@ -253,11 +254,25 @@ package body Fname.UF is
                if SFN_Patterns.Table (Pent).Typ = Unit_Char_Search then
                   Name_Len := 0;
 
+                  --  Determine if we have a predefined file name
+
+                  Name_Len := Uname'Length;
+                  Name_Buffer (1 .. Name_Len) := Uname;
+                  Is_Predef :=
+                    Is_Predefined_File_Name (Renamings_Included => True);
+
                   --  Found a match, execute the pattern
 
                   Name_Len := Uname'Length;
                   Name_Buffer (1 .. Name_Len) := Uname;
-                  Set_Casing (SFN_Patterns.Table (Pent).Cas);
+
+                  --  Apply casing, except that we do not do this for the case
+                  --  of a predefined library file. For the latter, we always
+                  --  use the all lower case name, regardless of the setting.
+
+                  if not Is_Predef then
+                     Set_Casing (SFN_Patterns.Table (Pent).Cas);
+                  end if;
 
                   --  If dot translation required do it
 
@@ -372,10 +387,15 @@ package body Fname.UF is
 
                   --  If we are in the second search of the table, we accept
                   --  the file name without checking, because we know that
-                  --  the file does not exist.
+                  --  the file does not exist, except when May_Fail is True,
+                  --  in which case we return No_File.
 
                   if No_File_Check then
-                     return Fnam;
+                     if May_Fail then
+                        return No_File;
+                     else
+                        return Fnam;
+                     end if;
 
                   --  Otherwise we check if the file exists