Merge lp:~onox/deplo/deplo into lp:deplo

Proposed by onox
Status: Merged
Approved by: Riccardo Bernardini
Approved revision: 32
Merged at revision: 32
Proposed branch: lp:~onox/deplo/deplo
Merge into: lp:deplo
Diff against target: 1885 lines (+278/-380)
29 files modified
command_line_parameters.adb (+8/-17)
command_line_parameters.ads (+0/-2)
dependency_graphs.adb (+4/-6)
dependency_graphs.ads (+2/-4)
deplo.adb (+2/-2)
deplo.gpr (+21/-4)
generic_line_parser.adb (+18/-23)
generic_line_parser.ads (+67/-71)
indented_io.adb (+2/-2)
indented_io.ads (+3/-5)
input.adb (+5/-15)
line_arrays.adb (+1/-4)
line_arrays.ads (+0/-1)
node_processing.adb (+5/-12)
node_processing.ads (+1/-2)
output.adb (+5/-16)
output.ads (+3/-2)
package_db.ads (+0/-1)
package_names.adb (+8/-11)
package_names.ads (+1/-4)
package_trees.adb (+4/-8)
package_trees.ads (+1/-10)
sectioned_text.adb (+9/-18)
sectioned_text.ads (+0/-6)
style_table.adb (+13/-20)
style_table.ads (+1/-3)
test/test_sectioned_text.adb (+7/-8)
tokenize.adb (+47/-51)
tokenize.ads (+40/-52)
To merge this branch: bzr merge lp:~onox/deplo/deplo
Reviewer Review Type Date Requested Status
Riccardo Bernardini Pending
Review via email: mp+113637@code.launchpad.net

Description of the change

I fixed a bunch of style warnings that are shown by GNAT if some -gnat options are added. Also introduced a change to deplo.gpr so that you can have different switches for debug builds and builds for users (no developers). There are still a couple of warnings (about redundant use type clauses and incorrect indention of labels) that remain.

I haven't actually tested the changes (bad bad I know :)), but my exams are over so I could afford to waste some time :p Feel free to merge it or not.

I usually also add a gnat.adc file to my projects to add some restrictions. Something like this:

pragma Restrictions (No_Obsolescent_Features);
pragma Restrictions (No_Recursion);
pragma Restrictions (No_Relative_Delay);

In that case you need to add to package Compiler in deplo.gpr the following:

