OSDN Git Service

Delete all lines containing "$Revision:".
[pf3gnuchains/gcc-fork.git] / gcc / ada / fname-sf.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                             F N A M E . S F                              --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --                                                                          --
10 --          Copyright (C) 1992-2000 Free Software Foundation, Inc.          --
11 --                                                                          --
12 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
13 -- terms of the  GNU General Public License as published  by the Free Soft- --
14 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
15 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
18 -- for  more details.  You should have  received  a copy of the GNU General --
19 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
20 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
21 -- MA 02111-1307, USA.                                                      --
22 --                                                                          --
23 -- GNAT was originally developed  by the GNAT team at  New York University. --
24 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
25 --                                                                          --
26 ------------------------------------------------------------------------------
27
28 with Casing;   use Casing;
29 with Fname;    use Fname;
30 with Fname.UF; use Fname.UF;
31 with SFN_Scan; use SFN_Scan;
32 with Namet;    use Namet;
33 with Osint;    use Osint;
34 with Types;    use Types;
35
36 with Unchecked_Conversion;
37
38 package body Fname.SF is
39
40    subtype Big_String is String (Positive);
41    type Big_String_Ptr is access all Big_String;
42
43    function To_Big_String_Ptr is new Unchecked_Conversion
44      (Source_Buffer_Ptr, Big_String_Ptr);
45
46    ----------------------
47    -- Local Procedures --
48    ----------------------
49
50    procedure Set_File_Name (Typ : Character; U : String; F : String);
51    --  This is a transfer function that is called from Scan_SFN_Pragmas,
52    --  and reformats its parameters appropriately for the version of
53    --  Set_File_Name found in Fname.SF.
54
55    procedure Set_File_Name_Pattern
56      (Pat : String;
57       Typ : Character;
58       Dot : String;
59       Cas : Character);
60    --  This is a transfer function that is called from Scan_SFN_Pragmas,
61    --  and reformats its parameters appropriately for the version of
62    --  Set_File_Name_Pattern found in Fname.SF.
63
64    -----------------------------------
65    -- Read_Source_File_Name_Pragmas --
66    -----------------------------------
67
68    procedure Read_Source_File_Name_Pragmas is
69       Src : Source_Buffer_Ptr;
70       Hi  : Source_Ptr;
71       BS  : Big_String_Ptr;
72       SP  : String_Ptr;
73
74    begin
75       Name_Buffer (1 .. 8) := "gnat.adc";
76       Name_Len := 8;
77       Read_Source_File (Name_Enter, 0, Hi, Src);
78
79       if Src /= null then
80          BS := To_Big_String_Ptr (Src);
81          SP := BS (1 .. Natural (Hi))'Unrestricted_Access;
82          Scan_SFN_Pragmas
83            (SP.all,
84             Set_File_Name'Access,
85             Set_File_Name_Pattern'Access);
86       end if;
87    end Read_Source_File_Name_Pragmas;
88
89    -------------------
90    -- Set_File_Name --
91    -------------------
92
93    procedure Set_File_Name (Typ : Character; U : String; F : String) is
94       Unm : Unit_Name_Type;
95       Fnm : File_Name_Type;
96
97    begin
98       Name_Buffer (1 .. U'Length) := U;
99       Name_Len := U'Length;
100       Set_Casing (All_Lower_Case);
101       Name_Buffer (Name_Len + 1) := '%';
102       Name_Buffer (Name_Len + 2) := Typ;
103       Name_Len := Name_Len + 2;
104       Unm := Name_Find;
105       Name_Buffer (1 .. F'Length) := F;
106       Name_Len := F'Length;
107       Fnm := Name_Find;
108       Fname.UF.Set_File_Name (Unm, Fnm);
109    end Set_File_Name;
110
111    ---------------------------
112    -- Set_File_Name_Pattern --
113    ---------------------------
114
115    procedure Set_File_Name_Pattern
116      (Pat : String;
117       Typ : Character;
118       Dot : String;
119       Cas : Character)
120    is
121       Ctyp : Casing_Type;
122       Patp : constant String_Ptr := new String'(Pat);
123       Dotp : constant String_Ptr := new String'(Dot);
124
125    begin
126       if Cas = 'l' then
127          Ctyp := All_Lower_Case;
128       elsif Cas = 'u' then
129          Ctyp := All_Upper_Case;
130       else -- Cas = 'm'
131          Ctyp := Mixed_Case;
132       end if;
133
134       Fname.UF.Set_File_Name_Pattern (Patp, Typ, Dotp, Ctyp);
135    end Set_File_Name_Pattern;
136
137 end Fname.SF;