1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 1992-2001, Free Software Foundation, Inc. --
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. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
26 ------------------------------------------------------------------------------
28 with Hostparm; use Hostparm;
31 package body Stylesw is
33 -------------------------------
34 -- Reset_Style_Check_Options --
35 -------------------------------
37 procedure Reset_Style_Check_Options is
39 Style_Check_Indentation := 0;
40 Style_Check_Attribute_Casing := False;
41 Style_Check_Blanks_At_End := False;
42 Style_Check_Comments := False;
43 Style_Check_End_Labels := False;
44 Style_Check_Form_Feeds := False;
45 Style_Check_Horizontal_Tabs := False;
46 Style_Check_If_Then_Layout := False;
47 Style_Check_Keyword_Casing := False;
48 Style_Check_Layout := False;
49 Style_Check_Max_Line_Length := False;
50 Style_Check_Pragma_Casing := False;
51 Style_Check_References := False;
52 Style_Check_Specs := False;
53 Style_Check_Standard := False;
54 Style_Check_Subprogram_Order := False;
55 Style_Check_Tokens := False;
56 end Reset_Style_Check_Options;
58 ------------------------------
59 -- Save_Style_Check_Options --
60 ------------------------------
62 procedure Save_Style_Check_Options (Options : out Style_Check_Options) is
66 procedure Add (C : Character; S : Boolean);
67 -- Add given character C to string if switch S is true
69 procedure Add (C : Character; S : Boolean) is
77 -- Start of processing for Save_Style_Check_Options
80 for K in Options'Range loop
84 Add (Character'Val (Style_Check_Indentation + Character'Pos ('0')),
85 Style_Check_Indentation /= 0);
87 Add ('a', Style_Check_Attribute_Casing);
88 Add ('b', Style_Check_Blanks_At_End);
89 Add ('c', Style_Check_Comments);
90 Add ('e', Style_Check_End_Labels);
91 Add ('f', Style_Check_Form_Feeds);
92 Add ('h', Style_Check_Horizontal_Tabs);
93 Add ('i', Style_Check_If_Then_Layout);
94 Add ('k', Style_Check_Keyword_Casing);
95 Add ('l', Style_Check_Layout);
96 Add ('m', Style_Check_Max_Line_Length);
97 Add ('n', Style_Check_Standard);
98 Add ('o', Style_Check_Subprogram_Order);
99 Add ('p', Style_Check_Pragma_Casing);
100 Add ('r', Style_Check_References);
101 Add ('s', Style_Check_Specs);
102 Add ('t', Style_Check_Tokens);
104 if Style_Check_Max_Line_Length then
106 J := Natural (Style_Max_Line_Length);
109 Options (P) := Character'Val (J mod 10 + Character'Pos ('0'));
118 end Save_Style_Check_Options;
120 -------------------------------------
121 -- Set_Default_Style_Check_Options --
122 -------------------------------------
124 procedure Set_Default_Style_Check_Options is
126 Reset_Style_Check_Options;
127 Set_Style_Check_Options ("3abcefhiklmnprst");
128 end Set_Default_Style_Check_Options;
130 -----------------------------
131 -- Set_Style_Check_Options --
132 -----------------------------
134 -- Version used when no error checking is required
136 procedure Set_Style_Check_Options (Options : String) is
141 Set_Style_Check_Options (Options, OK, EC);
142 end Set_Style_Check_Options;
144 -- Normal version with error checking
146 procedure Set_Style_Check_Options
149 Err_Col : out Natural)
156 while J <= Options'Last loop
162 Style_Check_Indentation
163 := Character'Pos (C) - Character'Pos ('0');
166 Style_Check_Attribute_Casing := True;
169 Style_Check_Blanks_At_End := True;
172 Style_Check_Comments := True;
175 Style_Check_End_Labels := True;
178 Style_Check_Form_Feeds := True;
181 Style_Check_Horizontal_Tabs := True;
184 Style_Check_If_Then_Layout := True;
187 Style_Check_Keyword_Casing := True;
190 Style_Check_Layout := True;
193 Style_Check_Max_Line_Length := True;
194 Style_Max_Line_Length := 79;
197 Style_Check_Standard := True;
200 Style_Max_Line_Length := 0;
203 or else Options (J) not in '0' .. '9'
211 Style_Max_Line_Length :=
212 Style_Max_Line_Length * 10 +
213 Character'Pos (Options (J)) - Character'Pos ('0');
215 exit when J > Options'Last
216 or else Options (J) not in '0' .. '9';
219 Style_Max_Line_Length :=
220 Int'Min (Style_Max_Line_Length, Hostparm.Max_Line_Length);
222 Style_Check_Max_Line_Length := Style_Max_Line_Length /= 0;
225 Style_Check_Subprogram_Order := True;
228 Style_Check_Pragma_Casing := True;
231 Style_Check_References := True;
234 Style_Check_Specs := True;
237 Style_Check_Tokens := True;
251 Err_Col := Options'Last + 1;
252 end Set_Style_Check_Options;