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> 2011-08-05 Thomas Quinot <quinot@adacore.com>
* sem_ch11.adb: Add comment. * sem_ch11.adb: Add comment.
......
...@@ -2117,20 +2117,26 @@ package body Ada.Containers.Bounded_Multiway_Trees is ...@@ -2117,20 +2117,26 @@ package body Ada.Containers.Bounded_Multiway_Trees is
NN : Tree_Node_Array renames Container.Nodes; 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 -- -- Read_Children --
------------------- -------------------
procedure Read_Children (Subtree : Count_Type) is procedure Read_Children (Subtree : Count_Type) is
Count : Count_Type; -- number of child subtrees Count : Count_Type'Base;
CC : Children_Type; -- number of child subtrees
CC : Children_Type;
begin begin
Count_Type'Read (Stream, Count); 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"; raise Program_Error with "attempt to read from corrupt stream";
end if; end if;
...@@ -2180,7 +2186,7 @@ package body Ada.Containers.Bounded_Multiway_Trees is ...@@ -2180,7 +2186,7 @@ package body Ada.Containers.Bounded_Multiway_Trees is
Count_Type'Read (Stream, Total_Count); 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"; raise Program_Error with "attempt to read from corrupt stream";
end if; end if;
......
...@@ -556,8 +556,10 @@ package body Ada.Containers.Indefinite_Multiway_Trees is ...@@ -556,8 +556,10 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
Target : out Tree_Node_Access; Target : out Tree_Node_Access;
Count : in out Count_Type) Count : in out Count_Type)
is is
E : constant Element_Access := new Element_Type'(Source.Element.all);
begin begin
Target := new Tree_Node_Type'(Element => Source.Element, Target := new Tree_Node_Type'(Element => E,
Parent => Parent, Parent => Parent,
others => <>); others => <>);
...@@ -886,7 +888,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is ...@@ -886,7 +888,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
Right_Subtree : Tree_Node_Access) return Boolean Right_Subtree : Tree_Node_Access) return Boolean
is is
begin begin
if Left_Subtree.Element /= Right_Subtree.Element then if Left_Subtree.Element.all /= Right_Subtree.Element.all then
return False; return False;
end if; end if;
...@@ -1638,8 +1640,11 @@ package body Ada.Containers.Indefinite_Multiway_Trees is ...@@ -1638,8 +1640,11 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
function Read_Subtree function Read_Subtree
(Parent : Tree_Node_Access) return Tree_Node_Access; (Parent : Tree_Node_Access) return Tree_Node_Access;
Total_Count : Count_Type; Total_Count : Count_Type'Base;
Read_Count : Count_Type; -- 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 -- -- Read_Children --
...@@ -1650,7 +1655,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is ...@@ -1650,7 +1655,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
pragma Assert (Subtree.Children.First = null); pragma Assert (Subtree.Children.First = null);
pragma Assert (Subtree.Children.Last = null); pragma Assert (Subtree.Children.Last = null);
Count : Count_Type; Count : Count_Type'Base;
-- Number of child subtrees -- Number of child subtrees
C : Children_Type; C : Children_Type;
...@@ -1658,7 +1663,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is ...@@ -1658,7 +1663,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
begin begin
Count_Type'Read (Stream, Count); 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"; raise Program_Error with "attempt to read from corrupt stream";
end if; end if;
...@@ -1712,7 +1717,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is ...@@ -1712,7 +1717,7 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
Count_Type'Read (Stream, Total_Count); 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"; raise Program_Error with "attempt to read from corrupt stream";
end if; end if;
...@@ -2383,6 +2388,11 @@ package body Ada.Containers.Indefinite_Multiway_Trees is ...@@ -2383,6 +2388,11 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
begin begin
Count_Type'Write (Stream, Container.Count); Count_Type'Write (Stream, Container.Count);
if Container.Count = 0 then
return;
end if;
Write_Children (Root_Node (Container)); Write_Children (Root_Node (Container));
end Write; end Write;
......
...@@ -1681,7 +1681,11 @@ package body Ada.Containers.Multiway_Trees is ...@@ -1681,7 +1681,11 @@ package body Ada.Containers.Multiway_Trees is
function Read_Subtree function Read_Subtree
(Parent : Tree_Node_Access) return Tree_Node_Access; (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 -- -- Read_Children --
...@@ -1692,13 +1696,15 @@ package body Ada.Containers.Multiway_Trees is ...@@ -1692,13 +1696,15 @@ package body Ada.Containers.Multiway_Trees is
pragma Assert (Subtree.Children.First = null); pragma Assert (Subtree.Children.First = null);
pragma Assert (Subtree.Children.Last = null); pragma Assert (Subtree.Children.Last = null);
Count : Count_Type; -- number of child subtrees Count : Count_Type'Base;
C : Children_Type; -- Number of child subtrees
C : Children_Type;
begin begin
Count_Type'Read (Stream, Count); 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"; raise Program_Error with "attempt to read from corrupt stream";
end if; end if;
...@@ -1749,7 +1755,7 @@ package body Ada.Containers.Multiway_Trees is ...@@ -1749,7 +1755,7 @@ package body Ada.Containers.Multiway_Trees is
Count_Type'Read (Stream, Total_Count); 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"; raise Program_Error with "attempt to read from corrupt stream";
end if; end if;
...@@ -2428,6 +2434,11 @@ package body Ada.Containers.Multiway_Trees is ...@@ -2428,6 +2434,11 @@ package body Ada.Containers.Multiway_Trees is
begin begin
Count_Type'Write (Stream, Container.Count); Count_Type'Write (Stream, Container.Count);
if Container.Count = 0 then
return;
end if;
Write_Children (Root_Node (Container)); Write_Children (Root_Node (Container));
end Write; end Write;
......
...@@ -6312,7 +6312,7 @@ example: ...@@ -6312,7 +6312,7 @@ example:
@item ^C^COMMENTS1^ (single space) @item ^C^COMMENTS1^ (single space)
@emph{Check comments, 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. is required following the @code{--} of a comment instead of two.
@item ^d^DOS_LINE_ENDINGS^ @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