g-table.adb, [...]: Fix comment typos.
[platform/upstream/gcc.git] / gcc / ada / gnatfind.adb
index 49fc1ed..5592d52 100644 (file)
@@ -6,42 +6,42 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---         Copyright (C) 1998-2003 Free Software Foundation, Inc.           --
+--          Copyright (C) 1998-2007, 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- --
--- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
 -- for  more details.  You should have  received  a copy of the GNU General --
--- Public License  distributed with GNAT;  see file COPYING.  If not, write --
--- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
--- MA 02111-1307, USA.                                                      --
+-- Public License  distributed with GNAT; see file COPYING3.  If not, go to --
+-- http://www.gnu.org/licenses for a complete copy of the license.          --
 --                                                                          --
 -- GNAT was originally developed  by the GNAT team at  New York University. --
 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with Xr_Tabls;     use Xr_Tabls;
-with Xref_Lib;     use Xref_Lib;
-with Osint;        use Osint;
-with Types;        use Types;
-
-with Gnatvsn;
 with Opt;
+with Osint;    use Osint;
+with Switch;   use Switch;
+with Types;    use Types;
+with Xr_Tabls; use Xr_Tabls;
+with Xref_Lib; use Xref_Lib;
 
 with Ada.Strings.Fixed; use Ada.Strings.Fixed;
 with Ada.Text_IO;       use Ada.Text_IO;
+
 with GNAT.Command_Line; use GNAT.Command_Line;
-with GNAT.Strings;      use GNAT.Strings;
----------------
---  Gnatfind --
----------------
 
-procedure Gnatfind is
+with System.Strings;    use System.Strings;
+
+--------------
+-- Gnatfind --
+--------------
 
+procedure Gnatfind is
    Output_Ref      : Boolean := False;
    Pattern         : Xref_Lib.Search_Pattern;
    Local_Symbols   : Boolean := True;
@@ -67,15 +67,31 @@ procedure Gnatfind is
    procedure Parse_Cmd_Line;
    --  Parse every switch on the command line
 
+   procedure Usage;
+   --  Display the usage
+
    procedure Write_Usage;
-   --  Print a small help page for program usage
+   --  Print a small help page for program usage and exit program
 
    --------------------
    -- Parse_Cmd_Line --
    --------------------
 
    procedure Parse_Cmd_Line is
+
+      procedure Check_Version_And_Help is new Check_Version_And_Help_G (Usage);
+
+      --  Start of processing for Parse_Cmd_Line
+
    begin
+      --  First check for --version or --help
+
+      Check_Version_And_Help ("GNATFIND", "1998");
+
+      --  Now scan the other switches
+
+      GNAT.Command_Line.Initialize_Option_Scan;
+
       loop
          case
            GNAT.Command_Line.Getopt
@@ -87,10 +103,8 @@ procedure Gnatfind is
             when 'a'    =>
                if GNAT.Command_Line.Full_Switch = "a" then
                   Read_Only := True;
-
                elsif GNAT.Command_Line.Full_Switch = "aI" then
                   Osint.Add_Src_Search_Dir (GNAT.Command_Line.Parameter);
-
                else
                   Osint.Add_Lib_Search_Dir (GNAT.Command_Line.Parameter);
                end if;
@@ -117,15 +131,13 @@ procedure Gnatfind is
             when 'n'    =>
                if GNAT.Command_Line.Full_Switch = "nostdinc" then
                   Opt.No_Stdinc := True;
-
-               elsif GNAT.Command_Line.Full_Switch = "nostlib" then
+               elsif GNAT.Command_Line.Full_Switch = "nostdlib" then
                   Opt.No_Stdlib := True;
                end if;
 
             when 'p'    =>
                declare
                   S : constant String := GNAT.Command_Line.Parameter;
-
                begin
                   Prj_File_Length := S'Length;
                   Prj_File (1 .. Prj_File_Length) := S;
@@ -209,6 +221,7 @@ procedure Gnatfind is
                end if;
 
             --  Next arguments are the files to search
+
             else
                Add_Xref_File (S);
                Wide_Search := False;
@@ -233,14 +246,12 @@ procedure Gnatfind is
          Write_Usage;
    end Parse_Cmd_Line;
 
-   -----------------
-   -- Write_Usage --
-   -----------------
+   -----------
+   -- Usage --
+   -----------
 
-   procedure Write_Usage is
+   procedure Usage is
    begin
-      Put_Line ("GNATFIND " & Gnatvsn.Gnat_Version_String
-                & " Copyright 1998-2003, Ada Core Technologies Inc.");
       Put_Line ("Usage: gnatfind pattern[:sourcefile[:line[:column]]] "
                 & "[file1 file2 ...]");
       New_Line;
@@ -277,8 +288,19 @@ procedure Gnatfind is
                 & " only)");
       Put_Line ("   -s        Print source line");
       Put_Line ("   -t        Print type hierarchy");
+   end Usage;
+
+   -----------------
+   -- Write_Usage --
+   -----------------
+
+   procedure Write_Usage is
+   begin
+      Display_Version ("GNATFIND", "1998");
       New_Line;
 
+      Usage;
+
       raise Usage_Error;
    end Write_Usage;
 
@@ -292,8 +314,8 @@ begin
    end if;
 
    --  Special case to speed things up: if the user has a command line of the
-   --  form 'gnatfind entity:file', ie has specified a file and only wants the
-   --  bodies and specs, then we can restrict the search to the .ali file
+   --  form 'gnatfind entity:file', i.e. has specified a file and only wants
+   --  the bodies and specs, then we can restrict the search to the .ali file
    --  associated with 'file'.
 
    if Has_File_In_Entity