OSDN Git Service

* 41intnam.ads, 42intnam.ads, 4aintnam.ads, 4cintnam.ads,
[pf3gnuchains/gcc-fork.git] / gcc / ada / g-casuti.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUNTIME COMPONENTS                          --
4 --                                                                          --
5 --                       G N A T . C A S E _ U T I L                        --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --                            $Revision: 1.4 $                              --
10 --                                                                          --
11 --           Copyright (C) 1995-1999 Ada Core Technologies, Inc.            --
12 --                                                                          --
13 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
14 -- terms of the  GNU General Public License as published  by the Free Soft- --
15 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
16 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
19 -- for  more details.  You should have  received  a copy of the GNU General --
20 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
21 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
22 -- MA 02111-1307, USA.                                                      --
23 --                                                                          --
24 -- As a special exception,  if other files  instantiate  generics from this --
25 -- unit, or you link  this unit with other files  to produce an executable, --
26 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
27 -- covered  by the  GNU  General  Public  License.  This exception does not --
28 -- however invalidate  any other reasons why  the executable file  might be --
29 -- covered by the  GNU Public License.                                      --
30 --                                                                          --
31 -- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).   --
32 --                                                                          --
33 ------------------------------------------------------------------------------
34
35 package body GNAT.Case_Util is
36
37    --------------
38    -- To_Lower --
39    --------------
40
41    function To_Lower (A : Character) return Character is
42       A_Val : constant Natural := Character'Pos (A);
43
44    begin
45       if A in 'A' .. 'Z'
46         or else A_Val in 16#C0# .. 16#D6#
47         or else A_Val in 16#D8# .. 16#DE#
48       then
49          return Character'Val (A_Val + 16#20#);
50       else
51          return A;
52       end if;
53    end To_Lower;
54
55    procedure To_Lower (A : in out String) is
56    begin
57       for J in A'Range loop
58          A (J) := To_Lower (A (J));
59       end loop;
60    end To_Lower;
61
62    --------------
63    -- To_Mixed --
64    --------------
65
66    procedure To_Mixed (A : in out String) is
67       Ucase : Boolean := True;
68
69    begin
70       for J in A'Range loop
71          if Ucase then
72             A (J) := To_Upper (A (J));
73          else
74             A (J) := To_Lower (A (J));
75          end if;
76
77          Ucase := A (J) = '_';
78       end loop;
79    end To_Mixed;
80
81    --------------
82    -- To_Upper --
83    --------------
84
85    function To_Upper (A : Character) return Character is
86       A_Val : constant Natural := Character'Pos (A);
87
88    begin
89       if A in 'a' .. 'z'
90         or else A_Val in 16#E0# .. 16#F6#
91         or else A_Val in 16#F8# .. 16#FE#
92       then
93          return Character'Val (A_Val - 16#20#);
94       else
95          return A;
96       end if;
97    end To_Upper;
98
99    procedure To_Upper (A : in out String) is
100    begin
101       for J in A'Range loop
102          A (J) := To_Upper (A (J));
103       end loop;
104    end To_Upper;
105
106 end GNAT.Case_Util;