[multiple changes]
[platform/upstream/gcc.git] / gcc / ada / g-awk.adb
index 654e11c..cece7e6 100644 (file)
@@ -6,9 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                            $Revision: 1.1 $
---                                                                          --
---            Copyright (C) 2000-2001 Ada Core Technologies, Inc.           --
+--            Copyright (C) 2000-2003 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.      --
 --                                                                          --
 ------------------------------------------------------------------------------
 
@@ -383,6 +382,8 @@ package body GNAT.AWK is
         (A       : Simple_Action;
          Session : Session_Type)
       is
+         pragma Unreferenced (Session);
+
       begin
          A.Proc.all;
       end Call;
@@ -446,6 +447,8 @@ package body GNAT.AWK is
          Session : Session_Type)
          return    Boolean
       is
+         pragma Unreferenced (Session);
+
       begin
          return P.Pattern.all;
       end Match;
@@ -455,6 +458,8 @@ package body GNAT.AWK is
       -------------
 
       procedure Release (P : in out Pattern) is
+         pragma Unreferenced (P);
+
       begin
          null;
       end Release;
@@ -489,10 +494,10 @@ package body GNAT.AWK is
          Line   : constant String := To_String (Session.Data.Current_Line);
          Fields : Field_Table.Instance renames Session.Data.Fields;
 
-         Start : Positive;
+         Start : Natural;
          Stop  : Natural;
 
-         Seps  : Maps.Character_Set := Maps.To_Set (S.Separators);
+         Seps  : constant Maps.Character_Set := Maps.To_Set (S.Separators);
 
       begin
          --  First field start here
@@ -516,7 +521,7 @@ package body GNAT.AWK is
 
             Fields.Table (Field_Table.Last (Fields)).Last := Stop - 1;
 
-            --  if separators are set to the default (space and tab) we skip
+            --  If separators are set to the default (space and tab) we skip
             --  all spaces and tabs following current field.
 
             if S.Separators = Default_Separators then
@@ -525,6 +530,10 @@ package body GNAT.AWK is
                   Maps.To_Set (Default_Separators),
                   Outside,
                   Strings.Forward);
+
+               if Start = 0 then
+                  Start := Stop + 1;
+               end if;
             else
                Start := Stop + 1;
             end if;
@@ -864,8 +873,7 @@ package body GNAT.AWK is
       Callbacks  : Callback_Mode := None;
       Session    : Session_Type  := Current_Session)
    is
-      Filter_Active : Boolean;
-      Quit          : Boolean;
+      Quit : Boolean;
 
    begin
       Open (Separators, Filename, Session);
@@ -875,7 +883,12 @@ package body GNAT.AWK is
          Split_Line (Session);
 
          if Callbacks in Only .. Pass_Through then
-            Filter_Active := Apply_Filters (Session);
+            declare
+               Discard : Boolean;
+               pragma Unreferenced (Discard);
+            begin
+               Discard := Apply_Filters (Session);
+            end;
          end if;
 
          if Callbacks /= Only then
@@ -907,14 +920,20 @@ package body GNAT.AWK is
          Read_Line (Session);
          Split_Line (Session);
 
-         if Callbacks in Only .. Pass_Through then
-            Filter_Active := Apply_Filters (Session);
-         end if;
+         case Callbacks is
+
+            when None =>
+               exit;
 
-         exit when Callbacks = None
-           or else Callbacks = Pass_Through
-           or else (Callbacks = Only and then not Filter_Active);
+            when Only =>
+               Filter_Active := Apply_Filters (Session);
+               exit when not Filter_Active;
 
+            when Pass_Through =>
+               Filter_Active := Apply_Filters (Session);
+               exit;
+
+         end case;
       end loop;
    end Get_Line;
 
@@ -1036,6 +1055,8 @@ package body GNAT.AWK is
       Session    : Session_Type := Current_Session)
    is
       Filter_Active : Boolean;
+      pragma Unreferenced (Filter_Active);
+
    begin
       Open (Separators, Filename, Session);
 
@@ -1168,7 +1189,7 @@ package body GNAT.AWK is
    is
       Filters : Pattern_Action_Table.Instance renames Session.Data.Filters;
 
-      A_Pattern : Patterns.Pattern_Matcher_Access :=
+      A_Pattern : constant Patterns.Pattern_Matcher_Access :=
                     new Regpat.Pattern_Matcher'(Pattern);
    begin
       Pattern_Action_Table.Increment_Last (Filters);
@@ -1186,7 +1207,7 @@ package body GNAT.AWK is
    is
       Filters : Pattern_Action_Table.Instance renames Session.Data.Filters;
 
-      A_Pattern : Patterns.Pattern_Matcher_Access :=
+      A_Pattern : constant Patterns.Pattern_Matcher_Access :=
                     new Regpat.Pattern_Matcher'(Pattern);
    begin
       Pattern_Action_Table.Increment_Last (Filters);