Commit 35a41b73 by Quentin Ochem Committed by Arnaud Charlet

ali.ads, ali.adb (Get_Nat): Raise an exception if the file cursor is not on a natural.

2007-04-06  Quentin Ochem  <ochem@adacore.com>

	* ali.ads, ali.adb (Get_Nat): Raise an exception if the file cursor is
	not on a natural.
	(Scan_ALI): Cancel the xref line if there has been a reading ALI error.

From-SVN: r123548
parent 320ae22a
...@@ -195,6 +195,7 @@ package body ALI is ...@@ -195,6 +195,7 @@ package body ALI is
function Get_Nat return Nat; function Get_Nat return Nat;
-- Skip blanks, then scan out an unsigned integer value in Nat range -- Skip blanks, then scan out an unsigned integer value in Nat range
-- raises ALI_Reading_Error if the encoutered type is not natural.
function Get_Stamp return Time_Stamp_Type; function Get_Stamp return Time_Stamp_Type;
-- Skip blanks, then scan out a time stamp -- Skip blanks, then scan out a time stamp
...@@ -347,7 +348,6 @@ package body ALI is ...@@ -347,7 +348,6 @@ package body ALI is
-- Find start of line -- Find start of line
Ptr1 := P; Ptr1 := P;
while Ptr1 > T'First while Ptr1 > T'First
and then T (Ptr1 - 1) /= CR and then T (Ptr1 - 1) /= CR
and then T (Ptr1 - 1) /= LF and then T (Ptr1 - 1) /= LF
...@@ -478,9 +478,17 @@ package body ALI is ...@@ -478,9 +478,17 @@ package body ALI is
begin begin
Skip_Space; Skip_Space;
-- Check if we are on a number. In the case of bas ALI files, this
-- may not be true.
if not (Nextc in '0' .. '9') then
Fatal_Error;
end if;
V := 0; V := 0;
loop loop
V := V * 10 + (Character'Pos (Getc) - Character'Pos ('0')); V := V * 10 + (Character'Pos (Getc) - Character'Pos ('0'));
exit when At_End_Of_Field; exit when At_End_Of_Field;
exit when Nextc < '0' or Nextc > '9'; exit when Nextc < '0' or Nextc > '9';
end loop; end loop;
...@@ -2186,6 +2194,24 @@ package body ALI is ...@@ -2186,6 +2194,24 @@ package body ALI is
XE.Last_Xref := Xref.Last; XE.Last_Xref := Xref.Last;
C := Nextc; C := Nextc;
exception
when Bad_ALI_Format =>
-- If ignoring errors, then we skip a line with an
-- unexpected error, and try to continue subsequent
-- xref lines.
if Ignore_Errors then
Xref_Entity.Decrement_Last;
Skip_Line;
C := Nextc;
-- Otherwise, we reraise the fatal exception
else
raise;
end if;
end Read_Refs_For_One_Entity; end Read_Refs_For_One_Entity;
end loop; end loop;
...@@ -2209,7 +2235,6 @@ package body ALI is ...@@ -2209,7 +2235,6 @@ package body ALI is
exception exception
when Bad_ALI_Format => when Bad_ALI_Format =>
return No_ALI_Id; return No_ALI_Id;
end Scan_ALI; end Scan_ALI;
--------- ---------
......
...@@ -839,7 +839,7 @@ package ALI is ...@@ -839,7 +839,7 @@ package ALI is
-- reference for the entity name. -- reference for the entity name.
Oref_File_Num : Sdep_Id; Oref_File_Num : Sdep_Id;
-- This field is set to No_Sdep_Id is the entity doesn't override any -- This field is set to No_Sdep_Id if the entity doesn't override any
-- other entity, or to the dependency reference for the overriden -- other entity, or to the dependency reference for the overriden
-- entity. -- entity.
......
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