diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-06-06 10:41:57 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-06-06 10:41:57 +0000 |
commit | 15203205d09d4c7f07c9849e2bb74e8e1ca2b1db (patch) | |
tree | 4d72d1588d56d4b9ac42f309727482c33856aa1b /gcc/ada/scng.adb | |
parent | 3074277a5536cc600bd52d7d7520ed3fa0235b79 (diff) | |
download | gcc-15203205d09d4c7f07c9849e2bb74e8e1ca2b1db.tar.gz |
2007-04-20 Robert Dewar <dewar@adacore.com>
* scng.adb: (Check_End_Of_Line): Deal with very long lines
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125445 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/scng.adb')
-rw-r--r-- | gcc/ada/scng.adb | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/gcc/ada/scng.adb b/gcc/ada/scng.adb index c4fdd86fbcf..e9a0e0284e1 100644 --- a/gcc/ada/scng.adb +++ b/gcc/ada/scng.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -39,10 +39,9 @@ with Urealp; use Urealp; with Widechar; use Widechar; with System.CRC32; +with System.UTF_32; use System.UTF_32; with System.WCh_Con; use System.WCh_Con; -with GNAT.UTF_32; use GNAT.UTF_32; - package body Scng is use ASCII; @@ -267,6 +266,46 @@ package body Scng is Error_Long_Line; end if; + -- Now one more checking circuit. Normally we are only enforcing a + -- limit of physical characters, with tabs counting as one character. + -- But if after tab expansion we would have a total line length that + -- exceeded 32766, that would really cause trouble, because column + -- positions would exceed the maximum we allow for a column count. + -- Note: the limit is 32766 rather than 32767, since we use a value + -- of 32767 for special purposes (see Sinput). Now we really do not + -- want to go messing with tabs in the normal case, so what we do is + -- to check for a line that has more than 4096 physical characters. + -- Any shorter line could not be a problem, even if it was all tabs. + + if Len >= 4096 then + declare + Col : Natural; + Ptr : Source_Ptr; + + begin + Col := 1; + Ptr := Current_Line_Start; + loop + exit when Ptr = Scan_Ptr; + + if Source (Ptr) = ASCII.HT then + Col := (Col - 1 + 8) / 8 * 8 + 1; + else + Col := Col + 1; + end if; + + if Col > 32766 then + Error_Msg + ("this line is longer than 32766 characters", + Current_Line_Start); + raise Unrecoverable_Error; + end if; + + Ptr := Ptr + 1; + end loop; + end; + end if; + -- Reset wide character byte count for next line Wide_Char_Byte_Count := 0; @@ -2441,6 +2480,14 @@ package body Scng is end loop Tabs_Loop; return Start_Column; + + -- A constraint error can happen only if we have a compiler with checks on + -- and a line with a ludicrous number of tabs or spaces at the start. In + -- such a case, we really don't care if Start_Column is right or not. + + exception + when Constraint_Error => + return Start_Column; end Set_Start_Column; end Scng; |