1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- I N T E R F A C E S . F O R T R A N --
9 -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 package body Interfaces.Fortran is
40 -- Single character case
42 function To_Ada (Item : in Character_Set) return Character is
44 return Character (Item);
47 -- String case (function returning converted result)
49 function To_Ada (Item : in Fortran_Character) return String is
50 T : String (1 .. Item'Length);
54 T (J) := Character (Item (J - 1 + Item'First));
60 -- String case (procedure copying converted string to given buffer)
63 (Item : in Fortran_Character;
68 if Item'Length = 0 then
72 elsif Target'Length = 0 then
73 raise Constraint_Error;
76 Last := Target'First - 1;
78 for J in Item'Range loop
81 if Last > Target'Last then
82 raise Constraint_Error;
84 Target (Last) := Character (Item (J));
96 function To_Fortran (Item : in Character) return Character_Set is
98 return Character_Set (Item);
101 -- String case (function returning converted result)
103 function To_Fortran (Item : in String) return Fortran_Character is
104 T : Fortran_Character (1 .. Item'Length);
107 for J in T'Range loop
108 T (J) := Character_Set (Item (J - 1 + Item'First));
114 -- String case (procedure copying converted string to given buffer)
118 Target : out Fortran_Character;
122 if Item'Length = 0 then
126 elsif Target'Length = 0 then
127 raise Constraint_Error;
130 Last := Target'First - 1;
132 for J in Item'Range loop
135 if Last > Target'Last then
136 raise Constraint_Error;
138 Target (Last) := Character_Set (Item (J));
144 end Interfaces.Fortran;