Commit 09d7d413 by Pascal Obry Committed by Arnaud Charlet

g-awk.adb: ensure that an AWK session is reusable.

2010-01-27  Pascal Obry  <obry@adacore.com>

	* g-awk.adb: ensure that an AWK session is reusable.

From-SVN: r156285
parent 0309455b
2010-01-27 Pascal Obry <obry@adacore.com>
* g-awk.adb: ensure that an AWK session is reusable.
2010-01-27 Vasiliy Fofanov <fofanov@adacore.com> 2010-01-27 Vasiliy Fofanov <fofanov@adacore.com>
* g-regist.adb (For_Every_Key): Fix previous change. * g-regist.adb (For_Every_Key): Fix previous change.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2000-2008, AdaCore -- -- Copyright (C) 2000-2010, AdaCore --
-- -- -- --
-- 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- --
...@@ -294,6 +294,10 @@ package body GNAT.AWK is ...@@ -294,6 +294,10 @@ package body GNAT.AWK is
-- We release the session data only if it is not the default session -- We release the session data only if it is not the default session
if Session.Data /= Get_Def then if Session.Data /= Get_Def then
-- Release separators
Free (Session.Data.Separators);
Free (Session.Data); Free (Session.Data);
-- Since we have closed the current session, set it to point now to -- Since we have closed the current session, set it to point now to
...@@ -485,11 +489,10 @@ package body GNAT.AWK is ...@@ -485,11 +489,10 @@ package body GNAT.AWK is
procedure Current_Line (S : Separator; Session : Session_Type) is procedure Current_Line (S : Separator; Session : Session_Type) is
Line : constant String := To_String (Session.Data.Current_Line); Line : constant String := To_String (Session.Data.Current_Line);
Fields : Field_Table.Instance renames Session.Data.Fields; Fields : Field_Table.Instance renames Session.Data.Fields;
Seps : constant Maps.Character_Set := Maps.To_Set (S.Separators);
Start : Natural; Start : Natural;
Stop : Natural; Stop : Natural;
Seps : constant Maps.Character_Set := Maps.To_Set (S.Separators);
begin begin
-- First field start here -- First field start here
...@@ -506,8 +509,8 @@ package body GNAT.AWK is ...@@ -506,8 +509,8 @@ package body GNAT.AWK is
-- Look for next separator -- Look for next separator
Stop := Fixed.Index Stop := Fixed.Index
(Source => Line (Start .. Line'Last), (Source => Line (Start .. Line'Last),
Set => Seps); Set => Seps);
exit when Stop = 0; exit when Stop = 0;
...@@ -526,6 +529,7 @@ package body GNAT.AWK is ...@@ -526,6 +529,7 @@ package body GNAT.AWK is
if Start = 0 then if Start = 0 then
Start := Stop + 1; Start := Stop + 1;
end if; end if;
else else
Start := Stop + 1; Start := Stop + 1;
end if; end if;
...@@ -707,10 +711,6 @@ package body GNAT.AWK is ...@@ -707,10 +711,6 @@ package body GNAT.AWK is
Text_IO.Close (Session.Data.Current_File); Text_IO.Close (Session.Data.Current_File);
end if; end if;
-- Release separators
Free (Session.Data.Separators);
-- Release Filters table -- Release Filters table
for F in 1 .. Pattern_Action_Table.Last (Filters) loop for F in 1 .. Pattern_Action_Table.Last (Filters) loop
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment