Commit 0359c57c by Robert Dewar Committed by Arnaud Charlet

gnatname.adb: Minor reformatting

2008-05-26  Robert Dewar  <dewar@adacore.com>

	* gnatname.adb: Minor reformatting

From-SVN: r135899
parent 24b66768
...@@ -201,6 +201,9 @@ procedure Gnatname is ...@@ -201,6 +201,9 @@ procedure Gnatname is
when Error_In_Regexp => when Error_In_Regexp =>
Fail ("invalid regular expression """, S, """"); Fail ("invalid regular expression """, S, """");
end Check_Regular_Expression; end Check_Regular_Expression;
-- Start of processing for Scan_Args
begin begin
-- First check for --version or --help -- First check for --version or --help
...@@ -214,6 +217,7 @@ procedure Gnatname is ...@@ -214,6 +217,7 @@ procedure Gnatname is
Dir_File_Name_Expected := False; Dir_File_Name_Expected := False;
Foreign_Pattern_Expected := False; Foreign_Pattern_Expected := False;
Excluded_Pattern_Expected := False; Excluded_Pattern_Expected := False;
for Next_Arg in 1 .. Argument_Count loop for Next_Arg in 1 .. Argument_Count loop
declare declare
Next_Argv : constant String := Argument (Next_Arg); Next_Argv : constant String := Argument (Next_Arg);
...@@ -221,9 +225,10 @@ procedure Gnatname is ...@@ -221,9 +225,10 @@ procedure Gnatname is
begin begin
if Arg'Length > 0 then if Arg'Length > 0 then
if Project_File_Name_Expected then
-- -P xxx
-- -P xxx
if Project_File_Name_Expected then
if Arg (1) = '-' then if Arg (1) = '-' then
Fail ("project file name missing"); Fail ("project file name missing");
...@@ -233,48 +238,50 @@ procedure Gnatname is ...@@ -233,48 +238,50 @@ procedure Gnatname is
Project_File_Name_Expected := False; Project_File_Name_Expected := False;
end if; end if;
elsif Pragmas_File_Expected then -- -c file
-- -c file
elsif Pragmas_File_Expected then
File_Set := True; File_Set := True;
File_Path := new String'(Arg); File_Path := new String'(Arg);
Create_Project := False; Create_Project := False;
Pragmas_File_Expected := False; Pragmas_File_Expected := False;
elsif Directory_Expected then -- -d xxx
-- -d xxx
elsif Directory_Expected then
Add_Source_Directory (Arg); Add_Source_Directory (Arg);
Directory_Expected := False; Directory_Expected := False;
elsif Dir_File_Name_Expected then -- -D xxx
-- -D xxx
elsif Dir_File_Name_Expected then
Get_Directories (Arg); Get_Directories (Arg);
Dir_File_Name_Expected := False; Dir_File_Name_Expected := False;
elsif Foreign_Pattern_Expected then -- -f xxx
-- -f xxx
elsif Foreign_Pattern_Expected then
Patterns.Append Patterns.Append
(Arguments.Table (Arguments.Last).Foreign_Patterns, (Arguments.Table (Arguments.Last).Foreign_Patterns,
new String'(Arg)); new String'(Arg));
Check_Regular_Expression (Arg); Check_Regular_Expression (Arg);
Foreign_Pattern_Expected := False; Foreign_Pattern_Expected := False;
elsif Excluded_Pattern_Expected then -- -x xxx
-- -x xxx
elsif Excluded_Pattern_Expected then
Patterns.Append Patterns.Append
(Arguments.Table (Arguments.Last).Excluded_Patterns, (Arguments.Table (Arguments.Last).Excluded_Patterns,
new String'(Arg)); new String'(Arg));
Check_Regular_Expression (Arg); Check_Regular_Expression (Arg);
Excluded_Pattern_Expected := False; Excluded_Pattern_Expected := False;
elsif Arg = "--and" then -- There must be at least one Ada pattern or one foreign
-- pattern for the previous section.
-- There must be at least one Ada pattern or one foreign -- --and
-- pattern for the previous section.
elsif Arg = "--and" then
if Patterns.Last if Patterns.Last
(Arguments.Table (Arguments.Last).Name_Patterns) = 0 (Arguments.Table (Arguments.Last).Name_Patterns) = 0
...@@ -297,8 +304,7 @@ procedure Gnatname is ...@@ -297,8 +304,7 @@ procedure Gnatname is
new String'(".")); new String'("."));
end if; end if;
-- Add another component in table Arguments and initialize -- Add and initialize another component to Arguments table
-- it.
Arguments.Increment_Last; Arguments.Increment_Last;
...@@ -319,12 +325,16 @@ procedure Gnatname is ...@@ -319,12 +325,16 @@ procedure Gnatname is
Patterns.Set_Last Patterns.Set_Last
(Arguments.Table (Arguments.Last).Foreign_Patterns, 0); (Arguments.Table (Arguments.Last).Foreign_Patterns, 0);
-- Subdirectory switch
elsif Arg'Length > Subdirs_Switch'Length elsif Arg'Length > Subdirs_Switch'Length
and then Arg (1 .. Subdirs_Switch'Length) = Subdirs_Switch and then Arg (1 .. Subdirs_Switch'Length) = Subdirs_Switch
then then
Subdirs := Subdirs :=
new String'(Arg (Subdirs_Switch'Length + 1 .. Arg'Last)); new String'(Arg (Subdirs_Switch'Length + 1 .. Arg'Last));
-- -c
elsif Arg'Length >= 2 and then Arg (1 .. 2) = "-c" then elsif Arg'Length >= 2 and then Arg (1 .. 2) = "-c" then
if File_Set then if File_Set then
Fail ("only one -P or -c switch may be specified"); Fail ("only one -P or -c switch may be specified");
...@@ -343,6 +353,8 @@ procedure Gnatname is ...@@ -343,6 +353,8 @@ procedure Gnatname is
Create_Project := False; Create_Project := False;
end if; end if;
-- -d
elsif Arg'Length >= 2 and then Arg (1 .. 2) = "-d" then elsif Arg'Length >= 2 and then Arg (1 .. 2) = "-d" then
if Arg'Length = 2 then if Arg'Length = 2 then
Directory_Expected := True; Directory_Expected := True;
...@@ -355,6 +367,8 @@ procedure Gnatname is ...@@ -355,6 +367,8 @@ procedure Gnatname is
Add_Source_Directory (Arg (3 .. Arg'Last)); Add_Source_Directory (Arg (3 .. Arg'Last));
end if; end if;
-- -D
elsif Arg'Length >= 2 and then Arg (1 .. 2) = "-D" then elsif Arg'Length >= 2 and then Arg (1 .. 2) = "-D" then
if Arg'Length = 2 then if Arg'Length = 2 then
Dir_File_Name_Expected := True; Dir_File_Name_Expected := True;
...@@ -367,9 +381,13 @@ procedure Gnatname is ...@@ -367,9 +381,13 @@ procedure Gnatname is
Get_Directories (Arg (3 .. Arg'Last)); Get_Directories (Arg (3 .. Arg'Last));
end if; end if;
-- -eL
elsif Arg = "-eL" then elsif Arg = "-eL" then
Opt.Follow_Links_For_Files := True; Opt.Follow_Links_For_Files := True;
-- -f
elsif Arg'Length >= 2 and then Arg (1 .. 2) = "-f" then elsif Arg'Length >= 2 and then Arg (1 .. 2) = "-f" then
if Arg'Length = 2 then if Arg'Length = 2 then
Foreign_Pattern_Expected := True; Foreign_Pattern_Expected := True;
...@@ -385,15 +403,20 @@ procedure Gnatname is ...@@ -385,15 +403,20 @@ procedure Gnatname is
Check_Regular_Expression (Arg (3 .. Arg'Last)); Check_Regular_Expression (Arg (3 .. Arg'Last));
end if; end if;
-- -gnatep or -gnateD
elsif Arg'Length > 7 and then elsif Arg'Length > 7 and then
(Arg (1 .. 7) = "-gnatep" or else Arg (1 .. 7) = "-gnateD") (Arg (1 .. 7) = "-gnatep" or else Arg (1 .. 7) = "-gnateD")
then then
Preprocessor_Switches.Append (new String'(Arg)); Preprocessor_Switches.Append (new String'(Arg));
-- -h
elsif Arg = "-h" then elsif Arg = "-h" then
Usage_Needed := True; Usage_Needed := True;
-- -p
elsif Arg'Length >= 2 and then Arg (1 .. 2) = "-P" then elsif Arg'Length >= 2 and then Arg (1 .. 2) = "-P" then
if File_Set then if File_Set then
Fail ("only one -c or -P switch may be specified"); Fail ("only one -c or -P switch may be specified");
...@@ -414,6 +437,8 @@ procedure Gnatname is ...@@ -414,6 +437,8 @@ procedure Gnatname is
Create_Project := True; Create_Project := True;
-- -v
elsif Arg = "-v" then elsif Arg = "-v" then
if Opt.Verbose_Mode then if Opt.Verbose_Mode then
Very_Verbose := True; Very_Verbose := True;
...@@ -421,6 +446,8 @@ procedure Gnatname is ...@@ -421,6 +446,8 @@ procedure Gnatname is
Opt.Verbose_Mode := True; Opt.Verbose_Mode := True;
end if; end if;
-- -x
elsif Arg'Length >= 2 and then Arg (1 .. 2) = "-x" then elsif Arg'Length >= 2 and then Arg (1 .. 2) = "-x" then
if Arg'Length = 2 then if Arg'Length = 2 then
Excluded_Pattern_Expected := True; Excluded_Pattern_Expected := True;
...@@ -436,9 +463,13 @@ procedure Gnatname is ...@@ -436,9 +463,13 @@ procedure Gnatname is
Check_Regular_Expression (Arg (3 .. Arg'Last)); Check_Regular_Expression (Arg (3 .. Arg'Last));
end if; end if;
-- Junk switch starting with minus
elsif Arg (1) = '-' then elsif Arg (1) = '-' then
Fail ("wrong switch: " & Arg); Fail ("wrong switch: " & Arg);
-- Not a recognized switch, assume file name
else else
Canonical_Case_File_Name (Arg); Canonical_Case_File_Name (Arg);
Patterns.Append Patterns.Append
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment