Commit 23b6deca by Arnaud Charlet

[multiple changes]

2011-08-05  Matthew Heaney  <heaney@adacore.com>

	* a-comutr.adb, a-cimutr.adb, a-cbmutr.adb (Read): do not use T'Valid
	to check count, check sign of value instead.
	* a-comutr.adb, a-cimutr.adb (Write): return immediately if tree empty
	(Copy_Subtree): allocate copy of source element
	(Equal_Subtree): compare elements, not access objects

2011-08-05  Vincent Celier  <celier@adacore.com>

	* gnat_ugn.texi: Fix VMS alternative.

From-SVN: r177457
parent 24911a50
2011-08-05 Matthew Heaney <heaney@adacore.com>
* a-comutr.adb, a-cimutr.adb, a-cbmutr.adb (Read): do not use T'Valid
to check count, check sign of value instead.
* a-comutr.adb, a-cimutr.adb (Write): return immediately if tree empty
(Copy_Subtree): allocate copy of source element
(Equal_Subtree): compare elements, not access objects
2011-08-05 Vincent Celier <celier@adacore.com>
* gnat_ugn.texi: Fix VMS alternative.
2011-08-05 Thomas Quinot <quinot@adacore.com>
* sem_ch11.adb: Add comment.
......
......@@ -2117,20 +2117,26 @@ package body Ada.Containers.Bounded_Multiway_Trees is
NN : Tree_Node_Array renames Container.Nodes;
Total_Count, Read_Count : Count_Type;
Total_Count : Count_Type'Base;
-- Value read from the stream that says how many elements follow
Read_Count : Count_Type'Base;
-- Actual number of elements read from the stream
-------------------
-- Read_Children --
-------------------
procedure Read_Children (Subtree : Count_Type) is
Count : Count_Type; -- number of child subtrees
CC : Children_Type;
Count : Count_Type'Base;
-- number of child subtrees
CC : Children_Type;
begin
Count_Type'Read (Stream, Count);
if not Count'Valid then -- Is this check necessary???
if Count < 0 then
raise Program_Error with "attempt to read from corrupt stream";
end if;
......@@ -2180,7 +2186,7 @@ package body Ada.Containers.Bounded_Multiway_Trees is
Count_Type'Read (Stream, Total_Count);
if not Total_Count'Valid then -- Is this check necessary???
if Total_Count < 0 then
raise Program_Error with "attempt to read from corrupt stream";
end if;
......
......@@ -556,8 +556,10 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
Target : out Tree_Node_Access;
Count : in out Count_Type)
is
E : constant Element_Access := new Element_Type'(Source.Element.all);
begin
Target := new Tree_Node_Type'(Element => Source.Element,
Target := new Tree_Node_Type'(Element => E,
Parent => Parent,
others => <>);
......@@ -886,7 +888,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
Right_Subtree : Tree_Node_Access) return Boolean
is
begin
if Left_Subtree.Element /= Right_Subtree.Element then
if Left_Subtree.Element.all /= Right_Subtree.Element.all then
return False;
end if;
......@@ -1638,8 +1640,11 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
function Read_Subtree
(Parent : Tree_Node_Access) return Tree_Node_Access;
Total_Count : Count_Type;
Read_Count : Count_Type;
Total_Count : Count_Type'Base;
-- Value read from the stream that says how many elements follow
Read_Count : Count_Type'Base;
-- Actual number of elements read from the stream
-------------------
-- Read_Children --
......@@ -1650,7 +1655,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
pragma Assert (Subtree.Children.First = null);
pragma Assert (Subtree.Children.Last = null);
Count : Count_Type;
Count : Count_Type'Base;
-- Number of child subtrees
C : Children_Type;
......@@ -1658,7 +1663,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
begin
Count_Type'Read (Stream, Count);
if not Count'Valid then -- Is this check necessary???
if Count < 0 then
raise Program_Error with "attempt to read from corrupt stream";
end if;
......@@ -1712,7 +1717,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
Count_Type'Read (Stream, Total_Count);
if not Total_Count'Valid then -- Is this check necessary???
if Total_Count < 0 then
raise Program_Error with "attempt to read from corrupt stream";
end if;
......@@ -2383,6 +2388,11 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
begin
Count_Type'Write (Stream, Container.Count);
if Container.Count = 0 then
return;
end if;
Write_Children (Root_Node (Container));
end Write;
......
......@@ -1681,7 +1681,11 @@ package body Ada.Containers.Multiway_Trees is
function Read_Subtree
(Parent : Tree_Node_Access) return Tree_Node_Access;
Total_Count, Read_Count : Count_Type;
Total_Count : Count_Type'Base;
-- Value read from the stream that says how many elements follow
Read_Count : Count_Type'Base;
-- Actual number of elements read from the stream
-------------------
-- Read_Children --
......@@ -1692,13 +1696,15 @@ package body Ada.Containers.Multiway_Trees is
pragma Assert (Subtree.Children.First = null);
pragma Assert (Subtree.Children.Last = null);
Count : Count_Type; -- number of child subtrees
C : Children_Type;
Count : Count_Type'Base;
-- Number of child subtrees
C : Children_Type;
begin
Count_Type'Read (Stream, Count);
if not Count'Valid then -- Is this check necessary???
if Count < 0 then
raise Program_Error with "attempt to read from corrupt stream";
end if;
......@@ -1749,7 +1755,7 @@ package body Ada.Containers.Multiway_Trees is
Count_Type'Read (Stream, Total_Count);
if not Total_Count'Valid then -- Is this check necessary???
if Total_Count < 0 then
raise Program_Error with "attempt to read from corrupt stream";
end if;
......@@ -2428,6 +2434,11 @@ package body Ada.Containers.Multiway_Trees is
begin
Count_Type'Write (Stream, Container.Count);
if Container.Count = 0 then
return;
end if;
Write_Children (Root_Node (Container));
end Write;
......
......@@ -6312,7 +6312,7 @@ example:
@item ^C^COMMENTS1^ (single space)
@emph{Check comments, single space.}
This is identical to @code{^c^COMMENTS} except that only one space
This is identical to @code{^c^COMMENTS^} except that only one space
is required following the @code{--} of a comment instead of two.
@item ^d^DOS_LINE_ENDINGS^
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment