OSDN Git Service

2007-04-20 Ed Schonberg <schonberg@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / lib-sort.adb
index d8b6d71..c20885e 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---   Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc.  --
+--          Copyright (C) 1992-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- --
@@ -16,8 +16,8 @@
 -- 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.                                              --
 --                                                                          --
 -- As a special exception,  if other files  instantiate  generics from this --
 -- unit, or you link  this unit with other files  to produce an executable, --
@@ -43,10 +43,10 @@ procedure Sort (Tbl : in out Unit_Ref_Table) is
    --  even though we have to copy Tbl back and forth.
 
    function Lt_Uname (C1, C2 : Natural) return Boolean;
-   --  Comparison routine for comparing Unames. Needed by the sorting routine.
+   --  Comparison routine for comparing Unames. Needed by the sorting routine
 
    procedure Move_Uname (From : Natural; To : Natural);
-   --  Move routine needed by the sorting routine below.
+   --  Move routine needed by the sorting routine below
 
    --------------
    -- Lt_Uname --
@@ -54,9 +54,21 @@ procedure Sort (Tbl : in out Unit_Ref_Table) is
 
    function Lt_Uname (C1, C2 : Natural) return Boolean is
    begin
-      return
-        Uname_Lt
-          (Units.Table (T (C1)).Unit_Name, Units.Table (T (C2)).Unit_Name);
+      --  Preprocessing data and definition files are not sorted, they are
+      --  at the bottom of the list. They are recognized because they are
+      --  the only ones without a Unit_Name.
+
+      if Units.Table (T (C1)).Unit_Name = No_Unit_Name then
+         return False;
+
+      elsif Units.Table (T (C2)).Unit_Name = No_Unit_Name then
+         return True;
+
+      else
+         return
+           Uname_Lt
+             (Units.Table (T (C1)).Unit_Name, Units.Table (T (C2)).Unit_Name);
+      end if;
    end Lt_Uname;
 
    ----------------