summaryrefslogtreecommitdiff
path: root/gcc/ada/scng.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/scng.adb')
-rw-r--r--gcc/ada/scng.adb166
1 files changed, 76 insertions, 90 deletions
diff --git a/gcc/ada/scng.adb b/gcc/ada/scng.adb
index ef3d665554a..8b08949601a 100644
--- a/gcc/ada/scng.adb
+++ b/gcc/ada/scng.adb
@@ -259,6 +259,82 @@ package body Scng is
end case;
end Accumulate_Token_Checksum_GNAT_5_03;
+ -----------------------
+ -- Check_End_Of_Line --
+ -----------------------
+
+ procedure Check_End_Of_Line is
+ Len : constant Int :=
+ Int (Scan_Ptr) -
+ Int (Current_Line_Start) -
+ Wide_Char_Byte_Count;
+
+ -- Start of processing for Check_End_Of_Line
+
+ begin
+ if Style_Check then
+ Style.Check_Line_Terminator (Len);
+ end if;
+
+ -- Deal with checking maximum line length
+
+ if Style_Check and Style_Check_Max_Line_Length then
+ Style.Check_Line_Max_Length (Len);
+
+ -- If style checking is inactive, check maximum line length against
+ -- standard value.
+
+ elsif Len > Max_Line_Length then
+ Error_Msg
+ ("this line is too long",
+ Current_Line_Start + Source_Ptr (Max_Line_Length));
+ 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;
+ end Check_End_Of_Line;
+
----------------------------
-- Determine_Token_Casing --
----------------------------
@@ -336,10 +412,6 @@ package body Scng is
Wptr : Source_Ptr;
-- Used to remember start of last wide character scanned
- procedure Check_End_Of_Line;
- -- Called when end of line encountered. Checks that line is not too
- -- long, and that other style checks for the end of line are met.
-
function Double_Char_Token (C : Character) return Boolean;
-- This function is used for double character tokens like := or <>. It
-- checks if the character following Source (Scan_Ptr) is C, and if so
@@ -359,9 +431,6 @@ package body Scng is
-- past the illegal character, which may still leave us pointing to
-- junk, not much we can do if the escape sequence is messed up!
- procedure Error_Long_Line;
- -- Signal error of excessively long line
-
procedure Error_No_Double_Underline;
-- Signal error of two underline or punctuation characters in a row.
-- Called with Scan_Ptr pointing to second underline/punctuation char.
@@ -389,78 +458,6 @@ package body Scng is
-- character sequence, does not modify the scan pointer in any case.
-----------------------
- -- Check_End_Of_Line --
- -----------------------
-
- procedure Check_End_Of_Line is
- Len : constant Int :=
- Int (Scan_Ptr) -
- Int (Current_Line_Start) -
- Wide_Char_Byte_Count;
-
- begin
- if Style_Check then
- Style.Check_Line_Terminator (Len);
- end if;
-
- -- Deal with checking maximum line length
-
- if Style_Check and Style_Check_Max_Line_Length then
- Style.Check_Line_Max_Length (Len);
-
- -- If style checking is inactive, check maximum line length against
- -- standard value.
-
- elsif Len > Max_Line_Length then
- 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;
- end Check_End_Of_Line;
-
- -----------------------
-- Double_Char_Token --
-----------------------
@@ -505,17 +502,6 @@ package body Scng is
Error_Msg ("illegal wide character", Wptr);
end Error_Illegal_Wide_Character;
- ---------------------
- -- Error_Long_Line --
- ---------------------
-
- procedure Error_Long_Line is
- begin
- Error_Msg
- ("this line is too long",
- Current_Line_Start + Source_Ptr (Max_Line_Length));
- end Error_Long_Line;
-
-------------------------------
-- Error_No_Double_Underline --
-------------------------------