styleg.adb (Check_Comment): More liberal rules for comment placement
2007-12-06 Robert Dewar <dewar@adacore.com> * styleg.adb (Check_Comment): More liberal rules for comment placement From-SVN: r130866
This commit is contained in:
parent
31eee11b7c
commit
46edcdb100
|
@ -256,11 +256,16 @@ package body Styleg is
|
|||
-- range 16#21#..16#2F# or 16#3A#..16#3F#. This allows special
|
||||
-- comments, such as those generated by gnatprep, or those that
|
||||
-- appear in the SPARK annotation language to be accepted.
|
||||
--
|
||||
|
||||
-- Note: for GNAT internal files (-gnatg switch set on for the
|
||||
-- compilation), the only special sequence recognized and allowed
|
||||
-- is --! as generated by gnatprep.
|
||||
|
||||
-- 6. In addition, the comment must be properly indented if comment
|
||||
-- indentation checking is active (Style_Check_Indentation non-zero).
|
||||
-- Either the start column must be a multiple of this indentation,
|
||||
-- or the indentation must match that of the next non-blank line.
|
||||
|
||||
procedure Check_Comment is
|
||||
S : Source_Ptr;
|
||||
C : Character;
|
||||
|
@ -269,6 +274,11 @@ package body Styleg is
|
|||
-- Returns True if the last two characters on the line are -- which
|
||||
-- characterizes a box comment (as for example follows this spec).
|
||||
|
||||
function Same_Column_As_Next_Non_Blank_Line return Boolean;
|
||||
-- Called for a full line comment. If the indentation of this commment
|
||||
-- matches that of the next non-blank line in the source, then True is
|
||||
-- returned, otherwise False.
|
||||
|
||||
--------------------
|
||||
-- Is_Box_Comment --
|
||||
--------------------
|
||||
|
@ -287,6 +297,32 @@ package body Styleg is
|
|||
return Source (S - 1) = '-' and then Source (S - 2) = '-';
|
||||
end Is_Box_Comment;
|
||||
|
||||
----------------------------------------
|
||||
-- Same_Column_As_Next_Non_Blank_Line --
|
||||
----------------------------------------
|
||||
|
||||
function Same_Column_As_Next_Non_Blank_Line return Boolean is
|
||||
P : Source_Ptr;
|
||||
|
||||
begin
|
||||
-- Step to end of line
|
||||
|
||||
P := Scan_Ptr + 2;
|
||||
while Source (P) not in Line_Terminator loop
|
||||
P := P + 1;
|
||||
end loop;
|
||||
|
||||
-- Step past blanks, and line terminators (UTF_32 case???)
|
||||
|
||||
while Source (P) <= ' ' and then Source (P) /= EOF loop
|
||||
P := P + 1;
|
||||
end loop;
|
||||
|
||||
-- Compare columns
|
||||
|
||||
return Get_Column_Number (Scan_Ptr) = Get_Column_Number (P);
|
||||
end Same_Column_As_Next_Non_Blank_Line;
|
||||
|
||||
-- Start of processing for Check_Comment
|
||||
|
||||
begin
|
||||
|
@ -320,12 +356,15 @@ package body Styleg is
|
|||
|
||||
if Style_Check_Indentation /= 0 then
|
||||
if Start_Column rem Style_Check_Indentation /= 0 then
|
||||
if not Same_Column_As_Next_Non_Blank_Line then
|
||||
Error_Msg_S ("(style) bad column");
|
||||
end if;
|
||||
|
||||
return;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- If we are not checking comments, nothing to do
|
||||
-- If we are not checking comments, nothing more to do
|
||||
|
||||
if not Style_Check_Comments then
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue