-- --
-- B o d y --
-- --
--- $Revision: 1.26 $
--- --
--- Copyright (C) 1998-2001 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- --
-- 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. --
+-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
+-- Boston, MA 02110-1301, USA. --
-- --
--- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). --
+-- GNAT was originally developed by the GNAT team at New York University. --
+-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-with Xr_Tabls;
+with Xr_Tabls; use Xr_Tabls;
with Xref_Lib; use Xref_Lib;
-with Ada.Text_IO;
-with GNAT.Command_Line;
+with Osint; use Osint;
+with Types; use Types;
+
with Gnatvsn;
-with Osint;
+with Opt;
+
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
+with Ada.Text_IO; use Ada.Text_IO;
----------------
--- Gnatfind --
----------------
+with GNAT.Command_Line; use GNAT.Command_Line;
-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;
Has_File_In_Entity : Boolean := False;
-- Will be true if a file name was specified in the entity
+ RTS_Specified : String_Access := null;
+ -- Used to detect multiple use of --RTS= switch
+
procedure Parse_Cmd_Line;
-- Parse every switch on the command line
procedure Parse_Cmd_Line is
begin
loop
- case GNAT.Command_Line.Getopt ("a aI: aO: d e f g h I: p: r s t") is
+ case
+ GNAT.Command_Line.Getopt
+ ("a aI: aO: d e f g h I: nostdinc nostdlib p: r s t -RTS=")
+ is
when ASCII.NUL =>
exit;
Osint.Add_Src_Search_Dir (GNAT.Command_Line.Parameter);
Osint.Add_Lib_Search_Dir (GNAT.Command_Line.Parameter);
+ when 'n' =>
+ if GNAT.Command_Line.Full_Switch = "nostdinc" then
+ Opt.No_Stdinc := True;
+ elsif GNAT.Command_Line.Full_Switch = "nostlib" then
+ Opt.No_Stdlib := True;
+ end if;
+
when 'p' =>
declare
S : constant String := GNAT.Command_Line.Parameter;
when 't' =>
Type_Tree := True;
+ -- Only switch starting with -- recognized is --RTS
+
+ when '-' =>
+ -- Check that it is the first time we see this switch
+
+ if RTS_Specified = null then
+ RTS_Specified := new String'(GNAT.Command_Line.Parameter);
+
+ elsif RTS_Specified.all /= GNAT.Command_Line.Parameter then
+ Osint.Fail ("--RTS cannot be specified multiple times");
+ end if;
+
+ Opt.No_Stdinc := True;
+ Opt.RTS_Switch := True;
+
+ declare
+ Src_Path_Name : constant String_Ptr :=
+ Get_RTS_Search_Dir
+ (GNAT.Command_Line.Parameter, Include);
+ Lib_Path_Name : constant String_Ptr :=
+ Get_RTS_Search_Dir
+ (GNAT.Command_Line.Parameter, Objects);
+
+ begin
+ if Src_Path_Name /= null and then Lib_Path_Name /= null then
+ Add_Search_Dirs (Src_Path_Name, Include);
+ Add_Search_Dirs (Lib_Path_Name, Objects);
+
+ elsif Src_Path_Name = null and then Lib_Path_Name = null then
+ Osint.Fail ("RTS path not valid: missing " &
+ "adainclude and adalib directories");
+
+ elsif Src_Path_Name = null then
+ Osint.Fail ("RTS path not valid: missing " &
+ "adainclude directory");
+
+ elsif Lib_Path_Name = null then
+ Osint.Fail ("RTS path not valid: missing " &
+ "adalib directory");
+ end if;
+ end;
+
when others =>
Write_Usage;
end case;
loop
declare
S : constant String := GNAT.Command_Line.Get_Argument;
+
begin
exit when S'Length = 0;
end if;
-- Next arguments are the files to search
+
else
- Add_File (S);
+ Add_Xref_File (S);
Wide_Search := False;
Nb_File := Nb_File + 1;
end if;
when GNAT.Command_Line.Invalid_Parameter =>
Ada.Text_IO.Put_Line ("Parameter missing for : "
- & GNAT.Command_Line.Parameter);
+ & GNAT.Command_Line.Full_Switch);
Write_Usage;
when Xref_Lib.Invalid_Argument =>
-----------------
procedure Write_Usage is
- use Ada.Text_IO;
-
begin
- Put_Line ("GNATFIND " & Gnatvsn.Gnat_Version_String
- & " Copyright 1998-2001, Ada Core Technologies Inc.");
+ Put_Line ("GNATFIND " & Gnatvsn.Gnat_Version_String);
+ Put_Line ("Copyright 1998-2005, AdaCore");
Put_Line ("Usage: gnatfind pattern[:sourcefile[:line[:column]]] "
& "[file1 file2 ...]");
New_Line;
& "references. This parameters are optional");
New_Line;
Put_Line ("gnatfind switches:");
- Put_Line (" -a Consider all files, even when the ali file is "
+ Put_Line (" -a Consider all files, even when the ali file is "
& "readonly");
- Put_Line (" -aIdir Specify source files search path");
- Put_Line (" -aOdir Specify library/object files search path");
- Put_Line (" -d Output derived type information");
- Put_Line (" -e Use the full regular expression set for pattern");
- Put_Line (" -f Output full path name");
- Put_Line (" -g Output information only for global symbols");
- Put_Line (" -Idir Like -aIdir -aOdir");
- Put_Line (" -p file Use file as the default project file");
- Put_Line (" -r Find all references (default to find declaration"
+ Put_Line (" -aIdir Specify source files search path");
+ Put_Line (" -aOdir Specify library/object files search path");
+ Put_Line (" -d Output derived type information");
+ Put_Line (" -e Use the full regular expression set for "
+ & "pattern");
+ Put_Line (" -f Output full path name");
+ Put_Line (" -g Output information only for global symbols");
+ Put_Line (" -Idir Like -aIdir -aOdir");
+ Put_Line (" -nostdinc Don't look for sources in the system default"
+ & " directory");
+ Put_Line (" -nostdlib Don't look for library files in the system"
+ & " default directory");
+ Put_Line (" --RTS=dir specify the default source and object search"
+ & " path");
+ Put_Line (" -p file Use file as the default project file");
+ Put_Line (" -r Find all references (default to find declaration"
& " only)");
- Put_Line (" -s Print source line");
- Put_Line (" -t Print type hierarchy");
+ Put_Line (" -s Print source line");
+ Put_Line (" -t Print type hierarchy");
New_Line;
raise Usage_Error;
end Write_Usage;
-begin
- Osint.Initialize (Osint.Compiler);
+-- Start of processing for Gnatfind
+begin
Parse_Cmd_Line;
if not Have_Entity then