stylesw.adb: Implement -gnaty + - y options

2008-04-08  Robert Dewar  <dewar@adacore.com>

	* stylesw.adb: Implement -gnaty + - y options
	(Set_GNAT_Style_Check_Options): Includ I in style check string

	* stylesw.ads: Add comments for new style switch options

From-SVN: r134055
This commit is contained in:
Robert Dewar 2008-04-08 08:56:20 +02:00 committed by Arnaud Charlet
parent 5723833553
commit 3017937417
2 changed files with 134 additions and 13 deletions

View File

@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2008, 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- --
@ -168,7 +168,7 @@ package body Stylesw is
procedure Set_GNAT_Style_Check_Options is
begin
Reset_Style_Check_Options;
Set_Style_Check_Options ("3aAbcdefhiklmnprsStux");
Set_Style_Check_Options ("3aAbcdefhiIklmnprsStux");
end Set_GNAT_Style_Check_Options;
-----------------------------
@ -195,6 +195,13 @@ package body Stylesw is
is
C : Character;
On : Boolean := True;
-- Set to False if minus encountered
-- Set to True if plus encountered
Last_Option : Character := ' ';
-- Set to last character encountered
procedure Add_Img (N : Natural);
-- Concatenates image of N at end of Style_Msg_Buf
@ -234,10 +241,21 @@ package body Stylesw is
Err_Col := Options'First;
while Err_Col <= Options'Last loop
C := Options (Err_Col);
Last_Option := C;
Err_Col := Err_Col + 1;
case C is
when '1' .. '9' =>
-- Turning switches on
if On then
case C is
when '+' =>
null;
when '-' =>
On := False;
when '0' .. '9' =>
Style_Check_Indentation :=
Character'Pos (C) - Character'Pos ('0');
@ -373,20 +391,122 @@ package body Stylesw is
when 'x' =>
Style_Check_Xtra_Parens := True;
when 'y' =>
Set_Default_Style_Check_Options;
when ' ' =>
null;
when others =>
Err_Col := Err_Col - 1;
Style_Msg_Buf (1 .. 22) := "invalid style switch: ";
Style_Msg_Len := 23;
Style_Msg_Buf (Style_Msg_Len) := C;
OK := False;
Bad_Style_Switch ("invalid style switch: " & C);
return;
end case;
end case;
-- Turning switches off
else
case C is
when '+' =>
On := True;
when '-' =>
null;
when '0' .. '9' =>
Style_Check_Indentation := 0;
when 'a' =>
Style_Check_Attribute_Casing := False;
when 'A' =>
Style_Check_Array_Attribute_Index := False;
when 'b' =>
Style_Check_Blanks_At_End := False;
when 'c' =>
Style_Check_Comments := False;
when 'd' =>
Style_Check_DOS_Line_Terminator := False;
when 'e' =>
Style_Check_End_Labels := False;
when 'f' =>
Style_Check_Form_Feeds := False;
when 'g' =>
Reset_Style_Check_Options;
when 'h' =>
Style_Check_Horizontal_Tabs := False;
when 'i' =>
Style_Check_If_Then_Layout := False;
when 'I' =>
Style_Check_Mode_In := False;
when 'k' =>
Style_Check_Keyword_Casing := False;
when 'l' =>
Style_Check_Layout := False;
when 'L' =>
Style_Max_Nesting_Level := 0;
when 'm' =>
Style_Check_Max_Line_Length := False;
when 'M' =>
Style_Max_Line_Length := 0;
Style_Check_Max_Line_Length := False;
when 'n' =>
Style_Check_Standard := False;
when 'o' =>
Style_Check_Order_Subprograms := False;
when 'p' =>
Style_Check_Pragma_Casing := False;
when 'r' =>
Style_Check_References := False;
when 's' =>
Style_Check_Specs := False;
when 'S' =>
Style_Check_Separate_Stmt_Lines := False;
when 't' =>
Style_Check_Tokens := False;
when 'u' =>
Style_Check_Blank_Lines := False;
when 'x' =>
Style_Check_Xtra_Parens := False;
when ' ' =>
null;
when others =>
Err_Col := Err_Col - 1;
Bad_Style_Switch ("invalid style switch: " & C);
return;
end case;
end if;
end loop;
Style_Check := True;
-- Turn on style checking if other than N at end of string
Style_Check := (Last_Option /= 'N');
OK := True;
end Set_Style_Check_Options;
end Stylesw;

View File

@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2008, 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- --
@ -269,7 +269,7 @@ package Stylesw is
procedure Set_Default_Style_Check_Options;
-- This procedure is called to set the default style checking options in
-- response to a -gnaty switch with no suboptions.
-- response to a -gnaty switch with no suboptions or from -gnatyy.
procedure Set_GNAT_Style_Check_Options;
-- This procedure is called to set the default style checking options for
@ -286,7 +286,8 @@ package Stylesw is
-- This procedure is called to set the style check options that correspond
-- to the characters in the given Options string. If all options are valid,
-- they are set in an additive manner: any previous options are retained
-- unless overridden.
-- unless overridden, unless a minus is encountered, and then subsequent
-- style switches are subtracted from the current set.
--
-- If all options given are valid, then OK is True, Err_Col is set to
-- Options'Last + 1, and Style_Msg_Buf/Style_Msg_Len are unchanged.