+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.
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;
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;
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 => <>);
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;
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 --
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;
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;
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;
begin
Count_Type'Write (Stream, Container.Count);
+
+ if Container.Count = 0 then
+ return;
+ end if;
+
Write_Children (Root_Node (Container));
end Write;
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 --
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;
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;
begin
Count_Type'Write (Stream, Container.Count);
+
+ if Container.Count = 0 then
+ return;
+ end if;
+
Write_Children (Root_Node (Container));
end Write;
@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^