OSDN Git Service

Delete all lines containing "$Revision:".
[pf3gnuchains/gcc-fork.git] / gcc / ada / mdll-fil.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                            M D L L . F I L E S                           --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --                                                                          --
10 --          Copyright (C) 1992-2001 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 --  Simple services used by GNATDLL to deal with Filename extension.
29
30 with Ada.Strings.Fixed;
31
32 package body MDLL.Fil is
33
34    use Ada;
35
36    -------------
37    -- Get_Ext --
38    -------------
39
40    function Get_Ext (Filename : String) return String is
41       use Strings.Fixed;
42       I : constant Natural := Index (Filename, ".", Strings.Backward);
43    begin
44       if I = 0 then
45          return "";
46       else
47          return Filename (I .. Filename'Last);
48       end if;
49    end Get_Ext;
50
51    ------------
52    -- Is_Ali --
53    ------------
54
55    function Is_Ali (Filename : String) return Boolean is
56    begin
57       return Get_Ext (Filename) = ".ali";
58    end Is_Ali;
59
60    ------------
61    -- Is_Obj --
62    ------------
63
64    function Is_Obj (Filename : String) return Boolean is
65       Ext : constant String := Get_Ext (Filename);
66    begin
67       return Ext = ".o" or else Ext = ".obj";
68    end Is_Obj;
69
70    ------------
71    -- Ext_To --
72    ------------
73
74    function Ext_To
75      (Filename : String;
76       New_Ext  : String := No_Ext)
77       return     String
78    is
79       use Strings.Fixed;
80       I : constant Natural := Index (Filename, ".", Strings.Backward);
81    begin
82       if I = 0 then
83          return Filename;
84       else
85          if New_Ext = "" then
86             return Head (Filename, I - 1);
87          else
88             return Head (Filename, I - 1) & '.' & New_Ext;
89          end if;
90       end if;
91    end Ext_To;
92
93 end MDLL.Fil;