OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [ada/] [a-clrefi.adb] - Diff between revs 816 and 826

Only display areas with differences | Details | Blame | View Log

Rev 816 Rev 826
------------------------------------------------------------------------------
------------------------------------------------------------------------------
--                                                                          --
--                                                                          --
--                         GNAT RUN-TIME COMPONENTS                         --
--                         GNAT RUN-TIME COMPONENTS                         --
--                                                                          --
--                                                                          --
--       A D A . C O M M A N D _ L I N E . R E S P O N S E _ F I L E        --
--       A D A . C O M M A N D _ L I N E . R E S P O N S E _ F I L E        --
--                                                                          --
--                                                                          --
--                                 B o d y                                  --
--                                 B o d y                                  --
--                                                                          --
--                                                                          --
--          Copyright (C) 2007-2009, Free Software Foundation, Inc.         --
--          Copyright (C) 2007-2009, Free Software Foundation, Inc.         --
--                                                                          --
--                                                                          --
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
-- 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- --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 3,  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- --
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
--                                                                          --
--                                                                          --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception,   --
-- additional permissions described in the GCC Runtime Library Exception,   --
-- version 3.1, as published by the Free Software Foundation.               --
-- version 3.1, as published by the Free Software Foundation.               --
--                                                                          --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
-- <http://www.gnu.org/licenses/>.                                          --
--                                                                          --
--                                                                          --
-- GNAT was originally developed  by the GNAT team at  New York University. --
-- GNAT was originally developed  by the GNAT team at  New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
--                                                                          --
--                                                                          --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
 
 
pragma Compiler_Unit;
pragma Compiler_Unit;
 
 
with Ada.Unchecked_Deallocation;
with Ada.Unchecked_Deallocation;
 
 
with System.OS_Lib; use System.OS_Lib;
with System.OS_Lib; use System.OS_Lib;
 
 
package body Ada.Command_Line.Response_File is
package body Ada.Command_Line.Response_File is
 
 
   type File_Rec;
   type File_Rec;
   type File_Ptr is access File_Rec;
   type File_Ptr is access File_Rec;
   type File_Rec is record
   type File_Rec is record
      Name : String_Access;
      Name : String_Access;
      Next : File_Ptr;
      Next : File_Ptr;
      Prev : File_Ptr;
      Prev : File_Ptr;
   end record;
   end record;
   --  To build a stack of response file names
   --  To build a stack of response file names
 
 
   procedure Free is new Ada.Unchecked_Deallocation (File_Rec, File_Ptr);
   procedure Free is new Ada.Unchecked_Deallocation (File_Rec, File_Ptr);
 
 
   type Argument_List_Access is access Argument_List;
   type Argument_List_Access is access Argument_List;
   procedure Free is new Ada.Unchecked_Deallocation
   procedure Free is new Ada.Unchecked_Deallocation
     (Argument_List, Argument_List_Access);
     (Argument_List, Argument_List_Access);
   --  Free only the allocated Argument_List, not allocated String components
   --  Free only the allocated Argument_List, not allocated String components
 
 
   --------------------
   --------------------
   -- Arguments_From --
   -- Arguments_From --
   --------------------
   --------------------
 
 
   function Arguments_From
   function Arguments_From
     (Response_File_Name        : String;
     (Response_File_Name        : String;
      Recursive                 : Boolean := False;
      Recursive                 : Boolean := False;
      Ignore_Non_Existing_Files : Boolean := False)
      Ignore_Non_Existing_Files : Boolean := False)
      return Argument_List
      return Argument_List
   is
   is
      First_File : File_Ptr := null;
      First_File : File_Ptr := null;
      Last_File  : File_Ptr := null;
      Last_File  : File_Ptr := null;
      --  The stack of response files
      --  The stack of response files
 
 
      Arguments  : Argument_List_Access := new Argument_List (1 .. 4);
      Arguments  : Argument_List_Access := new Argument_List (1 .. 4);
      Last_Arg   : Natural := 0;
      Last_Arg   : Natural := 0;
 
 
      procedure Add_Argument (Arg : String);
      procedure Add_Argument (Arg : String);
      --  Add argument Arg to argument list Arguments, increasing Arguments
      --  Add argument Arg to argument list Arguments, increasing Arguments
      --  if necessary.
      --  if necessary.
 
 
      procedure Recurse (File_Name : String);
      procedure Recurse (File_Name : String);
      --  Get the arguments from the file and call itself recursively if one of
      --  Get the arguments from the file and call itself recursively if one of
      --  the argument starts with character '@'.
      --  the argument starts with character '@'.
 
 
      ------------------
      ------------------
      -- Add_Argument --
      -- Add_Argument --
      ------------------
      ------------------
 
 
      procedure Add_Argument (Arg : String) is
      procedure Add_Argument (Arg : String) is
      begin
      begin
         if Last_Arg = Arguments'Last then
         if Last_Arg = Arguments'Last then
            declare
            declare
               New_Arguments : constant Argument_List_Access :=
               New_Arguments : constant Argument_List_Access :=
                                 new Argument_List (1 .. Arguments'Last * 2);
                                 new Argument_List (1 .. Arguments'Last * 2);
            begin
            begin
               New_Arguments (Arguments'Range) := Arguments.all;
               New_Arguments (Arguments'Range) := Arguments.all;
               Arguments.all := (others => null);
               Arguments.all := (others => null);
               Free (Arguments);
               Free (Arguments);
               Arguments := New_Arguments;
               Arguments := New_Arguments;
            end;
            end;
         end if;
         end if;
 
 
         Last_Arg := Last_Arg + 1;
         Last_Arg := Last_Arg + 1;
         Arguments (Last_Arg) := new String'(Arg);
         Arguments (Last_Arg) := new String'(Arg);
      end Add_Argument;
      end Add_Argument;
 
 
      -------------
      -------------
      -- Recurse --
      -- Recurse --
      -------------
      -------------
 
 
      procedure Recurse (File_Name : String) is
      procedure Recurse (File_Name : String) is
         FD : File_Descriptor;
         FD : File_Descriptor;
 
 
         Buffer_Size : constant := 1500;
         Buffer_Size : constant := 1500;
         Buffer : String (1 .. Buffer_Size);
         Buffer : String (1 .. Buffer_Size);
 
 
         Buffer_Length : Natural;
         Buffer_Length : Natural;
 
 
         Buffer_Cursor : Natural;
         Buffer_Cursor : Natural;
 
 
         End_Of_File_Reached : Boolean;
         End_Of_File_Reached : Boolean;
 
 
         Line : String (1 .. Max_Line_Length + 1);
         Line : String (1 .. Max_Line_Length + 1);
         Last : Natural;
         Last : Natural;
 
 
         First_Char : Positive;
         First_Char : Positive;
         --  Index of the first character of an argument in Line
         --  Index of the first character of an argument in Line
 
 
         Last_Char : Natural;
         Last_Char : Natural;
         --  Index of the last character of an argument in Line
         --  Index of the last character of an argument in Line
 
 
         In_String : Boolean;
         In_String : Boolean;
         --  True when inside a quoted string
         --  True when inside a quoted string
 
 
         Arg : Positive;
         Arg : Positive;
 
 
         function End_Of_File return Boolean;
         function End_Of_File return Boolean;
         --  True when the end of the response file has been reached
         --  True when the end of the response file has been reached
 
 
         procedure Get_Buffer;
         procedure Get_Buffer;
         --  Read one buffer from the response file
         --  Read one buffer from the response file
 
 
         procedure Get_Line;
         procedure Get_Line;
         --  Get one line from the response file
         --  Get one line from the response file
 
 
         -----------------
         -----------------
         -- End_Of_File --
         -- End_Of_File --
         -----------------
         -----------------
 
 
         function End_Of_File return Boolean is
         function End_Of_File return Boolean is
         begin
         begin
            return End_Of_File_Reached and then Buffer_Cursor > Buffer_Length;
            return End_Of_File_Reached and then Buffer_Cursor > Buffer_Length;
         end End_Of_File;
         end End_Of_File;
 
 
         ----------------
         ----------------
         -- Get_Buffer --
         -- Get_Buffer --
         ----------------
         ----------------
 
 
         procedure Get_Buffer is
         procedure Get_Buffer is
         begin
         begin
            Buffer_Length := Read (FD, Buffer (1)'Address, Buffer'Length);
            Buffer_Length := Read (FD, Buffer (1)'Address, Buffer'Length);
            End_Of_File_Reached := Buffer_Length < Buffer'Length;
            End_Of_File_Reached := Buffer_Length < Buffer'Length;
            Buffer_Cursor := 1;
            Buffer_Cursor := 1;
         end Get_Buffer;
         end Get_Buffer;
 
 
         --------------
         --------------
         -- Get_Line --
         -- Get_Line --
         --------------
         --------------
 
 
         procedure Get_Line is
         procedure Get_Line is
            Ch : Character;
            Ch : Character;
 
 
         begin
         begin
            Last := 0;
            Last := 0;
 
 
            if End_Of_File then
            if End_Of_File then
               return;
               return;
            end if;
            end if;
 
 
            loop
            loop
               Ch := Buffer (Buffer_Cursor);
               Ch := Buffer (Buffer_Cursor);
 
 
               exit when Ch = ASCII.CR or else
               exit when Ch = ASCII.CR or else
                         Ch = ASCII.LF or else
                         Ch = ASCII.LF or else
                         Ch = ASCII.FF;
                         Ch = ASCII.FF;
 
 
               Last := Last + 1;
               Last := Last + 1;
               Line (Last) := Ch;
               Line (Last) := Ch;
 
 
               if Last = Line'Last then
               if Last = Line'Last then
                  return;
                  return;
               end if;
               end if;
 
 
               Buffer_Cursor := Buffer_Cursor + 1;
               Buffer_Cursor := Buffer_Cursor + 1;
 
 
               if Buffer_Cursor > Buffer_Length then
               if Buffer_Cursor > Buffer_Length then
                  Get_Buffer;
                  Get_Buffer;
 
 
                  if End_Of_File then
                  if End_Of_File then
                     return;
                     return;
                  end if;
                  end if;
               end if;
               end if;
            end loop;
            end loop;
 
 
            loop
            loop
               Ch := Buffer (Buffer_Cursor);
               Ch := Buffer (Buffer_Cursor);
 
 
               exit when Ch /= ASCII.HT and then
               exit when Ch /= ASCII.HT and then
                         Ch /= ASCII.LF and then
                         Ch /= ASCII.LF and then
                         Ch /= ASCII.FF;
                         Ch /= ASCII.FF;
 
 
               Buffer_Cursor := Buffer_Cursor + 1;
               Buffer_Cursor := Buffer_Cursor + 1;
 
 
               if Buffer_Cursor > Buffer_Length then
               if Buffer_Cursor > Buffer_Length then
                  Get_Buffer;
                  Get_Buffer;
 
 
                  if End_Of_File then
                  if End_Of_File then
                     return;
                     return;
                  end if;
                  end if;
               end if;
               end if;
            end loop;
            end loop;
         end Get_Line;
         end Get_Line;
 
 
      --  Start or Recurse
      --  Start or Recurse
 
 
      begin
      begin
         Last_Arg := 0;
         Last_Arg := 0;
 
 
         --  Open the response file. If not found, fail or report a warning,
         --  Open the response file. If not found, fail or report a warning,
         --  depending on the value of Ignore_Non_Existing_Files.
         --  depending on the value of Ignore_Non_Existing_Files.
 
 
         FD := Open_Read (File_Name, Text);
         FD := Open_Read (File_Name, Text);
 
 
         if FD = Invalid_FD then
         if FD = Invalid_FD then
            if Ignore_Non_Existing_Files then
            if Ignore_Non_Existing_Files then
               return;
               return;
            else
            else
               raise File_Does_Not_Exist;
               raise File_Does_Not_Exist;
            end if;
            end if;
         end if;
         end if;
 
 
         --  Put the response file name on the stack
         --  Put the response file name on the stack
 
 
         if First_File = null then
         if First_File = null then
            First_File :=
            First_File :=
              new File_Rec'
              new File_Rec'
                (Name => new String'(File_Name),
                (Name => new String'(File_Name),
                 Next => null,
                 Next => null,
                 Prev => null);
                 Prev => null);
            Last_File  := First_File;
            Last_File  := First_File;
 
 
         else
         else
            declare
            declare
               Current : File_Ptr := First_File;
               Current : File_Ptr := First_File;
 
 
            begin
            begin
               loop
               loop
                  if Current.Name.all = File_Name then
                  if Current.Name.all = File_Name then
                     raise Circularity_Detected;
                     raise Circularity_Detected;
                  end if;
                  end if;
 
 
                  Current := Current.Next;
                  Current := Current.Next;
                  exit when Current = null;
                  exit when Current = null;
               end loop;
               end loop;
 
 
               Last_File.Next :=
               Last_File.Next :=
                 new File_Rec'
                 new File_Rec'
                   (Name => new String'(File_Name),
                   (Name => new String'(File_Name),
                    Next => null,
                    Next => null,
                    Prev => Last_File);
                    Prev => Last_File);
               Last_File := Last_File.Next;
               Last_File := Last_File.Next;
            end;
            end;
         end if;
         end if;
 
 
         End_Of_File_Reached := False;
         End_Of_File_Reached := False;
         Get_Buffer;
         Get_Buffer;
 
 
         --  Read the response file line by line
         --  Read the response file line by line
 
 
         Line_Loop :
         Line_Loop :
         while not End_Of_File loop
         while not End_Of_File loop
            Get_Line;
            Get_Line;
 
 
            if Last = Line'Last then
            if Last = Line'Last then
               raise Line_Too_Long;
               raise Line_Too_Long;
            end if;
            end if;
 
 
            First_Char := 1;
            First_Char := 1;
 
 
            --  Get each argument on the line
            --  Get each argument on the line
 
 
            Arg_Loop :
            Arg_Loop :
            loop
            loop
               --  First, skip any white space
               --  First, skip any white space
 
 
               while First_Char <= Last loop
               while First_Char <= Last loop
                  exit when Line (First_Char) /= ' ' and then
                  exit when Line (First_Char) /= ' ' and then
                            Line (First_Char) /= ASCII.HT;
                            Line (First_Char) /= ASCII.HT;
                  First_Char := First_Char + 1;
                  First_Char := First_Char + 1;
               end loop;
               end loop;
 
 
               exit Arg_Loop when First_Char > Last;
               exit Arg_Loop when First_Char > Last;
 
 
               Last_Char := First_Char;
               Last_Char := First_Char;
               In_String := False;
               In_String := False;
 
 
               --  Get the character one by one
               --  Get the character one by one
 
 
               Character_Loop :
               Character_Loop :
               while Last_Char <= Last loop
               while Last_Char <= Last loop
 
 
                  --  Inside a string, check only for '"'
                  --  Inside a string, check only for '"'
 
 
                  if In_String then
                  if In_String then
                     if Line (Last_Char) = '"' then
                     if Line (Last_Char) = '"' then
 
 
                        --  Remove the '"'
                        --  Remove the '"'
 
 
                        Line (Last_Char .. Last - 1) :=
                        Line (Last_Char .. Last - 1) :=
                          Line (Last_Char + 1 .. Last);
                          Line (Last_Char + 1 .. Last);
                        Last := Last - 1;
                        Last := Last - 1;
 
 
                        --  End of string is end of argument
                        --  End of string is end of argument
 
 
                        if Last_Char > Last or else
                        if Last_Char > Last or else
                          Line (Last_Char) = ' ' or else
                          Line (Last_Char) = ' ' or else
                          Line (Last_Char) = ASCII.HT
                          Line (Last_Char) = ASCII.HT
                        then
                        then
                           In_String := False;
                           In_String := False;
 
 
                           Last_Char := Last_Char - 1;
                           Last_Char := Last_Char - 1;
                           exit Character_Loop;
                           exit Character_Loop;
 
 
                        else
                        else
                           --  If there are two consecutive '"', the quoted
                           --  If there are two consecutive '"', the quoted
                           --  string is not closed
                           --  string is not closed
 
 
                           In_String := Line (Last_Char) = '"';
                           In_String := Line (Last_Char) = '"';
 
 
                           if In_String then
                           if In_String then
                              Last_Char := Last_Char + 1;
                              Last_Char := Last_Char + 1;
                           end if;
                           end if;
                        end if;
                        end if;
 
 
                     else
                     else
                        Last_Char := Last_Char + 1;
                        Last_Char := Last_Char + 1;
                     end if;
                     end if;
 
 
                  elsif Last_Char = Last then
                  elsif Last_Char = Last then
 
 
                     --  An opening '"' at the end of the line is an error
                     --  An opening '"' at the end of the line is an error
 
 
                     if Line (Last) = '"' then
                     if Line (Last) = '"' then
                        raise No_Closing_Quote;
                        raise No_Closing_Quote;
 
 
                     else
                     else
                        --  The argument ends with the line
                        --  The argument ends with the line
 
 
                        exit Character_Loop;
                        exit Character_Loop;
                     end if;
                     end if;
 
 
                  elsif Line (Last_Char) = '"' then
                  elsif Line (Last_Char) = '"' then
 
 
                     --  Entering a quoted string: remove the '"'
                     --  Entering a quoted string: remove the '"'
 
 
                     In_String := True;
                     In_String := True;
                     Line (Last_Char .. Last - 1) :=
                     Line (Last_Char .. Last - 1) :=
                       Line (Last_Char + 1 .. Last);
                       Line (Last_Char + 1 .. Last);
                     Last := Last - 1;
                     Last := Last - 1;
 
 
                  else
                  else
                     --  Outside quoted strings, white space ends the argument
                     --  Outside quoted strings, white space ends the argument
 
 
                     exit Character_Loop
                     exit Character_Loop
                          when Line (Last_Char + 1) = ' ' or else
                          when Line (Last_Char + 1) = ' ' or else
                               Line (Last_Char + 1) = ASCII.HT;
                               Line (Last_Char + 1) = ASCII.HT;
 
 
                     Last_Char := Last_Char + 1;
                     Last_Char := Last_Char + 1;
                  end if;
                  end if;
               end loop Character_Loop;
               end loop Character_Loop;
 
 
               --  It is an error to not close a quoted string before the end
               --  It is an error to not close a quoted string before the end
               --  of the line.
               --  of the line.
 
 
               if In_String then
               if In_String then
                  raise No_Closing_Quote;
                  raise No_Closing_Quote;
               end if;
               end if;
 
 
               --  Add the argument to the list
               --  Add the argument to the list
 
 
               declare
               declare
                  Arg : String (1 .. Last_Char - First_Char + 1);
                  Arg : String (1 .. Last_Char - First_Char + 1);
               begin
               begin
                  Arg := Line (First_Char .. Last_Char);
                  Arg := Line (First_Char .. Last_Char);
                  Add_Argument (Arg);
                  Add_Argument (Arg);
               end;
               end;
 
 
               --  Next argument, if line is not finished
               --  Next argument, if line is not finished
 
 
               First_Char := Last_Char + 1;
               First_Char := Last_Char + 1;
            end loop Arg_Loop;
            end loop Arg_Loop;
         end loop Line_Loop;
         end loop Line_Loop;
 
 
         Close (FD);
         Close (FD);
 
 
         --  If Recursive is True, check for any argument starting with '@'
         --  If Recursive is True, check for any argument starting with '@'
 
 
         if Recursive then
         if Recursive then
            Arg := 1;
            Arg := 1;
            while Arg <= Last_Arg loop
            while Arg <= Last_Arg loop
 
 
               if Arguments (Arg)'Length > 0 and then
               if Arguments (Arg)'Length > 0 and then
                  Arguments (Arg) (1) = '@'
                  Arguments (Arg) (1) = '@'
               then
               then
                  --  Ignore argument "@" with no file name
                  --  Ignore argument "@" with no file name
 
 
                  if Arguments (Arg)'Length = 1 then
                  if Arguments (Arg)'Length = 1 then
                     Arguments (Arg .. Last_Arg - 1) :=
                     Arguments (Arg .. Last_Arg - 1) :=
                       Arguments (Arg + 1 .. Last_Arg);
                       Arguments (Arg + 1 .. Last_Arg);
                     Last_Arg := Last_Arg - 1;
                     Last_Arg := Last_Arg - 1;
 
 
                  else
                  else
                     --  Save the current arguments and get those in the new
                     --  Save the current arguments and get those in the new
                     --  response file.
                     --  response file.
 
 
                     declare
                     declare
                        Inc_File_Name     : constant String :=
                        Inc_File_Name     : constant String :=
                                              Arguments (Arg)
                                              Arguments (Arg)
                                              (2 .. Arguments (Arg)'Last);
                                              (2 .. Arguments (Arg)'Last);
                        Current_Arguments : constant Argument_List :=
                        Current_Arguments : constant Argument_List :=
                                              Arguments (1 .. Last_Arg);
                                              Arguments (1 .. Last_Arg);
                     begin
                     begin
                        Recurse (Inc_File_Name);
                        Recurse (Inc_File_Name);
 
 
                        --  Insert the new arguments where the new response
                        --  Insert the new arguments where the new response
                        --  file was imported.
                        --  file was imported.
 
 
                        declare
                        declare
                           New_Arguments : constant Argument_List :=
                           New_Arguments : constant Argument_List :=
                                             Arguments (1 .. Last_Arg);
                                             Arguments (1 .. Last_Arg);
                           New_Last_Arg  : constant Positive :=
                           New_Last_Arg  : constant Positive :=
                                             Current_Arguments'Length +
                                             Current_Arguments'Length +
                                             New_Arguments'Length - 1;
                                             New_Arguments'Length - 1;
 
 
                        begin
                        begin
                           --  Grow Arguments if it is not large enough
                           --  Grow Arguments if it is not large enough
 
 
                           if Arguments'Last < New_Last_Arg then
                           if Arguments'Last < New_Last_Arg then
                              Last_Arg := Arguments'Last;
                              Last_Arg := Arguments'Last;
                              Free (Arguments);
                              Free (Arguments);
 
 
                              while Last_Arg < New_Last_Arg loop
                              while Last_Arg < New_Last_Arg loop
                                 Last_Arg := Last_Arg * 2;
                                 Last_Arg := Last_Arg * 2;
                              end loop;
                              end loop;
 
 
                              Arguments := new Argument_List (1 .. Last_Arg);
                              Arguments := new Argument_List (1 .. Last_Arg);
                           end if;
                           end if;
 
 
                           Last_Arg := New_Last_Arg;
                           Last_Arg := New_Last_Arg;
 
 
                           Arguments (1 .. Last_Arg) :=
                           Arguments (1 .. Last_Arg) :=
                             Current_Arguments (1 .. Arg - 1) &
                             Current_Arguments (1 .. Arg - 1) &
                           New_Arguments &
                           New_Arguments &
                           Current_Arguments
                           Current_Arguments
                             (Arg + 1 .. Current_Arguments'Last);
                             (Arg + 1 .. Current_Arguments'Last);
 
 
                           Arg := Arg + New_Arguments'Length;
                           Arg := Arg + New_Arguments'Length;
                        end;
                        end;
                     end;
                     end;
                  end if;
                  end if;
 
 
               else
               else
                  Arg := Arg + 1;
                  Arg := Arg + 1;
               end if;
               end if;
            end loop;
            end loop;
         end if;
         end if;
 
 
         --  Remove the response file name from the stack
         --  Remove the response file name from the stack
 
 
         if First_File = Last_File then
         if First_File = Last_File then
            System.Strings.Free (First_File.Name);
            System.Strings.Free (First_File.Name);
            Free (First_File);
            Free (First_File);
            First_File := null;
            First_File := null;
            Last_File := null;
            Last_File := null;
 
 
         else
         else
            System.Strings.Free (Last_File.Name);
            System.Strings.Free (Last_File.Name);
            Last_File := Last_File.Prev;
            Last_File := Last_File.Prev;
            Free (Last_File.Next);
            Free (Last_File.Next);
         end if;
         end if;
 
 
      exception
      exception
         when others =>
         when others =>
            Close (FD);
            Close (FD);
 
 
            raise;
            raise;
      end Recurse;
      end Recurse;
 
 
   --  Start of Arguments_From
   --  Start of Arguments_From
 
 
   begin
   begin
      --  The job is done by procedure Recurse
      --  The job is done by procedure Recurse
 
 
      Recurse (Response_File_Name);
      Recurse (Response_File_Name);
 
 
      --  Free Arguments before returning the result
      --  Free Arguments before returning the result
 
 
      declare
      declare
         Result : constant Argument_List := Arguments (1 .. Last_Arg);
         Result : constant Argument_List := Arguments (1 .. Last_Arg);
      begin
      begin
         Free (Arguments);
         Free (Arguments);
         return Result;
         return Result;
      end;
      end;
 
 
   exception
   exception
      when others =>
      when others =>
 
 
         --  When an exception occurs, deallocate everything
         --  When an exception occurs, deallocate everything
 
 
         Free (Arguments);
         Free (Arguments);
 
 
         while First_File /= null loop
         while First_File /= null loop
            Last_File := First_File.Next;
            Last_File := First_File.Next;
            System.Strings.Free (First_File.Name);
            System.Strings.Free (First_File.Name);
            Free (First_File);
            Free (First_File);
            First_File := Last_File;
            First_File := Last_File;
         end loop;
         end loop;
 
 
         raise;
         raise;
   end Arguments_From;
   end Arguments_From;
 
 
end Ada.Command_Line.Response_File;
end Ada.Command_Line.Response_File;
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.