OSDN Git Service

PR bootstrap/11932
[pf3gnuchains/gcc-fork.git] / gcc / ada / g-regexp.adb
index 66d5667..ab63d73 100644 (file)
@@ -6,9 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                            $Revision$
---                                                                          --
---            Copyright (C) 1999-2001 Ada Core Technologies, Inc.           --
+--            Copyright (C) 1999-2002 Ada Core Technologies, 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- --
@@ -28,7 +26,8 @@
 -- however invalidate  any other reasons why  the executable file  might be --
 -- covered by the  GNU Public License.                                      --
 --                                                                          --
--- 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.      --
 --                                                                          --
 ------------------------------------------------------------------------------
 
@@ -535,7 +534,7 @@ package body GNAT.Regexp is
                case S (J) is
                   when Open_Paren =>
                      declare
-                        J_Start    : Integer := J + 1;
+                        J_Start    : constant Integer := J + 1;
                         Next_Start : State_Index;
                         Next_End   : State_Index;
 
@@ -569,11 +568,11 @@ package body GNAT.Regexp is
 
                   when '|' =>
                      declare
-                        Start_Prev : State_Index := Start_State;
-                        End_Prev   : State_Index := End_State;
+                        Start_Prev : constant State_Index := Start_State;
+                        End_Prev   : constant State_Index := End_State;
+                        Start_J    : constant Integer     := J + 1;
                         Start_Next : State_Index := 0;
                         End_Next   : State_Index := 0;
-                        Start_J    : Integer := J + 1;
 
                      begin
                         J := Next_Sub_Expression (J, End_Index);
@@ -1236,6 +1235,19 @@ package body GNAT.Regexp is
    --  Start of processing for Compile
 
    begin
+      --  Special case for the empty string: it always matches, and the
+      --  following processing would fail on it.
+      if S = "" then
+         return (Ada.Finalization.Controlled with
+                 R => new Regexp_Value'
+                      (Alphabet_Size => 0,
+                       Num_States    => 1,
+                       Map           => (others => 0),
+                       States        => (others => (others => 1)),
+                       Is_Final      => (others => True),
+                       Case_Sensitive => True));
+      end if;
+
       if not Case_Sensitive then
          GNAT.Case_Util.To_Lower (S);
       end if;