for Local_Configuration_Pragmas use "gnat.adc";

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'command_line_parameters.adb'
2--- command_line_parameters.adb 2012-06-29 11:46:21 +0000
3+++ command_line_parameters.adb 2012-07-05 20:01:18 +0000
4@@ -22,14 +22,12 @@
5 with Ada.Command_Line;
6 with Generic_Line_Parser;
7 with Ada.Strings.Fixed;
8-with Package_Names;
9 with Ada.Exceptions;
10 with Sectioned_Text;
11 with Line_Arrays;
12 with Ada.Text_IO;
13
14 package body Command_Line_Parameters is
15- use Ada.Strings.Unbounded;
16 use Package_Names;
17
18 package Line_Parsers is
19@@ -65,8 +63,6 @@
20 function "+" (X : Unbounded_String) return String
21 renames To_String;
22
23-
24-
25 -------------------------
26 -- Input_Name_Callback --
27 -------------------------
28@@ -92,11 +88,10 @@
29
30 pragma Unreferenced (Name);
31 begin
32- Ada.Text_Io.Put_Line ("SPEC: " & To_String (Value));
33- Result.Style_Spec.Append (Style_Spec(To_String (Value)));
34+ Ada.Text_IO.Put_Line ("SPEC: " & To_String (Value));
35+ Result.Style_Spec.Append (Style_Spec (To_String (Value)));
36 end Style_Spec_Callback;
37
38-
39 ---------------------------
40 -- Input_Format_Callback --
41 ---------------------------
42@@ -123,7 +118,6 @@
43 Result.Output_Format := Value;
44 end Output_Format_Callback;
45
46-
47 -------------------
48 -- Trim_Callback --
49 -------------------
50@@ -170,8 +164,7 @@
51 end if;
52 end Iterate_Over_Section;
53
54-
55- Classifier : Basic_Line_Classifier :=
56+ Classifier : constant Basic_Line_Classifier :=
57 New_Classifier (Head => "[",
58 Tail => "]",
59 Comments => "#",
60@@ -180,7 +173,7 @@
61 Trim_Comments => True,
62 Ignore_Empty => True);
63
64- Sections : Section_List := Parse (+Value, Classifier);
65+ Sections : constant Section_List := Parse (+Value, Classifier);
66 begin
67 declare
68 procedure Append (Pos : Line_Containers.Cursor) is
69@@ -221,8 +214,7 @@
70
71 end Config_Callback;
72
73-
74- Syntax : Line_Parsers.Parameter_Descriptor_Array :=
75+ Syntax : constant Line_Parsers.Parameter_Descriptor_Array :=
76 ((Name => +"input",
77 Default => +"",
78 If_Missing => Line_Parsers.Ignore,
79@@ -278,16 +270,15 @@
80 Result := (Input_Name => <>,
81 Style_Spec => Style_Table.Style_Spec_Lists.Empty_List,
82 Input_Format => +"ali",
83- OutPut_Format => +"dot",
84+ Output_Format => +"dot",
85 Trim_Nodes => Package_Names.Package_Lists.Empty_List,
86 Ignore => Package_Names.Package_Lists.Empty_List);
87
88-
89 if Argument_Count = 1 and then Fixed.Index (Argument (1), "=") = 0 then
90 declare
91- Arg : String := Argument (1);
92+ Arg : constant String := Argument (1);
93 begin
94- if Arg(Arg'First) /= '@' then
95+ if Arg (Arg'First) /= '@' then
96 Result.Input_Name.Append (Argument (1));
97 else
98 Config_Callback (Name => Null_Unbounded_String,
99
100=== modified file 'command_line_parameters.ads'
101--- command_line_parameters.ads 2012-06-13 20:24:08 +0000
102+++ command_line_parameters.ads 2012-07-05 20:01:18 +0000
103@@ -27,7 +27,6 @@
104 package Command_Line_Parameters is
105 use Ada.Strings.Unbounded;
106
107-
108 package String_Lists is
109 new Ada.Containers.Indefinite_Doubly_Linked_Lists (String);
110
111@@ -45,4 +44,3 @@
112
113 User_Error : exception;
114 end Command_Line_Parameters;
115-
116
117=== modified file 'dependency_graphs.adb'
118--- dependency_graphs.adb 2012-06-09 10:32:54 +0000
119+++ dependency_graphs.adb 2012-07-05 20:01:18 +0000
120@@ -20,8 +20,7 @@
121 ----------------------------------------------------------------------------
122 with Ada.Text_IO;
123
124-package body dependency_graphs is
125- use Package_Trees;
126+package body Dependency_Graphs is
127
128 ------------
129 -- Create --
130@@ -30,7 +29,7 @@
131 function Create (N_Nodes : Positive) return Graph_Access is
132
133 begin
134- return new Dependency_Graph'(N_Nodes => Package_Index(N_Nodes),
135+ return new Dependency_Graph'(N_Nodes => Package_Index (N_Nodes),
136 Adjacency => (others => (others => False)));
137 end Create;
138
139@@ -44,7 +43,7 @@
140 Withed : in Package_Trees.Cursor)
141 is
142 begin
143- Graph.Adjacency(Index(Wither), Index(Withed)) := True;
144+ Graph.Adjacency (Index (Wither), Index (Withed)) := True;
145 end Add_Dependency;
146
147 -----------------------
148@@ -96,5 +95,4 @@
149 end loop;
150 end Dump;
151
152-
153-end dependency_graphs;
154+end Dependency_Graphs;
155
156=== modified file 'dependency_graphs.ads'
157--- dependency_graphs.ads 2012-06-09 10:32:54 +0000
158+++ dependency_graphs.ads 2012-07-05 20:01:18 +0000
159@@ -34,8 +34,7 @@
160 --
161 with Package_Trees;
162
163-
164-package dependency_graphs is
165+package Dependency_Graphs is
166 type Dependency_Graph (<>) is tagged private;
167
168 type Graph_Access is access Dependency_Graph;
169@@ -50,7 +49,6 @@
170 Wither : in Package_Trees.Cursor;
171 Withed : in Package_Trees.Cursor);
172
173-
174 procedure Iterate_Over_Withed
175 (Graph : Dependency_Graph;
176 Wither : Package_Trees.Cursor;
177@@ -71,4 +69,4 @@
178 record
179 Adjacency : Adjacency_Matrix (1 .. N_Nodes, 1 .. N_Nodes);
180 end record;
181-end dependency_graphs;
182+end Dependency_Graphs;
183
184=== modified file 'deplo.adb'
185--- deplo.adb 2012-06-28 18:24:52 +0000
186+++ deplo.adb 2012-07-05 20:01:18 +0000
187@@ -50,8 +50,8 @@
188 Parameters := Command_Line_Parameters.Parse_Command_Line;
189
190 declare
191- Input_Format : String := +Parameters.Input_Format;
192- Output_Format : String := +Parameters.Output_Format;
193+ Input_Format : constant String := +Parameters.Input_Format;
194+ Output_Format : constant String := +Parameters.Output_Format;
195 begin
196 if not Input.Is_Known (Input_Format) then
197 raise Command_Line_Parameters.User_Error
198
199=== modified file 'deplo.gpr'
200--- deplo.gpr 2012-06-16 09:35:15 +0000
201+++ deplo.gpr 2012-07-05 20:01:18 +0000
202@@ -4,20 +4,37 @@
203 for Object_Dir use "obj/";
204 for Source_Dirs use (".", "test");
205
206+ type Mode_Type is ("debug", "release");
207+
208+ Mode : Mode_Type := external ("mode", "release");
209+
210 package Compiler is
211- for Default_Switches ("ada") use ("-g", "-O2", "-gnata", "-gnat05", "-fstack-check", "-gnato", "-gnatwu");
212+ Ada_Switches := ("-O2", "-march=native", "-gnata", "-gnat05", "-fstack-check", "-gnato", "-gnatwu", "-gnatv", "-gnatf", "-gnatVa", "-gnatwa", "-gnaty", "-gnatyduxO", "-gnaty-ms");
213+
214+ case Mode is
215+ when "debug" =>
216+ for Default_Switches ("ada") use Ada_Switches & ("-g");
217+ when "release" =>
218+ for Default_Switches ("ada") use Ada_Switches & ("-fomit-frame-pointer");
219+ end case;
220 end Compiler;
221
222 package Builder is
223- for Default_Switches ("ada") use ("-g", "-s");
224+ case Mode is
225+ when "debug" =>
226+ for Default_Switches ("ada") use ("-g", "-s");
227+ end case;
228 end Builder;
229
230 package Binder is
231- for Default_Switches ("ada") use ("-E");
232+ for Default_Switches ("ada") use ("-E"); -- Store tracebacks in exception occurrences
233 end Binder;
234
235 package Linker is
236- for Default_Switches ("ada") use ("-g");
237+ case Mode is
238+ when "debug" =>
239+ for Default_Switches ("ada") use ("-g");
240+ end case;
241 end Linker;
242
243 end Deplo;
244
245=== modified file 'generic_line_parser.adb'
246--- generic_line_parser.adb 2012-06-14 13:00:27 +0000
247+++ generic_line_parser.adb 2012-07-05 20:01:18 +0000
248@@ -21,7 +21,6 @@
249 --
250 with Ada.Command_Line;
251 with Ada.Strings.Fixed;
252-with Ada.Text_IO;
253 with Ada.Containers.Ordered_Maps;
254 with Ada.Strings.Maps.Constants;
255 with Ada.Containers.Doubly_Linked_Lists;
256@@ -38,8 +37,8 @@
257 function To_U (X : String) return Unbounded_String
258 renames To_Unbounded_String;
259
260- -- In order to handle parameter aliases (see comments in the specs)
261- -- we keep a table that maps parameter names to parameter "index"
262+ -- In order to handle parameter aliases (see comments in the specs)
263+ -- we keep a table that maps parameter names to parameter "index"
264 package Name_To_Index_Maps is
265 new Ada.Containers.Ordered_Maps (Key_Type => Unbounded_String,
266 Element_Type => Natural);
267@@ -48,8 +47,8 @@
268 -- Case_Normalize --
269 --------------------
270
271- -- If the user required case insensitive matching, force the
272- -- name to lower case
273+ -- If the user required case insensitive matching, force the
274+ -- name to lower case
275 procedure Case_Normalize (Name : in out Unbounded_String) is
276 begin
277 if not Case_Sensitive then
278@@ -61,8 +60,8 @@
279 -- Fill_Name_Table --
280 ---------------------
281
282- -- Fill the Parameter Name -> parameter index table with the
283- -- parameter names
284+ -- Fill the Parameter Name -> parameter index table with the
285+ -- parameter names
286 procedure Fill_Name_Table (Parameters : in Parameter_Descriptor_Array;
287 Name_Table : in out Name_To_Index_Maps.Map)
288 is
289@@ -96,7 +95,7 @@
290 end Trimmed_Name;
291
292 Result : Name_Lists.List;
293- Buffer : String := To_S (Name);
294+ Buffer : constant String := To_S (Name);
295 First : Natural;
296 Comma_Pos : Natural;
297 begin
298@@ -104,7 +103,7 @@
299 raise Constraint_Error with "Option label '" & Buffer & "' has '='";
300 end if;
301
302- if Buffer(Buffer'Last) = ',' then
303+ if Buffer (Buffer'Last) = ',' then
304 raise Constraint_Error
305 with "Option label '" & Buffer & "' ends with ','";
306 end if;
307@@ -117,20 +116,20 @@
308 exit when Comma_Pos = 0;
309
310 if First = Comma_Pos then
311- -- First should always point to the beginning of a
312- -- label, therefore it cannot be Buffer(First) = ','
313+ -- First should always point to the beginning of a
314+ -- label, therefore it cannot be Buffer(First) = ','
315 raise Constraint_Error
316 with "Wrong syntax in Option label '" & Buffer & "'";
317 end if;
318
319 pragma Assert (Comma_Pos > First);
320
321- Result.Append (Trimmed_Name (Buffer(First .. Comma_Pos - 1)));
322+ Result.Append (Trimmed_Name (Buffer (First .. Comma_Pos - 1)));
323
324 First := Comma_Pos + 1;
325
326- -- It cannot be First > Buffer'Last since Buffer(Comma_Pos) = '='
327- -- and Buffer(Buffer'Last) /= ','
328+ -- It cannot be First > Buffer'Last since Buffer(Comma_Pos) = '='
329+ -- and Buffer(Buffer'Last) /= ','
330 pragma Assert (First <= Buffer'Last);
331 end loop;
332
333@@ -155,7 +154,7 @@
334 Name := Name_Lists.Element (Position);
335 Name_Lists.Next (Position);
336
337- Case_Normalize(Name);
338+ Case_Normalize (Name);
339
340 if Name_Table.Contains (Name) then
341 raise Constraint_Error
342@@ -167,7 +166,6 @@
343 end loop;
344 end Fill_Name_Table;
345
346-
347 ----------------
348 -- To_Natural --
349 ----------------
350@@ -176,7 +174,7 @@
351 return Natural is
352 begin
353 if X = Null_Unbounded_String then
354- raise Bad_Command with "Invalid integer '" & To_S(X) & "'";
355+ raise Bad_Command with "Invalid integer '" & To_S (X) & "'";
356 end if;
357
358 return Natural'Value (To_S (X));
359@@ -190,13 +188,12 @@
360 return Float is
361 begin
362 if X = Null_Unbounded_String then
363- raise Bad_Command with "Invalid Float '" & To_S(X) & "'";
364+ raise Bad_Command with "Invalid Float '" & To_S (X) & "'";
365 end if;
366
367 return Float'Value (To_S (X));
368 end To_Float;
369
370-
371 ------------------------
372 -- Parse_Command_Line --
373 ------------------------
374@@ -223,7 +220,7 @@
375 Idx := Index (Source => Param,
376 Pattern => "=");
377
378- if (Idx = 0) then
379+ if Idx = 0 then
380 Name := To_U (Param);
381 Value := Null_Unbounded_String;
382 else
383@@ -251,7 +248,7 @@
384 begin
385 Item.Iterate (Append'Access);
386
387- return To_String(Result);
388+ return To_String (Result);
389 end Join;
390
391 use type Ada.Containers.Count_Type;
392@@ -263,7 +260,6 @@
393 end if;
394 end Missing_Message;
395
396-
397 Found : array (Parameters'Range) of Boolean := (others => False);
398
399 Name : Unbounded_String;
400@@ -341,7 +337,6 @@
401 Name_To_Index_Maps.Next (Position);
402 end loop;
403
404-
405 if not Missing.Is_Empty then
406 raise Bad_Command with Missing_Message (Missing);
407 end if;
408
409=== modified file 'generic_line_parser.ads'
410--- generic_line_parser.ads 2012-06-09 10:32:54 +0000
411+++ generic_line_parser.ads 2012-07-05 20:01:18 +0000
412@@ -20,63 +20,63 @@
413 ----------------------------------------------------------------------------
414 --
415
416--- <summary>
417--- <p>This is a generic package implementing a simple-to-use command line
418--- parser. Yes, I know, everyone makes his/her own command line parser...
419--- so, I wrote mine. As they say, every open source project starts
420--- with a programmer that schratches its own itch. So I did... If
421--- you find this useful, you are welcome to use it.</p>
422---
423--- <p>The ideas behind this package are the following
424---
425--- <itemize>
426--- <item> <p>Parameters are nominal, non positional. The syntax is of
427--- "named parameter" type, that is, each command line parameter is
428--- expected to have thefollowing format</p>
429---
430--- <center>label ['=' value]</center>
431---
432--- <p>where "label" is any string without '='.</p></item>
433---
434--- <item><p> Parsed value are written in a "configuration variable" whose type
435--- is a formal parameter of this package. The values are written
436--- in the configuration variable by using some callbacks provided
437--- by caller.</p></item>
438--- </itemize>
439--- </p>
440--- The names of the parameters are given to the parser in "parameter
441--- description array" that is an array of records that specify
442---
443--- + The parameter name
444---
445--- + A default value (if needed)
446---
447--- + What to do if the parameter is missing
448---
449--- + If it can be specified more than once
450---
451--- + The callback function to be called when the parameter is found
452---
453--- In order to parse the command line it suffices to call Parse_Command_Line
454--- giving as argument the array of parameter descriptors and the configuration
455--- variable to be written. For every parameter found, the corresponding
456--- callback function is called. If at the end of the parsing there are some
457--- optional parameters that were missing from the command line, the
458--- corresponding callbacks are called with the default parameter.
459--- </summary>
460+-- <summary>
461+-- <p>This is a generic package implementing a simple-to-use command line
462+-- parser. Yes, I know, everyone makes his/her own command line parser...
463+-- so, I wrote mine. As they say, every open source project starts
464+-- with a programmer that schratches its own itch. So I did... If
465+-- you find this useful, you are welcome to use it.</p>
466+--
467+-- <p>The ideas behind this package are the following
468+--
469+-- <itemize>
470+-- <item> <p>Parameters are nominal, non positional. The syntax is of
471+-- "named parameter" type, that is, each command line parameter is
472+-- expected to have thefollowing format</p>
473+--
474+-- <center>label ['=' value]</center>
475+--
476+-- <p>where "label" is any string without '='.</p></item>
477+--
478+-- <item><p> Parsed value are written in a "configuration variable" whose type
479+-- is a formal parameter of this package. The values are written
480+-- in the configuration variable by using some callbacks provided
481+-- by caller.</p></item>
482+-- </itemize>
483+-- </p>
484+-- The names of the parameters are given to the parser in "parameter
485+-- description array" that is an array of records that specify
486+--
487+-- + The parameter name
488+--
489+-- + A default value (if needed)
490+--
491+-- + What to do if the parameter is missing
492+--
493+-- + If it can be specified more than once
494+--
495+-- + The callback function to be called when the parameter is found
496+--
497+-- In order to parse the command line it suffices to call Parse_Command_Line
498+-- giving as argument the array of parameter descriptors and the configuration
499+-- variable to be written. For every parameter found, the corresponding
500+-- callback function is called. If at the end of the parsing there are some
501+-- optional parameters that were missing from the command line, the
502+-- corresponding callbacks are called with the default parameter.
503+-- </summary>
504
505 with Ada.Strings.Unbounded;
506 with Ada.Text_IO;
507
508 generic
509 type Config_Data (<>) is limited private;
510- -- The parameters read from the command line will be written in
511- -- a variable of this type
512+ -- The parameters read from the command line will be written in
513+ -- a variable of this type
514
515 Case_Sensitive : Boolean := True;
516- -- Set this to False if you want case insensitive option matching.
517- -- For example, if you set this to False, "input", "Input", "INPUT"
518- -- and "InPuT" will be equivalent names for the option "input"
519+ -- Set this to False if you want case insensitive option matching.
520+ -- For example, if you set this to False, "input", "Input", "INPUT"
521+ -- and "InPuT" will be equivalent names for the option "input"
522 package Generic_Line_Parser is
523 use Ada.Strings.Unbounded;
524
525@@ -107,44 +107,40 @@
526 Only_Once : Boolean; -- Parameter MUST NOT be given more than once
527 Callback : Parameter_Callback; -- Called when parameter found
528 end record;
529- -- <description>Record holding the description of a parameter. The fields
530- -- should be self-explenatory (I hope). The only field that needs some
531- -- explanation is Name since it allows to specify more than one
532- -- name for each parameter. The syntax is very simple: just separate
533- -- the names with commas. For example, if Name is "f,filename,input"
534- -- one can use on the command line, with the same effect f=/tmp/a.txt or
535- -- filename=/tmp/a.txt or input=/tmp/a.txt. Spaces at both ends of
536- -- the label name are trimmed, so that, for example, "f,filename,input"
537- -- is equivalent to "f , filename ,input "
538- -- </description>
539-
540+ -- <description>Record holding the description of a parameter. The fields
541+ -- should be self-explenatory (I hope). The only field that needs some
542+ -- explanation is Name since it allows to specify more than one
543+ -- name for each parameter. The syntax is very simple: just separate
544+ -- the names with commas. For example, if Name is "f,filename,input"
545+ -- one can use on the command line, with the same effect f=/tmp/a.txt or
546+ -- filename=/tmp/a.txt or input=/tmp/a.txt. Spaces at both ends of
547+ -- the label name are trimmed, so that, for example, "f,filename,input"
548+ -- is equivalent to "f , filename ,input "
549+ -- </description>
550
551 type Parameter_Descriptor_Array is
552 array (Natural range <>) of Parameter_Descriptor;
553
554-
555 procedure Parse_Command_Line
556 (Parameters : in Parameter_Descriptor_Array;
557 Result : out Config_Data;
558 Help_Line : in String := "";
559 Help_Output : in Ada.Text_IO.File_Type := Ada.Text_IO.Standard_Error);
560- -- Main exported method. It parses the command line and it writes
561- -- the result in Result. If some error is encountered, Bad_Command
562- -- is raised with an explicative exception message. If Help_Line is
563- -- not empty, it is written to Help_Output in case of error.
564+ -- Main exported method. It parses the command line and it writes
565+ -- the result in Result. If some error is encountered, Bad_Command
566+ -- is raised with an explicative exception message. If Help_Line is
567+ -- not empty, it is written to Help_Output in case of error.
568
569 Bad_Command : exception;
570
571-
572-
573 function To_Float (X : Unbounded_String)
574 return Float;
575- -- Convenient conversion function to Float that raise Bad_Command if
576- -- the argument has not a valid syntax
577+ -- Convenient conversion function to Float that raise Bad_Command if
578+ -- the argument has not a valid syntax
579
580 function To_Natural (X : Unbounded_String)
581 return Natural;
582- -- Convenient conversion function to Float that raise Bad_Command if
583- -- the argument has not a valid syntax
584+ -- Convenient conversion function to Float that raise Bad_Command if
585+ -- the argument has not a valid syntax
586
587 end Generic_Line_Parser;
588
589=== modified file 'indented_io.adb'
590--- indented_io.adb 2012-06-09 10:32:54 +0000
591+++ indented_io.adb 2012-07-05 20:01:18 +0000
592@@ -145,10 +145,10 @@
593 -- DeCrease_Tab --
594 ------------------
595
596- procedure DeCrease_Tab (Indenter : in out Indenter_Type) is
597+ procedure Decrease_Tab (Indenter : in out Indenter_Type) is
598 begin
599 Indenter.Current_Indent :=
600 Integer'Max (0, Indenter.Current_Indent - Indenter.Indent_Step);
601- end DeCrease_Tab;
602+ end Decrease_Tab;
603
604 end Indented_IO;
605
606=== modified file 'indented_io.ads'
607--- indented_io.ads 2012-06-09 10:32:54 +0000
608+++ indented_io.ads 2012-07-05 20:01:18 +0000
609@@ -62,12 +62,10 @@
610 -- Equivalent to Put followed by New_Line
611
612 procedure Increase_Tab (Indenter : in out Indenter_Type);
613- -- Increase the indentation level by the Tab amount
614+ -- Increase the indentation level by the Tab amount
615
616 procedure Decrease_Tab (Indenter : in out Indenter_Type);
617- -- Decrease the indentation level by the Tab amount
618-
619-
620+ -- Decrease the indentation level by the Tab amount
621
622 procedure Open_Block (Indenter : in out Indenter_Type;
623 Line : in String := "");
624@@ -98,7 +96,7 @@
625 private
626 type Indenter_Type is tagged
627 record
628- File : Ada.Text_Io.File_Access;
629+ File : Ada.Text_IO.File_Access;
630 Current_Indent : Natural := 0;
631 Indent_Step : Natural := 4;
632 Begin_Of_Line : Boolean := True;
633
634=== modified file 'input.adb'
635--- input.adb 2012-07-05 14:37:11 +0000
636+++ input.adb 2012-07-05 20:01:18 +0000
637@@ -28,7 +28,6 @@
638 with Ada.Directories;
639 with Package_Names;
640 with Ada.Strings.Equal_Case_Insensitive;
641-with Command_Line_Parameters;
642
643 package body Input is
644 use Package_Trees;
645@@ -37,7 +36,6 @@
646
647 type Filename_Type is new String;
648
649-
650 package Filename_Lists is
651 new Ada.Containers.Indefinite_Doubly_Linked_Lists (Filename_Type);
652
653@@ -48,10 +46,10 @@
654 function Filename_To_Package (Item : Filename_Type) return Package_Name is
655 use Ada.Strings;
656
657- Dash_To_Dot : Maps.Character_Mapping := Maps.To_Mapping (From => "-",
658+ Dash_To_Dot : constant Maps.Character_Mapping := Maps.To_Mapping (From => "-",
659 To => ".");
660
661- Basename : String := Ada.Directories.Base_Name (String (Item));
662+ Basename : constant String := Ada.Directories.Base_Name (String (Item));
663 begin
664 return Package_Name (Fixed.Translate (Source => String (Basename),
665 Mapping => Dash_To_Dot));
666@@ -62,8 +60,6 @@
667 return Graph_Access
668 is
669 use Filename_Lists;
670- use Dependency_Graphs;
671-
672
673 function Extract_Dependencies (Filename : Filename_Type) return Package_Lists.List is
674 use Ada.Text_IO;
675@@ -95,7 +91,7 @@
676
677 while not End_Of_File (Input) loop
678 declare
679- Pkg_Name : Package_Name := Parse_W_Line (Get_Line (Input));
680+ Pkg_Name : constant Package_Name := Parse_W_Line (Get_Line (Input));
681 begin
682 if DB.Contains (Pkg_Name) then
683 Result.Append (Pkg_Name);
684@@ -107,11 +103,11 @@
685 return Result;
686 end Extract_Dependencies;
687
688- Result : Graph_Access := Create (DB.Size);
689+ Result : constant Graph_Access := Create (DB.Size);
690
691 procedure Process_One_ALI (Position : Filename_Lists.Cursor) is
692 Wither : Package_Trees.Cursor;
693- Filename : Filename_Type := Filename_Lists.Element (Position);
694+ Filename : constant Filename_Type := Filename_Lists.Element (Position);
695 Dependencies : Package_Lists.List;
696
697 procedure Add_Dependency (Pos : Package_Lists.Cursor) is
698@@ -129,10 +125,6 @@
699 Dependencies.Iterate (Add_Dependency'Access);
700 end Process_One_ALI;
701
702-
703-
704-
705-
706 begin
707 Filenames.Iterate (Process_One_ALI'Access);
708
709@@ -166,7 +158,6 @@
710 Process => Process'Access);
711 end Populate_Tree;
712
713-
714 ---------------------------
715 -- Get_Package_Structure --
716 ---------------------------
717@@ -176,7 +167,6 @@
718 return Package_DB.DB_Type
719 is
720 pragma Unreferenced (Format);
721- use Command_Line_Parameters;
722
723 Filenames : Filename_Lists.List;
724 Result : Package_DB.DB_Type;
725
726=== modified file 'line_arrays.adb'
727--- line_arrays.adb 2012-06-28 17:58:41 +0000
728+++ line_arrays.adb 2012-07-05 20:01:18 +0000
729@@ -108,7 +108,6 @@
730 Terminator : String)
731 return String
732 is
733- use Ada.Strings.Unbounded;
734 use Line_Containers;
735
736 Result : Unbounded_String := Null_Unbounded_String;
737@@ -124,7 +123,6 @@
738 return To_String (Result);
739 end Join;
740
741-
742 ----------
743 -- Join --
744 ----------
745@@ -149,7 +147,7 @@
746 is
747 use Ada.Containers;
748
749- Diff : Integer := Right.First_Index - Left.First_Index;
750+ Diff : constant Integer := Right.First_Index - Left.First_Index;
751 begin
752 if Left.Length /= Right.Length then
753 return False;
754@@ -203,5 +201,4 @@
755 return Result;
756 end Read;
757
758-
759 end Line_Arrays;
760
761=== modified file 'line_arrays.ads'
762--- line_arrays.ads 2012-06-28 17:58:41 +0000
763+++ line_arrays.ads 2012-07-05 20:01:18 +0000
764@@ -68,7 +68,6 @@
765 -- Read a file and split its content a string into an array of lines,
766 -- splitting at the specified line terminator
767
768-
769 function Join
770 (Input : Line_Array;
771 Terminator : Valid_Line_Terminator := CR)
772
773=== modified file 'node_processing.adb'
774--- node_processing.adb 2012-06-09 10:32:54 +0000
775+++ node_processing.adb 2012-07-05 20:01:18 +0000
776@@ -19,9 +19,6 @@
777 -- along with DePlo. If not, see <http://www.gnu.org/licenses/>.
778 ----------------------------------------------------------------------------
779
780-with Package_Trees;
781-with Dependency_Graphs;
782-
783 package body Node_Processing is
784 ------------------------
785 -- Clean_Dependencies --
786@@ -68,7 +65,6 @@
787 end loop;
788 end Clean_Dependencies;
789
790-
791 ---------------------
792 -- Removed_Ignored --
793 ---------------------
794@@ -81,7 +77,6 @@
795 use Package_Names;
796 use Dependency_Graphs;
797
798-
799 procedure Copy_Not_Ignored (Target : in out Package_Tree;
800 Source : in Package_Tree;
801 Ignored : in Package_List)
802@@ -97,7 +92,7 @@
803 Target.Add (Name (Pos));
804
805 declare
806- P : Package_Trees.Cursor := Target.Find (Name (Pos));
807+ P : constant Package_Trees.Cursor := Target.Find (Name (Pos));
808
809 procedure Copy_Attribute (Name, Value : String) is
810 begin
811@@ -120,10 +115,9 @@
812
813 procedure Process (Wither : Package_Trees.Cursor;
814 Withed : Package_Trees.Cursor) is
815- use Package_Trees;
816
817- Wither_Pos : Cursor := Target.Tree.Find (Name (Wither));
818- Withed_Pos : Cursor := Target.Tree.Find (Name (Withed));
819+ Wither_Pos : constant Cursor := Target.Tree.Find (Name (Wither));
820+ Withed_Pos : constant Cursor := Target.Tree.Find (Name (Withed));
821 begin
822 if Wither_Pos /= No_Element and Withed_Pos /= No_Element then
823 Target.Graph.Add_Dependency (Wither => Wither_Pos,
824@@ -200,7 +194,7 @@
825 Trim_List : Package_List)
826 return Package_Trees.Cursor
827 is
828- Ancestor : Package_Name := Find_Ancestor (Trim_List, Name (Node));
829+ Ancestor : constant Package_Name := Find_Ancestor (Trim_List, Name (Node));
830 begin
831 if Ancestor = "" then
832 return Target.Tree.Find (Name (Node));
833@@ -215,7 +209,7 @@
834 end Process;
835 begin
836 for Index in Source.Tree.First_Index .. Source.Tree.Last_Index loop
837- Source.Graph.Iterate_Over_Withed (Wither => Source.Tree.Position(Index),
838+ Source.Graph.Iterate_Over_Withed (Wither => Source.Tree.Position (Index),
839 Process => Process'Access);
840 end loop;
841 end Collapse_Edges;
842@@ -235,5 +229,4 @@
843 return Result;
844 end Collapse_Nodes;
845
846-
847 end Node_Processing;
848
849=== modified file 'node_processing.ads'
850--- node_processing.ads 2012-06-09 10:32:54 +0000
851+++ node_processing.ads 2012-07-05 20:01:18 +0000
852@@ -28,7 +28,7 @@
853
854 with Package_DB;
855 with Package_Names;
856-with dependency_graphs;
857+with Dependency_Graphs;
858 with Package_Trees;
859
860 package Node_Processing is
861@@ -67,5 +67,4 @@
862 -- * If a package depends both from a package and an ancestor of
863 -- it, remove the dependence from the ancestor.
864
865-
866 end Node_Processing;
867
868=== modified file 'output.adb'
869--- output.adb 2012-06-28 18:24:52 +0000
870+++ output.adb 2012-07-05 20:01:18 +0000
871@@ -25,8 +25,6 @@
872 with Ada.Strings.Fixed;
873 with Indented_IO;
874 with Ada.Strings.Equal_Case_Insensitive;
875-with Style_Table;
876-
877
878 package body Output is
879
880@@ -38,7 +36,6 @@
881 & "dot.collapsed-shape = folder;"
882 & "dot.collapsed-color = blue";
883
884-
885 function To_S (Idx : Package_Trees.Package_Index) return String is
886 use Package_Trees;
887 use Ada.Strings.Fixed;
888@@ -77,7 +74,7 @@
889 end if;
890
891 declare
892- Item : String := String (Name)
893+ Item : constant String := String (Name)
894 & "="
895 & '"' & String (Value) & '"'
896 & Terminator;
897@@ -96,18 +93,14 @@
898
899 end Print_Style;
900
901-
902-
903 procedure Print_Node_List (Indenter : in out Indented_IO.Indenter_Type;
904 DB : Package_Trees.Package_Tree) is
905 use Package_Trees;
906
907-
908 procedure Print_Tree (Pos : Cursor) is
909 use Ada.Strings.Fixed;
910
911 procedure Print_Node (Pos : Cursor) is
912-
913 begin
914 Indenter.Put (Node_Name (Pos));
915 Indenter.Put ("[label="
916@@ -151,7 +144,7 @@
917 Indenter.Close_Block ("}");
918 end Close_Subgraph;
919
920- Desc : Cursor_Array := Children (Pos);
921+ Desc : constant Cursor_Array := Children (Pos);
922 begin
923 if Desc'Length = 0 then
924 pragma Assert (Is_A_Leaf (Pos));
925@@ -168,7 +161,7 @@
926 end if;
927 end Print_Tree;
928
929- Roots : Cursor_Array := DB.Roots;
930+ Roots : constant Cursor_Array := DB.Roots;
931 begin
932 for I in Roots'Range loop
933 Print_Tree (Roots (I));
934@@ -200,7 +193,7 @@
935 return Root;
936 else
937 declare
938- Kids : Cursor_Array := Children (Root);
939+ Kids : constant Cursor_Array := Children (Root);
940 begin
941 -- First search among the direct descendants of Root
942 for I in Kids'Range loop
943@@ -236,7 +229,6 @@
944 pragma Assert (Is_A_Leaf (True_To));
945 pragma Assert (Is_A_Leaf (True_From));
946
947-
948 -- Make an edge between the two leaves
949 Indenter.Put (Node_Name (True_From)
950 & " -> "
951@@ -302,20 +294,17 @@
952 Indenter.Close_Block ("}");
953 end Print_Trailer;
954
955-
956-
957 -----------------
958 -- Print_Graph --
959 -----------------
960
961 procedure Print_Graph (Format : String;
962 Item : Package_DB.DB_Type)
963-
964 is
965 pragma Unreferenced (Format);
966 Indenter : Indented_IO.Indenter_Type := Indented_IO.Create;
967
968- Collapsed : Package_DB.DB_Type := Item;
969+ Collapsed : constant Package_DB.DB_Type := Item;
970 begin
971 Print_Header (Indenter);
972 Print_Node_List (Indenter, Collapsed.Tree);
973
974=== modified file 'output.ads'
975--- output.ads 2012-06-14 18:15:19 +0000
976+++ output.ads 2012-07-05 20:01:18 +0000
977@@ -20,7 +20,8 @@
978 ----------------------------------------------------------------------------
979 with Package_DB;
980 with Style_Table;
981-package output is
982+
983+package Output is
984 function Is_Known (Format : String) return Boolean;
985
986 function Style_Defaults (Format : String) return Style_Table.Style_Spec;
987@@ -28,4 +29,4 @@
988 procedure Print_Graph (Format : String;
989 Item : Package_DB.DB_Type);
990
991-end output;
992+end Output;
993
994=== modified file 'package_db.ads'
995--- package_db.ads 2012-06-09 10:32:54 +0000
996+++ package_db.ads 2012-07-05 20:01:18 +0000
997@@ -46,4 +46,3 @@
998 Graph : Graph_Access;
999 end record;
1000 end Package_DB;
1001-
1002
1003=== modified file 'package_names.adb'
1004--- package_names.adb 2012-06-09 10:32:54 +0000
1005+++ package_names.adb 2012-07-05 20:01:18 +0000
1006@@ -96,8 +96,6 @@
1007 Put_Line (Standard_Error, ")");
1008 end Print_Warning;
1009
1010-
1011-
1012 Result : Package_List;
1013 Removed : Package_List;
1014 begin
1015@@ -107,7 +105,7 @@
1016 -------------
1017
1018 procedure Process (Pos : Package_Lists.Cursor) is
1019- Name : Package_Name := Package_Lists.Element (Pos);
1020+ Name : constant Package_Name := Package_Lists.Element (Pos);
1021 begin
1022 if Package_Names.Find_Ancestor (Input, Name) /= "" then
1023 Removed.Append (Name);
1024@@ -141,17 +139,17 @@
1025 Input : Ada.Text_IO.File_Type;
1026 begin
1027 Ada.Text_IO.Open (File => Input,
1028- Mode => Ada.Text_Io.In_File,
1029+ Mode => Ada.Text_IO.In_File,
1030 Name => Filename);
1031
1032 while not Ada.Text_IO.End_Of_File (Input) loop
1033 declare
1034- Line : String := Fixed.Trim (Source => Get_Line (Input),
1035- Left => Spaces,
1036- Right => Spaces);
1037+ Line : constant String := Fixed.Trim (Source => Get_Line (Input),
1038+ Left => Spaces,
1039+ Right => Spaces);
1040 begin
1041 if Line'Length >= 1 and then Line (Line'First) /= '#' then
1042- if Is_Valid_Package_Name(Line) then
1043+ if Is_Valid_Package_Name (Line) then
1044 List.Append (Package_Name (Line));
1045 else
1046 raise Program_Error
1047@@ -178,11 +176,10 @@
1048
1049 function To_Package_List (Input : Token_List) return Package_List is
1050 Result : Package_List;
1051-
1052 begin
1053 declare
1054 procedure Append (Pos : String_Vectors.Cursor) is
1055- V : String := Fixed.Trim (+String_Vectors.Element (Pos), Both);
1056+ V : constant String := Fixed.Trim (+String_Vectors.Element (Pos), Both);
1057 begin
1058 if Is_Valid_Package_Name (V) then
1059 Result.Append (Package_Name (V));
1060@@ -200,7 +197,7 @@
1061
1062 begin
1063 if Param (Param'First) = '@' then
1064- return Read_Package_List (Param (Param'First + 1 .. Param'Last));
1065+ return Read_Package_List (Param (Param'First + 1 .. Param'Last));
1066 else
1067 return To_Package_List (Split (Param, ','));
1068 end if;
1069
1070=== modified file 'package_names.ads'
1071--- package_names.ads 2012-06-09 10:32:54 +0000
1072+++ package_names.ads 2012-07-05 20:01:18 +0000
1073@@ -52,7 +52,7 @@
1074 -- found. If no ancestor is found, return the empty string.
1075 -- If more than ancestor is present, return the first found.
1076
1077- function Parse_Package_List (Param : String)return Package_List;
1078+ function Parse_Package_List (Param : String) return Package_List;
1079 -- If Param begins with '@', the rest of the string is interpreted
1080 -- as the name of a file to be read via Read_Package_List; if Param
1081 -- does not begin with '@', it is expected to be a list of package
1082@@ -70,9 +70,6 @@
1083 -- package). If a package is the ancestor of another, the ancestor
1084 -- is kept and the descendant is removed.
1085
1086-
1087-
1088-
1089 -- ================== --
1090 -- PACKAGE COMPONENTS --
1091 -- ================== --
1092
1093=== modified file 'package_trees.adb'
1094--- package_trees.adb 2012-06-09 10:32:54 +0000
1095+++ package_trees.adb 2012-07-05 20:01:18 +0000
1096@@ -19,10 +19,8 @@
1097 -- along with DePlo. If not, see <http://www.gnu.org/licenses/>.
1098 ----------------------------------------------------------------------------
1099 with Ada.Strings.Hash;
1100-with Ada.Containers.Hashed_Maps;
1101
1102 package body Package_Trees is
1103- use Ada.Strings.Unbounded;
1104
1105 ---------
1106 -- Add --
1107@@ -61,7 +59,7 @@
1108 end if;
1109
1110 declare
1111- Idx : Package_Index := DB.DB.Package_Data.Last_Index + 1;
1112+ Idx : constant Package_Index := DB.DB.Package_Data.Last_Index + 1;
1113
1114 procedure Add_Child (Item : in out Package_Descriptor) is
1115 begin
1116@@ -72,7 +70,7 @@
1117
1118 DB.DB.Package_Data.Append ((Index => Idx,
1119 Parent => Parent,
1120- Name => To_Unbounded_String (String(To_Name (Key))),
1121+ Name => To_Unbounded_String (String (To_Name (Key))),
1122 Name_Components => Key,
1123 Children => Index_Lists.Empty_List,
1124 Attributes => Attribute_Lists.Empty_Map));
1125@@ -103,7 +101,7 @@
1126 Name : Package_Name)
1127 return Cursor
1128 is
1129- Key : Component_List := To_Component_List (Name);
1130+ Key : constant Component_List := To_Component_List (Name);
1131 begin
1132 if not DB.DB.Name_To_Index.Contains (Key) then
1133 return No_Element;
1134@@ -121,7 +119,7 @@
1135 (Position : Cursor)
1136 return Cursor
1137 is
1138- Parent_Idx : Package_Index := Position.DB.Package_Data.Element (Position.Index).Parent;
1139+ Parent_Idx : constant Package_Index := Position.DB.Package_Data.Element (Position.Index).Parent;
1140 begin
1141 if Parent_Idx = No_Index then
1142 return No_Element;
1143@@ -181,7 +179,6 @@
1144 Index => Index);
1145 end Position;
1146
1147-
1148 --------------
1149 -- Contains --
1150 --------------
1151@@ -306,7 +303,6 @@
1152 use type Package_Lists.Cursor;
1153 use type Ada.Containers.Count_Type;
1154
1155-
1156 Pos_L : Package_Lists.Cursor := Left.First;
1157 Pos_R : Package_Lists.Cursor := Right.First;
1158 begin
1159
1160=== modified file 'package_trees.ads'
1161--- package_trees.ads 2012-06-09 10:32:54 +0000
1162+++ package_trees.ads 2012-07-05 20:01:18 +0000
1163@@ -60,7 +60,6 @@
1164 private;
1165 -- The type representing the package tree
1166
1167-
1168 type Cursor is private;
1169
1170 No_Element : constant Cursor;
1171@@ -98,7 +97,6 @@
1172 Process : access procedure (Name, Value : String));
1173 -- Call Process for every attribute of the node
1174
1175-
1176 function Find (DB : Package_Tree;
1177 Name : Package_Name)
1178 return Cursor;
1179@@ -114,7 +112,6 @@
1180 return Cursor;
1181 -- Return the parent of the node identified by the cursor
1182
1183-
1184 function Children (Pos : Cursor)
1185 return Cursor_Array;
1186 -- Return the cursors associated with the children of the specified node
1187@@ -124,13 +121,11 @@
1188 -- Return true if the node has no children. Equivalent to
1189 -- Children(pos)'length = 0
1190
1191-
1192 function Roots (DB : Package_Tree)
1193 return Cursor_Array;
1194 -- Return the cursors of the nodes that have no ancestor. (Yes, the
1195 -- "package tree" is actually a forest)
1196
1197-
1198 function Index (Position : Cursor)
1199 return Package_Index;
1200 -- Return the unique index assigned to the package identified by the cursor
1201@@ -147,7 +142,6 @@
1202 -- Return the cursor associated with the specified package index in
1203 -- the specified tree
1204
1205-
1206 function Position (Pos : Cursor;
1207 Index : Package_Index)
1208 return Cursor;
1209@@ -155,7 +149,6 @@
1210 -- the same tree of the specified cursor. (Funny as it may seem, it is
1211 -- useful)
1212
1213-
1214 function Size (DB : Package_Tree) return Natural;
1215 -- Return the number of nodes in the tree
1216
1217@@ -176,14 +169,12 @@
1218
1219 No_Index : constant Package_Index := Package_Index'Last;
1220
1221-
1222 function Name_List_Hash (Item : Component_List)
1223 return Ada.Containers.Hash_Type;
1224
1225 function "=" (Left, Right : Component_List)
1226 return Boolean;
1227
1228-
1229 package Name_To_Index_Maps is
1230 new Ada.Containers.Hashed_Maps (Key_Type => Component_List,
1231 Element_Type => Package_Index,
1232@@ -224,7 +215,7 @@
1233
1234 type DB_Access is access Basic_DB_Type;
1235
1236- type Package_Tree Is new
1237+ type Package_Tree is new
1238 Ada.Finalization.Controlled
1239 with
1240 record
1241
1242=== modified file 'sectioned_text.adb'
1243--- sectioned_text.adb 2012-06-28 18:24:52 +0000
1244+++ sectioned_text.adb 2012-07-05 20:01:18 +0000
1245@@ -18,11 +18,9 @@
1246 -- You should have received a copy of the GNU General Public License --
1247 -- along with DePlo. If not, see <http://www.gnu.org/licenses/>. --
1248 -------------------------------------------------------------------------------
1249-with Ada.Strings.Unbounded;
1250 with Ada.Strings.Fixed;
1251
1252 package body Sectioned_Text is
1253- use Ada.Strings.Unbounded;
1254
1255 function To_S (X : Unbounded_String) return String
1256 renames To_String;
1257@@ -56,7 +54,7 @@
1258 begin
1259 for I in Skip + Lines.First_Index .. Lines.Last_Index loop
1260 declare
1261- Classified : Classified_Line := Classifier.Classify (Lines.Element (I));
1262+ Classified : constant Classified_Line := Classifier.Classify (Lines.Element (I));
1263 begin
1264 case Classified.Class is
1265 when Section =>
1266@@ -64,7 +62,7 @@
1267 Current_Sect.Clear;
1268 Section_Name := Classified.Name;
1269 when Normal =>
1270- Current_Sect.Append (To_S(Classified.Content));
1271+ Current_Sect.Append (To_S (Classified.Content));
1272 when Comment =>
1273 null;
1274 end case;
1275@@ -94,7 +92,7 @@
1276 is
1277 Separator : constant String := Lines.First_Element;
1278
1279- Classifier : Basic_Line_Classifier := New_Classifier (Head => Separator);
1280+ Classifier : constant Basic_Line_Classifier := New_Classifier (Head => Separator);
1281 begin
1282 return Parse (Lines => Lines,
1283 Classifier => Classifier,
1284@@ -111,8 +109,6 @@
1285 return Parse (Line_Arrays.Read (Filename));
1286 end Parse;
1287
1288-
1289-
1290 ----------------
1291 -- New_Parser --
1292 ----------------
1293@@ -145,14 +141,13 @@
1294 Input : String)
1295 return Classified_Line
1296 is
1297- use Ada.Strings.Unbounded;
1298 use Ada.Strings;
1299
1300 function Begin_With (Input : String;
1301 Head : Unbounded_String)
1302 return Boolean
1303 is
1304- H : String := To_S (Head);
1305+ H : constant String := To_S (Head);
1306 begin
1307 return
1308 H = "" or else
1309@@ -165,7 +160,7 @@
1310 Skip : Natural)
1311 return Boolean
1312 is
1313- T : String := To_S (Tail);
1314+ T : constant String := To_S (Tail);
1315 begin
1316 return T = ""
1317 or else
1318@@ -179,7 +174,7 @@
1319 Trim : Boolean)
1320 return Unbounded_String
1321 is
1322- Section : String :=
1323+ Section : constant String :=
1324 Input (Input'First + Length (Head) .. Input'Last - Length (Tail));
1325 begin
1326 if Trim then
1327@@ -189,17 +184,16 @@
1328 end if;
1329 end Strip;
1330
1331-
1332 function Is_To_Be_Ignored (Input : String) return Boolean is
1333- Trimmed : String := Fixed.Trim (Input, Both);
1334+ Trimmed : constant String := Fixed.Trim (Input, Both);
1335 begin
1336 if Length (Parser.Comments) > 0 then
1337 if Begin_With (Input, Parser.Comments) then
1338 return True;
1339 end if;
1340
1341- if (Parser.Trim_Comments
1342- and then Begin_With (Trimmed, Parser.Comments)) then
1343+ if Parser.Trim_Comments
1344+ and then Begin_With (Trimmed, Parser.Comments) then
1345 return True;
1346 end if;
1347 end if;
1348@@ -233,9 +227,6 @@
1349
1350 end Sectioned_Text;
1351
1352-
1353-
1354-
1355 -- function Check (X : String) return String is
1356 -- use Ada.Strings.Fixed;
1357 --
1358
1359=== modified file 'sectioned_text.ads'
1360--- sectioned_text.ads 2012-06-28 17:58:41 +0000
1361+++ sectioned_text.ads 2012-07-05 20:01:18 +0000
1362@@ -57,7 +57,6 @@
1363
1364 subtype Section_List is Line_Array_Maps.Map;
1365
1366-
1367 type Line_Class is (Normal, Section, Comment);
1368
1369 type Classified_Line (Class : Line_Class) is
1370@@ -93,7 +92,6 @@
1371 Skip : Integer := 0)
1372 return Section_List;
1373
1374-
1375 function Parse (Lines : Line_Array) return Section_List;
1376
1377 function Parse (Filename : String) return Section_List;
1378@@ -120,7 +118,6 @@
1379 -- the section name are stripped, so that "%foo" is equivalent to "% foo"
1380 -- "%foo ".
1381
1382-
1383 type Basic_Line_Classifier (<>) is new
1384 Abstract_Classifier
1385 with
1386@@ -139,10 +136,8 @@
1387 Input : String)
1388 return Classified_Line;
1389
1390-
1391 private
1392
1393-
1394 type Basic_Line_Classifier is new
1395 Abstract_Classifier
1396 with
1397@@ -156,5 +151,4 @@
1398 Ignore_Empty : Boolean;
1399 end record;
1400
1401-
1402 end Sectioned_Text;
1403
1404=== modified file 'style_table.adb'
1405--- style_table.adb 2012-06-29 11:46:21 +0000
1406+++ style_table.adb 2012-07-05 20:01:18 +0000
1407@@ -19,7 +19,6 @@
1408 -- along with DePlo. If not, see <http://www.gnu.org/licenses/>. --
1409 -------------------------------------------------------------------------------
1410
1411-with Ada.Strings.Unbounded;
1412 with Ada.Strings.Hash_Case_Insensitive;
1413 with Ada.Strings.Equal_Case_Insensitive;
1414 with Ada.Containers.Indefinite_Hashed_Maps;
1415@@ -27,14 +26,11 @@
1416 with Ada.Text_IO;
1417
1418 package body Style_Table is
1419- use Ada.Strings.Unbounded;
1420
1421 function To_U (X : String) return Unbounded_String
1422 renames To_Unbounded_String;
1423 pragma Unreferenced (To_U);
1424
1425-
1426-
1427 function To_S (X : Unbounded_String) return String
1428 renames To_String;
1429
1430@@ -54,10 +50,9 @@
1431
1432 function Attribute_Name_Hash (X : Attribute_Name) return Ada.Containers.Hash_Type is
1433 begin
1434- return Ada.Strings.Hash (String (X));
1435+ return Ada.Strings.Hash (String (X));
1436 end Attribute_Name_Hash;
1437
1438-
1439 package Attribute_Maps is
1440 new Ada.Containers.Indefinite_Hashed_Maps
1441 (Key_Type => Attribute_Name,
1442@@ -68,7 +63,7 @@
1443
1444 function Class_Hash (X : Node_Class) return Ada.Containers.Hash_Type is
1445 begin
1446- return Ada.Strings.Hash_Case_Insensitive (String (X));
1447+ return Ada.Strings.Hash_Case_Insensitive (String (X));
1448 end Class_Hash;
1449
1450 function Class_Equal (X, Y : Node_Class) return Boolean is
1451@@ -153,7 +148,7 @@
1452 end Next;
1453
1454 function Get_Char return Character is
1455- Result : Character := Peek;
1456+ Result : constant Character := Peek;
1457 begin
1458 Next;
1459 return Result;
1460@@ -256,7 +251,7 @@
1461
1462 Extract_String_Value;
1463
1464- -- Skip optional spaces after the last '"'
1465+ -- Skip optional spaces after the last '"'
1466 Skip_Spaces;
1467
1468 -- Now the next char, if it exists, can only be a ';'
1469@@ -332,8 +327,6 @@
1470 end loop;
1471 end Parse_And_Add;
1472
1473-
1474-
1475 -------------------
1476 -- Parse_And_Add --
1477 -------------------
1478@@ -352,14 +345,14 @@
1479 -------------
1480
1481 procedure Iterate
1482- (Class : Node_Class;
1483- Process : not null access procedure (Name : Attribute_Name;
1484- Value : Attribute_Value))
1485+ (Class : Node_Class;
1486+ Process : not null access procedure (Name : Attribute_Name;
1487+ Value : Attribute_Value))
1488 is
1489 procedure Dispatch (Pos : Attribute_Maps.Cursor) is
1490 begin
1491- Process (Name => Attribute_Maps.Key(Pos),
1492- Value => Attribute_Maps.Element(Pos));
1493+ Process (Name => Attribute_Maps.Key (Pos),
1494+ Value => Attribute_Maps.Element (Pos));
1495 end Dispatch;
1496 begin
1497 -- Ada.Text_IO.Put_Line ("Iterate : " & String (Class) & "->" & Boolean'Image (Table.Contains (Class)));
1498@@ -368,14 +361,14 @@
1499 end if;
1500 end Iterate;
1501
1502- procedure Dump(List : Style_Spec_Lists.List)
1503+ procedure Dump (List : Style_Spec_Lists.List)
1504 is
1505- procedure Print(Pos : Style_Spec_Lists.Cursor) is
1506+ procedure Print (Pos : Style_Spec_Lists.Cursor) is
1507 begin
1508- Ada.Text_Io.Put_Line(String(Style_Spec_Lists.Element(Pos)));
1509+ Ada.Text_IO.Put_Line (String (Style_Spec_Lists.Element (Pos)));
1510 end Print;
1511 begin
1512- List.Iterate(Print'Access);
1513+ List.Iterate (Print'Access);
1514 end Dump;
1515
1516 end Style_Table;
1517
1518=== modified file 'style_table.ads'
1519--- style_table.ads 2012-06-29 11:46:21 +0000
1520+++ style_table.ads 2012-07-05 20:01:18 +0000
1521@@ -75,7 +75,7 @@
1522 package Style_Spec_Lists is
1523 new Ada.Containers.Indefinite_Doubly_Linked_Lists (Style_Spec);
1524
1525- procedure Dump(List : Style_Spec_Lists.List);
1526+ procedure Dump (List : Style_Spec_Lists.List);
1527
1528 procedure Add (Class : Node_Class;
1529 Name : Attribute_Name;
1530@@ -127,8 +127,6 @@
1531 -- Call Extract_Spec_Data for every entry in the list of
1532 -- style specs and add the result to the style table
1533
1534-
1535-
1536 procedure Iterate
1537 (Class : Node_Class;
1538 Process : not null access procedure (Name : Attribute_Name;
1539
1540=== modified file 'test/test_sectioned_text.adb'
1541--- test/test_sectioned_text.adb 2012-06-28 17:58:41 +0000
1542+++ test/test_sectioned_text.adb 2012-07-05 20:01:18 +0000
1543@@ -30,7 +30,7 @@
1544 use Sectioned_Text.Line_Array_Maps;
1545
1546 procedure Print_Section (Pos : Cursor) is
1547- Lines : Line_Array := Element (Pos);
1548+ Lines : constant Line_Array := Element (Pos);
1549 begin
1550 Put_Line ("[" & Key (Pos) & "]");
1551
1552@@ -42,9 +42,9 @@
1553 X.Iterate (Print_Section'Access);
1554 end Print;
1555
1556- Sectioned : Section_List := Parse ("test_sectioned_text.txt");
1557+ Sectioned : constant Section_List := Parse ("test_sectioned_text.txt");
1558
1559- Classifier : Basic_Line_Classifier :=
1560+ Classifier : constant Basic_Line_Classifier :=
1561 New_Classifier (Head => "[",
1562 Tail => "]",
1563 Comments => "%",
1564@@ -53,7 +53,7 @@
1565 Trim_Comments => True,
1566 Ignore_Empty => True);
1567
1568- Classifier_2 : Basic_Line_Classifier :=
1569+ Classifier_2 : constant Basic_Line_Classifier :=
1570 New_Classifier (Head => "[",
1571 Tail => "]",
1572 Comments => "%",
1573@@ -62,16 +62,15 @@
1574 Trim_Comments => False,
1575 Ignore_Empty => False);
1576
1577-
1578- Sectioned_2 : Section_List := Parse (Filename => "test_sectioned_text2.txt",
1579+ Sectioned_2 : constant Section_List := Parse (Filename => "test_sectioned_text2.txt",
1580 Classifier => Classifier);
1581
1582- Sectioned_3 : Section_List := Parse (Filename => "test_sectioned_text2.txt",
1583+ Sectioned_3 : constant Section_List := Parse (Filename => "test_sectioned_text2.txt",
1584 Classifier => Classifier_2);
1585 begin
1586 Print (Sectioned);
1587 Put_Line ("-------------------------");
1588 Print (Sectioned_2);
1589- Put_Line("-------------------------");
1590+ Put_Line ("-------------------------");
1591 Print (Sectioned_3);
1592 end Test_Sectioned_Text;
1593
1594=== modified file 'tokenize.adb'
1595--- tokenize.adb 2012-06-09 10:32:54 +0000
1596+++ tokenize.adb 2012-07-05 20:01:18 +0000
1597@@ -20,9 +20,9 @@
1598 ----------------------------------------------------------------------------
1599 package body Tokenize is
1600
1601- -- Called by Split when the separator is a space. According to
1602- -- Ruby convention, space is a special separator in the sense
1603- -- that consecutive spaces do not give rise to empty tokens.
1604+ -- Called by Split when the separator is a space. According to
1605+ -- Ruby convention, space is a special separator in the sense
1606+ -- that consecutive spaces do not give rise to empty tokens.
1607 function Collated_Split (To_Be_Splitted : String;
1608 Separator : Character)
1609 return Token_List is
1610@@ -32,38 +32,38 @@
1611
1612 Current := To_Be_Splitted'First;
1613
1614- Main_Loop:
1615+ Main_Loop:
1616 while Current <= To_Be_Splitted'Last loop
1617
1618 Search_For_Begin:
1619- -- Since we are doing a Collated split, we need to skip
1620- -- all the separators
1621+ -- Since we are doing a Collated split, we need to skip
1622+ -- all the separators
1623 while Current <= To_Be_Splitted'Last and then
1624- To_Be_Splitted(Current) = Separator loop
1625- Current := Current+1;
1626+ To_Be_Splitted (Current) = Separator loop
1627+ Current := Current + 1;
1628 end loop Search_For_Begin;
1629
1630- -- If I am here or Current points after the end of
1631- -- the string of To_Be_Splitted(Current) is a non-sep
1632- -- character
1633-
1634- exit when (Current > To_Be_Splitted'Last);
1635-
1636- -- If I am here, To_Be_Splitted(Current) is a
1637- -- non-separator character
1638+ -- If I am here or Current points after the end of
1639+ -- the string of To_Be_Splitted(Current) is a non-sep
1640+ -- character
1641+
1642+ exit when Current > To_Be_Splitted'Last;
1643+
1644+ -- If I am here, To_Be_Splitted(Current) is a
1645+ -- non-separator character
1646
1647 First := Current;
1648
1649 Search_For_End:
1650 while Current <= To_Be_Splitted'Last and then
1651- To_Be_Splitted(Current) /= Separator loop
1652- Current := Current+1;
1653+ To_Be_Splitted (Current) /= Separator loop
1654+ Current := Current + 1;
1655 end loop Search_For_End;
1656
1657 String_Vectors.Append (Result,
1658- To_Unbounded_String(To_Be_Splitted(First..Current-1)));
1659+ To_Unbounded_String (To_Be_Splitted (First .. Current - 1)));
1660
1661- Current := Current+1;
1662+ Current := Current + 1;
1663 end loop Main_Loop;
1664
1665 return Result;
1666@@ -88,49 +88,46 @@
1667
1668 Search_For_End:
1669 while Current <= To_Be_Splitted'Last and then
1670- To_Be_Splitted(Current) /= Separator loop
1671- Current := Current+1;
1672+ To_Be_Splitted (Current) /= Separator loop
1673+ Current := Current + 1;
1674 end loop Search_For_End;
1675
1676- String_Vectors.Append(Result,
1677- To_Unbounded_String(To_Be_Splitted(First..Current-1)));
1678+ String_Vectors.Append (Result,
1679+ To_Unbounded_String (To_Be_Splitted (First .. Current - 1)));
1680
1681- if (Current = To_Be_Splitted'Last) then
1682- String_Vectors.Append(Result, Null_Unbounded_String);
1683+ if Current = To_Be_Splitted'Last then
1684+ String_Vectors.Append (Result, Null_Unbounded_String);
1685 end if;
1686
1687- Current := Current+1;
1688+ Current := Current + 1;
1689 end loop Main_Loop;
1690
1691 return Result;
1692 end Uncollated_Split;
1693
1694- function Split(To_Be_Splitted : String;
1695- Separator : Character;
1696- Collate_Separator : Boolean)
1697- return Token_List is
1698+ function Split (To_Be_Splitted : String;
1699+ Separator : Character;
1700+ Collate_Separator : Boolean)
1701+ return Token_List is
1702 begin
1703- if (Collate_Separator) then
1704- return Collated_Split(To_Be_Splitted, Separator);
1705+ if Collate_Separator then
1706+ return Collated_Split (To_Be_Splitted, Separator);
1707 else
1708- return Uncollated_Split(To_Be_Splitted, Separator);
1709+ return Uncollated_Split (To_Be_Splitted, Separator);
1710 end if;
1711 end Split;
1712
1713-
1714- --
1715- -- Similar to the three-parameter version, but the Separator
1716- -- char defaults to the space and Collate_Separator is True
1717- -- if Separator is the space, false otherwise
1718- --
1719- function Split(To_Be_Splitted : String;
1720- Separator : Character := ' ')
1721- return Token_List is
1722+ -- Similar to the three-parameter version, but the Separator
1723+ -- char defaults to the space and Collate_Separator is True
1724+ -- if Separator is the space, false otherwise
1725+ function Split (To_Be_Splitted : String;
1726+ Separator : Character := ' ')
1727+ return Token_List is
1728 begin
1729- if (Separator=' ') then
1730- return Collated_Split(To_Be_Splitted, Separator);
1731+ if Separator = ' ' then
1732+ return Collated_Split (To_Be_Splitted, Separator);
1733 else
1734- return Uncollated_Split(To_Be_Splitted, Separator);
1735+ return Uncollated_Split (To_Be_Splitted, Separator);
1736 end if;
1737 end Split;
1738
1739@@ -141,18 +138,17 @@
1740 return To_Array (Split (To_Be_Splitted, Separator));
1741 end Split;
1742
1743-
1744- function Length(Container : Token_List) return Natural is
1745+ function Length (Container : Token_List) return Natural is
1746 begin
1747- return Natural(String_Vectors.Length(Container));
1748+ return Natural (String_Vectors.Length (Container));
1749 end Length;
1750
1751 function To_Array (List : Token_List)
1752 return Token_Array is
1753- Result : Token_Array(1..Length(List));
1754+ Result : Token_Array (1 .. Length (List));
1755 begin
1756 for I in Result'Range loop
1757- Result(I) := Element(List, I);
1758+ Result (I) := Element (List, I);
1759 end loop;
1760
1761 return Result;
1762
1763=== modified file 'tokenize.ads'
1764--- tokenize.ads 2012-06-09 10:32:54 +0000
1765+++ tokenize.ads 2012-07-05 20:01:18 +0000
1766@@ -29,60 +29,53 @@
1767 -- Update Count : 1
1768 -- Status : <TESTED>
1769
1770---
1771--- This package provides a function Split which divides its input
1772--- string in smaller strings, separated by a "separator" (much as the
1773--- split function in Perl, Ruby, and so on...). Function Split returns
1774--- a Token_List (defined by this package) whose elements can be accessed
1775--- by the function Element.
1776---
1777--- Function Split can accept a third Boolean value Collate_Separator.
1778--- If Collate_Separator is true, consecutive istances of the separator are
1779--- considered as a single one. If Collate_Separator is False, for every
1780--- pair of consecutive separator characters an empty string will be returned.
1781--- Moreover, if Collate_Separator is True, any separator at the beginning of
1782--- the string is ignored. Separators at the end are always ignored.
1783---
1784--- The default value of Collate_Separator is true if the separator
1785--- is the space, false otherwise.
1786---
1787--- Examples:
1788---
1789--- Split("Hello there") returns "Hello" and "there"
1790--- Split("Hello there", ' ', False) returns "Hello", "" and "there"
1791--- Split("Hello::there", ':') returns "Hello", "" and "there"
1792--- Split("Hello::there", ':', True) returns "Hello" and "there"
1793---
1794+-- This package provides a function Split which divides its input
1795+-- string in smaller strings, separated by a "separator" (much as the
1796+-- split function in Perl, Ruby, and so on...). Function Split returns
1797+-- a Token_List (defined by this package) whose elements can be accessed
1798+-- by the function Element.
1799+--
1800+-- Function Split can accept a third Boolean value Collate_Separator.
1801+-- If Collate_Separator is true, consecutive istances of the separator are
1802+-- considered as a single one. If Collate_Separator is False, for every
1803+-- pair of consecutive separator characters an empty string will be returned.
1804+-- Moreover, if Collate_Separator is True, any separator at the beginning of
1805+-- the string is ignored. Separators at the end are always ignored.
1806+--
1807+-- The default value of Collate_Separator is true if the separator
1808+-- is the space, false otherwise.
1809+--
1810+-- Examples:
1811+--
1812+-- Split("Hello there") returns "Hello" and "there"
1813+-- Split("Hello there", ' ', False) returns "Hello", "" and "there"
1814+-- Split("Hello::there", ':') returns "Hello", "" and "there"
1815+-- Split("Hello::there", ':', True) returns "Hello" and "there"
1816 with Ada.Containers.Vectors;
1817 with Ada.Strings.Unbounded;
1818 use Ada.Strings.Unbounded;
1819
1820 package Tokenize is
1821 package String_Vectors is
1822- new Ada.Containers.Vectors(Index_Type => Positive,
1823- Element_Type => Unbounded_String);
1824+ new Ada.Containers.Vectors (Index_Type => Positive,
1825+ Element_Type => Unbounded_String);
1826
1827 subtype Token_List is String_Vectors.Vector;
1828 type Token_Array is array (Positive range <>) of Unbounded_String;
1829 use type Token_List;
1830
1831-
1832- function Split(To_Be_Splitted : String;
1833- Separator : Character;
1834- Collate_Separator : Boolean) return Token_List;
1835- --
1836- -- Split string To_Be_Splitted in substring separated by
1837- -- Separator. If Collate_Separator is true consider consecutive
1838- -- istances of Separator as a single one
1839- --
1840-
1841- function Split(To_Be_Splitted : String;
1842- Separator : Character := ' ') return Token_List;
1843- --
1844- -- Similar to the three-parameter version, but the Separator
1845- -- char defaults to the space and Collate_Separator is True
1846- -- if Separator is the space, false otherwise
1847- --
1848+ function Split (To_Be_Splitted : String;
1849+ Separator : Character;
1850+ Collate_Separator : Boolean) return Token_List;
1851+ -- Split string To_Be_Splitted in substring separated by
1852+ -- Separator. If Collate_Separator is true consider consecutive
1853+ -- istances of Separator as a single one
1854+
1855+ function Split (To_Be_Splitted : String;
1856+ Separator : Character := ' ') return Token_List;
1857+ -- Similar to the three-parameter version, but the Separator
1858+ -- char defaults to the space and Collate_Separator is True
1859+ -- if Separator is the space, false otherwise
1860
1861 function Split (To_Be_Splitted : String;
1862 Separator : Character := ' ') return Token_Array;
1863@@ -90,18 +83,13 @@
1864 -- instead of a vector. The reason for the presence of this procedure
1865 -- is mainly historical.
1866
1867- function Element(Container : Token_List;
1868- Index : Positive) return Unbounded_String
1869+ function Element (Container : Token_List;
1870+ Index : Positive) return Unbounded_String
1871 renames String_Vectors.Element;
1872- --
1873- -- Return the Index-th token
1874- --
1875-
1876+ -- Return the Index-th token
1877
1878 function Length (Container : Token_List) return Natural;
1879- --
1880- -- Return the number of tokens
1881- --
1882+ -- Return the number of tokens
1883
1884 function To_Array (List : Token_List) return Token_Array;
1885 end Tokenize;

Subscribers

People subscribed via source and target branches

to all changes: