aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/styleg.adb
diff options
context:
space:
mode:
authorRobert Dewar <dewar@adacore.com>2005-03-29 18:14:20 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2005-03-29 18:14:20 +0200
commitdebe0ab674d54dbe2df6358be39f56143e00ca8e (patch)
treebcdecf2cbba892fbd44f1149051ea028d0d1c515 /gcc/ada/styleg.adb
parentd127f91b1d4b99d53d31a80076bf178ceb4053df (diff)
downloadgcc-debe0ab674d54dbe2df6358be39f56143e00ca8e.zip
gcc-debe0ab674d54dbe2df6358be39f56143e00ca8e.tar.gz
gcc-debe0ab674d54dbe2df6358be39f56143e00ca8e.tar.bz2
errutil.adb, errout.adb: Minor comment updates on Line_Terminator references
2005-03-29 Robert Dewar <dewar@adacore.com> * errutil.adb, errout.adb: Minor comment updates on Line_Terminator references * par-ch10.adb: Add ??? comment about line terminator * styleg.adb (Check_Line_Terminator): Add check for new switch -gnatyd (check dos line terminator). (Check_Line_Max_Length): New procedure, split off from the existing Check_Line_Terminator routine. Separating this out allows -gnatyf to be properly recognized. * styleg.adb: Add ??? comment for line terminator reference * scng.adb (Check_End_Of_Line): Fix bug of -gnatyf being ignored (Check_End_Of_Line): Add -gnatyd handling (check dos line terminators) * styleg.ads (Check_Line_Terminator): Add check for new switch -gnatyd (check dos line terminator). (Check_Line_Max_Length): New procedure, split off from the existing Check_Line_Terminator routine. Separating this out allows -gnatyf to be properly recognized. * stylesw.ads, stylesw.adb: Add handling for new -gnatyd switch (check dos line terminator) * switch-c.adb: Recognize new -gnatyd switch (check dos line terminator) Recognize -gnatwb/-gnatwB switches Include Warn_On_Bad_Fixed_Value for -gnatg * usage.adb: Add line for new -gnatyd switch (check dos line terminator) * usage.adb: Add lines for -gnatwb/-gnatwB * vms_data.ads: Add entry for NOCRLF (-gnatyd) * vms_data.ads: [NO_]BAD_FIXED_VALUES synonym for -gnatwb/-gnatwB * gnat_ugn.texi: Fix overlong lines Document new -gnatyd switch Document new -gnatwb/-gnatwB switches From-SVN: r97169
Diffstat (limited to 'gcc/ada/styleg.adb')
-rw-r--r--gcc/ada/styleg.adb65
1 files changed, 43 insertions, 22 deletions
diff --git a/gcc/ada/styleg.adb b/gcc/ada/styleg.adb
index 91c807b..aec09dd 100644
--- a/gcc/ada/styleg.adb
+++ b/gcc/ada/styleg.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2004 Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2005 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- --
@@ -265,6 +265,8 @@ package body Styleg is
S : Source_Ptr;
begin
+ -- Do we need to worry about UTF_32 line terminators here ???
+
S := Scan_Ptr + 3;
while Source (S) not in Line_Terminator loop
S := S + 1;
@@ -462,18 +464,36 @@ package body Styleg is
end Check_Left_Paren;
---------------------------
+ -- Check_Line_Max_Length --
+ ---------------------------
+
+ -- In check max line length mode (-gnatym), the line length must
+ -- not exceed the permitted maximum value.
+
+ procedure Check_Line_Max_Length (Len : Int) is
+ begin
+ if Style_Check_Max_Line_Length then
+ if Len > Style_Max_Line_Length then
+ Error_Msg
+ ("(style) this line is too long",
+ Current_Line_Start + Source_Ptr (Style_Max_Line_Length));
+ end if;
+ end if;
+ end Check_Line_Max_Length;
+
+ ---------------------------
-- Check_Line_Terminator --
---------------------------
-- In check blanks at end mode (-gnatyb), lines may not end with a
-- trailing space.
- -- In check max line length mode (-gnatym), the line length must
- -- not exceed the permitted maximum value.
-
-- In check form feeds mode (-gnatyf), the line terminator may not
-- be either of the characters FF or VT.
+ -- In check DOS line terminators node (-gnatyd), the line terminator
+ -- must be a single LF, without a following CR.
+
procedure Check_Line_Terminator (Len : Int) is
S : Source_Ptr;
@@ -483,18 +503,30 @@ package body Styleg is
if Style_Check_Form_Feeds then
if Source (Scan_Ptr) = ASCII.FF then
Error_Msg_S ("(style) form feed not allowed");
-
elsif Source (Scan_Ptr) = ASCII.VT then
Error_Msg_S ("(style) vertical tab not allowed");
end if;
end if;
- -- We are now possibly going to check for trailing spaces and maximum
- -- line length. There is no point in doing this if the current line is
- -- empty. It is actually wrong in the case of trailing spaces, because
- -- we scan backwards for this purpose, so we would end up looking at a
- -- different line, or even at invalid buffer locations if we have the
- -- first source line at hand.
+ -- Check DOS line terminator (ignore EOF, since we only get called
+ -- with an EOF if it is the last character in the buffer, and was
+ -- therefore not present in the sources
+
+ if Style_Check_DOS_Line_Terminator then
+ if Source (Scan_Ptr) = EOF then
+ null;
+ elsif Source (Scan_Ptr) /= LF
+ or else Source (Scan_Ptr + 1) = CR
+ then
+ Error_Msg_S ("(style) incorrect line terminator");
+ end if;
+ end if;
+
+ -- We are now possibly going to check for trailing spaces. There is no
+ -- point in doing this if the current line is empty. It is actually
+ -- wrong to do so, because we scan backwards for this purpose, so we
+ -- would end up looking at different line, or even at invalid buffer
+ -- locations if we have the first source line at hand.
if Len = 0 then
return;
@@ -515,17 +547,6 @@ package body Styleg is
end if;
end if;
end if;
-
- -- Check max line length
-
- if Style_Check_Max_Line_Length then
- if Len > Style_Max_Line_Length then
- Error_Msg
- ("(style) this line is too long",
- Current_Line_Start + Source_Ptr (Style_Max_Line_Length));
- end if;
- end if;
-
end Check_Line_Terminator;
--------------------------