1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 1992-2001, Free Software Foundation, Inc. --
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. --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
27 ------------------------------------------------------------------------------
29 with Hostparm
; use Hostparm
;
32 package body Stylesw
is
34 -------------------------------
35 -- Reset_Style_Check_Options --
36 -------------------------------
38 procedure Reset_Style_Check_Options
is
40 Style_Check_Indentation
:= 0;
41 Style_Check_Attribute_Casing
:= False;
42 Style_Check_Blanks_At_End
:= False;
43 Style_Check_Comments
:= False;
44 Style_Check_End_Labels
:= False;
45 Style_Check_Form_Feeds
:= False;
46 Style_Check_Horizontal_Tabs
:= False;
47 Style_Check_If_Then_Layout
:= False;
48 Style_Check_Keyword_Casing
:= False;
49 Style_Check_Layout
:= False;
50 Style_Check_Max_Line_Length
:= False;
51 Style_Check_Pragma_Casing
:= False;
52 Style_Check_References
:= False;
53 Style_Check_Specs
:= False;
54 Style_Check_Standard
:= False;
55 Style_Check_Subprogram_Order
:= False;
56 Style_Check_Tokens
:= False;
57 end Reset_Style_Check_Options
;
59 ------------------------------
60 -- Save_Style_Check_Options --
61 ------------------------------
63 procedure Save_Style_Check_Options
(Options
: out Style_Check_Options
) is
67 procedure Add
(C
: Character; S
: Boolean);
68 -- Add given character C to string if switch S is true
70 procedure Add
(C
: Character; S
: Boolean) is
78 -- Start of processing for Save_Style_Check_Options
81 for K
in Options
'Range loop
85 Add
(Character'Val (Style_Check_Indentation
+ Character'Pos ('0')),
86 Style_Check_Indentation
/= 0);
88 Add
('a', Style_Check_Attribute_Casing
);
89 Add
('b', Style_Check_Blanks_At_End
);
90 Add
('c', Style_Check_Comments
);
91 Add
('e', Style_Check_End_Labels
);
92 Add
('f', Style_Check_Form_Feeds
);
93 Add
('h', Style_Check_Horizontal_Tabs
);
94 Add
('i', Style_Check_If_Then_Layout
);
95 Add
('k', Style_Check_Keyword_Casing
);
96 Add
('l', Style_Check_Layout
);
97 Add
('m', Style_Check_Max_Line_Length
);
98 Add
('n', Style_Check_Standard
);
99 Add
('o', Style_Check_Subprogram_Order
);
100 Add
('p', Style_Check_Pragma_Casing
);
101 Add
('r', Style_Check_References
);
102 Add
('s', Style_Check_Specs
);
103 Add
('t', Style_Check_Tokens
);
105 if Style_Check_Max_Line_Length
then
107 J
:= Natural (Style_Max_Line_Length
);
110 Options
(P
) := Character'Val (J
mod 10 + Character'Pos ('0'));
119 end Save_Style_Check_Options
;
121 -------------------------------------
122 -- Set_Default_Style_Check_Options --
123 -------------------------------------
125 procedure Set_Default_Style_Check_Options
is
127 Reset_Style_Check_Options
;
128 Set_Style_Check_Options
("3abcefhiklmnprst");
129 end Set_Default_Style_Check_Options
;
131 -----------------------------
132 -- Set_Style_Check_Options --
133 -----------------------------
135 -- Version used when no error checking is required
137 procedure Set_Style_Check_Options
(Options
: String) is
142 Set_Style_Check_Options
(Options
, OK
, EC
);
143 end Set_Style_Check_Options
;
145 -- Normal version with error checking
147 procedure Set_Style_Check_Options
150 Err_Col
: out Natural)
157 while J
<= Options
'Last loop
163 Style_Check_Indentation
164 := Character'Pos (C
) - Character'Pos ('0');
167 Style_Check_Attribute_Casing
:= True;
170 Style_Check_Blanks_At_End
:= True;
173 Style_Check_Comments
:= True;
176 Style_Check_End_Labels
:= True;
179 Style_Check_Form_Feeds
:= True;
182 Style_Check_Horizontal_Tabs
:= True;
185 Style_Check_If_Then_Layout
:= True;
188 Style_Check_Keyword_Casing
:= True;
191 Style_Check_Layout
:= True;
194 Style_Check_Max_Line_Length
:= True;
195 Style_Max_Line_Length
:= 79;
198 Style_Check_Standard
:= True;
201 Style_Max_Line_Length
:= 0;
204 or else Options
(J
) not in '0' .. '9'
212 Style_Max_Line_Length
:=
213 Style_Max_Line_Length
* 10 +
214 Character'Pos (Options
(J
)) - Character'Pos ('0');
216 exit when J
> Options
'Last
217 or else Options
(J
) not in '0' .. '9';
220 Style_Max_Line_Length
:=
221 Int
'Min (Style_Max_Line_Length
, Hostparm
.Max_Line_Length
);
223 Style_Check_Max_Line_Length
:= Style_Max_Line_Length
/= 0;
226 Style_Check_Subprogram_Order
:= True;
229 Style_Check_Pragma_Casing
:= True;
232 Style_Check_References
:= True;
235 Style_Check_Specs
:= True;
238 Style_Check_Tokens
:= True;
252 Err_Col
:= Options
'Last + 1;
253 end Set_Style_Check_Options
;