diff mbox

[Ada] Add version of Find_Token with From parameter

Message ID 20101008130313.GA24819@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Oct. 8, 2010, 1:03 p.m. UTC
This patch adds a version of Find_Token with a From parameter
to all relevant string packages, as prescribed by AI 0031. The
following test program:

with Ada.Strings;
use Ada.Strings;
with Ada.Strings.Fixed;
use Ada.Strings.Fixed;
with Ada.Strings.Maps;
use Ada.Strings.Maps;
with Text_IO;
use Text_IO;
procedure Testft is
   S : constant String := "999abc999def999";
   M : constant Character_Set :=
         To_Set (Character_Range'('a', 'z'));
   First : Positive;
   Last  : Natural;

begin
   Find_Token (S, M, Inside, First, Last);
   Put_Line ("First =" & First'Img & " Last =" & Last'Img);
   Find_Token (S, M, 7, Inside, First, Last);
   Put_Line ("First =" & First'Img & " Last =" & Last'Img);
end Testft;

outputs:

First = 4 Last = 6
First = 10 Last = 12

If compiled without -gnat12, a warning is issued:

testft.adb:19:04: warning: "Find_Token" is only defined in Ada 2012

Tested on x86_64-pc-linux-gnu, committed on trunk

2010-10-08  Robert Dewar  <dewar@adacore.com>

	* a-strbou.ads, a-strfix.adb, a-strfix.ads, a-strsea.adb, a-strsea.ads,
	a-strsup.adb, a-strsup.ads, a-strunb-shared.adb, a-strunb-shared.ads,
	a-strunb.adb, a-strunb.ads, a-stwibo.ads, a-stwifi.adb, a-stwifi.ads,
	a-stwise.adb, a-stwise.ads, a-stwisu.adb, a-stwisu.ads,
	a-stwiun-shared.adb, a-stwiun-shared.ads, a-stwiun.adb, a-stwiun.ads,
	a-stzbou.ads, a-stzfix.adb, a-stzfix.ads, a-stzsea.adb, a-stzsea.ads,
	a-stzsup.adb, a-stzsup.ads, a-stzunb-shared.adb, a-stzunb-shared.ads,
	a-stzunb.adb, a-stzunb.ads (Find_Token): New version with From
	parameter.
diff mbox

Patch

Index: a-stwiun.adb
===================================================================
--- a-stwiun.adb	(revision 165080)
+++ a-stwiun.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -514,6 +514,19 @@  package body Ada.Strings.Wide_Unbounded 
    procedure Find_Token
      (Source : Unbounded_Wide_String;
       Set    : Wide_Maps.Wide_Character_Set;
+      From   : Positive;
+      Test   : Strings.Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   is
+   begin
+      Wide_Search.Find_Token
+        (Source.Reference (From .. Source.Last), Set, Test, First, Last);
+   end Find_Token;
+
+   procedure Find_Token
+     (Source : Unbounded_Wide_String;
+      Set    : Wide_Maps.Wide_Character_Set;
       Test   : Strings.Membership;
       First  : out Positive;
       Last   : out Natural)
Index: a-stwiun.ads
===================================================================
--- a-stwiun.ads	(revision 165080)
+++ a-stwiun.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -264,6 +264,15 @@  package Ada.Strings.Wide_Unbounded is
    procedure Find_Token
      (Source : Unbounded_Wide_String;
       Set    : Wide_Maps.Wide_Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+   pragma Ada_2012 (Find_Token);
+
+   procedure Find_Token
+     (Source : Unbounded_Wide_String;
+      Set    : Wide_Maps.Wide_Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);
Index: a-stwise.adb
===================================================================
--- a-stwise.adb	(revision 165080)
+++ a-stwise.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -192,6 +192,40 @@  package body Ada.Strings.Wide_Search is
    procedure Find_Token
      (Source : Wide_String;
       Set    : Wide_Maps.Wide_Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   is
+   begin
+      for J in From .. Source'Last loop
+         if Belongs (Source (J), Set, Test) then
+            First := J;
+
+            for K in J + 1 .. Source'Last loop
+               if not Belongs (Source (K), Set, Test) then
+                  Last := K - 1;
+                  return;
+               end if;
+            end loop;
+
+            --  Here if J indexes first char of token, and all chars after J
+            --  are in the token.
+
+            Last := Source'Last;
+            return;
+         end if;
+      end loop;
+
+      --  Here if no token found
+
+      First := From;
+      Last  := 0;
+   end Find_Token;
+
+   procedure Find_Token
+     (Source : Wide_String;
+      Set    : Wide_Maps.Wide_Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural)
Index: a-stwise.ads
===================================================================
--- a-stwise.ads	(revision 165080)
+++ a-stwise.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -109,6 +109,15 @@  private package Ada.Strings.Wide_Search 
    procedure Find_Token
      (Source : Wide_String;
       Set    : Wide_Maps.Wide_Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+   pragma Ada_2012 (Find_Token);
+
+   procedure Find_Token
+     (Source : Wide_String;
+      Set    : Wide_Maps.Wide_Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);
Index: a-stzunb-shared.adb
===================================================================
--- a-stzunb-shared.adb	(revision 165080)
+++ a-stzunb-shared.adb	(working copy)
@@ -827,6 +827,20 @@  package body Ada.Strings.Wide_Wide_Unbou
    procedure Find_Token
      (Source : Unbounded_Wide_Wide_String;
       Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
+      From   : Positive;
+      Test   : Strings.Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   is
+      SR : constant Shared_Wide_Wide_String_Access := Source.Reference;
+   begin
+      Wide_Wide_Search.Find_Token
+        (SR.Data (From .. SR.Last), Set, Test, First, Last);
+   end Find_Token;
+
+   procedure Find_Token
+     (Source : Unbounded_Wide_Wide_String;
+      Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
       Test   : Strings.Membership;
       First  : out Positive;
       Last   : out Natural)
Index: a-stzunb-shared.ads
===================================================================
--- a-stzunb-shared.ads	(revision 165080)
+++ a-stzunb-shared.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -279,6 +279,15 @@  package Ada.Strings.Wide_Wide_Unbounded 
    procedure Find_Token
      (Source : Unbounded_Wide_Wide_String;
       Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+   pragma Ada_2012 (Find_Token);
+
+   procedure Find_Token
+     (Source : Unbounded_Wide_Wide_String;
+      Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);
Index: a-stwifi.adb
===================================================================
--- a-stwifi.adb	(revision 165080)
+++ a-stwifi.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -117,6 +117,15 @@  package body Ada.Strings.Wide_Fixed is
    procedure Find_Token
      (Source : Wide_String;
       Set    : Wide_Maps.Wide_Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   renames Ada.Strings.Wide_Search.Find_Token;
+
+   procedure Find_Token
+     (Source : Wide_String;
+      Set    : Wide_Maps.Wide_Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural)
Index: a-stwifi.ads
===================================================================
--- a-stwifi.ads	(revision 165080)
+++ a-stwifi.ads	(working copy)
@@ -105,6 +105,15 @@  package Ada.Strings.Wide_Fixed is
    procedure Find_Token
      (Source : Wide_String;
       Set    : Wide_Maps.Wide_Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+   pragma Ada_2012 (Find_Token);
+
+   procedure Find_Token
+     (Source : Wide_String;
+      Set    : Wide_Maps.Wide_Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);
Index: a-strunb-shared.adb
===================================================================
--- a-strunb-shared.adb	(revision 165080)
+++ a-strunb-shared.adb	(working copy)
@@ -819,6 +819,19 @@  package body Ada.Strings.Unbounded is
    procedure Find_Token
      (Source : Unbounded_String;
       Set    : Maps.Character_Set;
+      From   : Positive;
+      Test   : Strings.Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   is
+      SR : constant Shared_String_Access := Source.Reference;
+   begin
+      Search.Find_Token (SR.Data (From .. SR.Last), Set, Test, First, Last);
+   end Find_Token;
+
+   procedure Find_Token
+     (Source : Unbounded_String;
+      Set    : Maps.Character_Set;
       Test   : Strings.Membership;
       First  : out Positive;
       Last   : out Natural)
Index: a-strunb-shared.ads
===================================================================
--- a-strunb-shared.ads	(revision 165080)
+++ a-strunb-shared.ads	(working copy)
@@ -297,6 +297,15 @@  package Ada.Strings.Unbounded is
    procedure Find_Token
      (Source : Unbounded_String;
       Set    : Maps.Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+   pragma Ada_2012 (Find_Token);
+
+   procedure Find_Token
+     (Source : Unbounded_String;
+      Set    : Maps.Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);
Index: a-stwibo.ads
===================================================================
--- a-stwibo.ads	(revision 165080)
+++ a-stwibo.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -296,6 +296,15 @@  package Ada.Strings.Wide_Bounded is
       procedure Find_Token
         (Source : Bounded_Wide_String;
          Set    : Wide_Maps.Wide_Character_Set;
+         From   : Positive;
+         Test   : Membership;
+         First  : out Positive;
+         Last   : out Natural);
+      pragma Ada_2012 (Find_Token);
+
+      procedure Find_Token
+        (Source : Bounded_Wide_String;
+         Set    : Wide_Maps.Wide_Character_Set;
          Test   : Membership;
          First  : out Positive;
          Last   : out Natural);
@@ -754,6 +763,15 @@  package Ada.Strings.Wide_Bounded is
       procedure Find_Token
         (Source : Bounded_Wide_String;
          Set    : Wide_Maps.Wide_Character_Set;
+         From   : Positive;
+         Test   : Membership;
+         First  : out Positive;
+         Last   : out Natural)
+         renames Super_Find_Token;
+
+      procedure Find_Token
+        (Source : Bounded_Wide_String;
+         Set    : Wide_Maps.Wide_Character_Set;
          Test   : Membership;
          First  : out Positive;
          Last   : out Natural)
Index: a-stzunb.adb
===================================================================
--- a-stzunb.adb	(revision 165080)
+++ a-stzunb.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -517,6 +517,19 @@  package body Ada.Strings.Wide_Wide_Unbou
    procedure Find_Token
      (Source : Unbounded_Wide_Wide_String;
       Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
+      From   : Positive;
+      Test   : Strings.Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   is
+   begin
+      Wide_Wide_Search.Find_Token
+        (Source.Reference (From .. Source.Last), Set, Test, First, Last);
+   end Find_Token;
+
+   procedure Find_Token
+     (Source : Unbounded_Wide_Wide_String;
+      Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
       Test   : Strings.Membership;
       First  : out Positive;
       Last   : out Natural)
Index: a-stzunb.ads
===================================================================
--- a-stzunb.ads	(revision 165080)
+++ a-stzunb.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -269,6 +269,15 @@  package Ada.Strings.Wide_Wide_Unbounded 
    procedure Find_Token
      (Source : Unbounded_Wide_Wide_String;
       Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+   pragma Ada_2012 (Find_Token);
+
+   procedure Find_Token
+     (Source : Unbounded_Wide_Wide_String;
+      Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);
Index: a-stzsea.adb
===================================================================
--- a-stzsea.adb	(revision 165080)
+++ a-stzsea.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -194,6 +194,40 @@  package body Ada.Strings.Wide_Wide_Searc
    procedure Find_Token
      (Source : Wide_Wide_String;
       Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   is
+   begin
+      for J in From .. Source'Last loop
+         if Belongs (Source (J), Set, Test) then
+            First := J;
+
+            for K in J + 1 .. Source'Last loop
+               if not Belongs (Source (K), Set, Test) then
+                  Last := K - 1;
+                  return;
+               end if;
+            end loop;
+
+            --  Here if J indexes first char of token, and all chars after J
+            --  are in the token.
+
+            Last := Source'Last;
+            return;
+         end if;
+      end loop;
+
+      --  Here if no token found
+
+      First := From;
+      Last  := 0;
+   end Find_Token;
+
+   procedure Find_Token
+     (Source : Wide_Wide_String;
+      Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural)
Index: a-stzsea.ads
===================================================================
--- a-stzsea.ads	(revision 165080)
+++ a-stzsea.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -115,6 +115,14 @@  private package Ada.Strings.Wide_Wide_Se
    procedure Find_Token
      (Source : Wide_Wide_String;
       Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+
+   procedure Find_Token
+     (Source : Wide_Wide_String;
+      Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);
Index: a-stzfix.adb
===================================================================
--- a-stzfix.adb	(revision 165080)
+++ a-stzfix.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -123,6 +123,15 @@  package body Ada.Strings.Wide_Wide_Fixed
    procedure Find_Token
      (Source : Wide_Wide_String;
       Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   renames Ada.Strings.Wide_Wide_Search.Find_Token;
+
+   procedure Find_Token
+     (Source : Wide_Wide_String;
+      Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural)
Index: a-stzfix.ads
===================================================================
--- a-stzfix.ads	(revision 165080)
+++ a-stzfix.ads	(working copy)
@@ -110,6 +110,15 @@  package Ada.Strings.Wide_Wide_Fixed is
    procedure Find_Token
      (Source : Wide_Wide_String;
       Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+   pragma Ada_2012 (Find_Token);
+
+   procedure Find_Token
+     (Source : Wide_Wide_String;
+      Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);
Index: a-strbou.ads
===================================================================
--- a-strbou.ads	(revision 165080)
+++ a-strbou.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -292,6 +292,15 @@  package Ada.Strings.Bounded is
       procedure Find_Token
         (Source : Bounded_String;
          Set    : Maps.Character_Set;
+         From   : Positive;
+         Test   : Membership;
+         First  : out Positive;
+         Last   : out Natural);
+      pragma Ada_2012 (Find_Token);
+
+      procedure Find_Token
+        (Source : Bounded_String;
+         Set    : Maps.Character_Set;
          Test   : Membership;
          First  : out Positive;
          Last   : out Natural);
@@ -749,6 +758,15 @@  package Ada.Strings.Bounded is
       procedure Find_Token
         (Source : Bounded_String;
          Set    : Maps.Character_Set;
+         From   : Positive;
+         Test   : Membership;
+         First  : out Positive;
+         Last   : out Natural)
+         renames Super_Find_Token;
+
+      procedure Find_Token
+        (Source : Bounded_String;
+         Set    : Maps.Character_Set;
          Test   : Membership;
          First  : out Positive;
          Last   : out Natural)
Index: a-strsup.adb
===================================================================
--- a-strsup.adb	(revision 165080)
+++ a-strsup.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2003-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 2003-2010, 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- --
@@ -795,6 +795,19 @@  package body Ada.Strings.Superbounded is
    procedure Super_Find_Token
      (Source : Super_String;
       Set    : Maps.Character_Set;
+      From   : Positive;
+      Test   : Strings.Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   is
+   begin
+      Search.Find_Token
+        (Source.Data (From .. Source.Current_Length), Set, Test, First, Last);
+   end Super_Find_Token;
+
+   procedure Super_Find_Token
+     (Source : Super_String;
+      Set    : Maps.Character_Set;
       Test   : Strings.Membership;
       First  : out Positive;
       Last   : out Natural)
Index: a-strsup.ads
===================================================================
--- a-strsup.ads	(revision 165080)
+++ a-strsup.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 2003-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 2003-2010, 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- --
@@ -293,6 +293,14 @@  package Ada.Strings.Superbounded is
    procedure Super_Find_Token
      (Source : Super_String;
       Set    : Maps.Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+
+   procedure Super_Find_Token
+     (Source : Super_String;
+      Set    : Maps.Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);
Index: a-stwiun-shared.adb
===================================================================
--- a-stwiun-shared.adb	(revision 165080)
+++ a-stwiun-shared.adb	(working copy)
@@ -823,13 +823,28 @@  package body Ada.Strings.Wide_Unbounded 
    procedure Find_Token
      (Source : Unbounded_Wide_String;
       Set    : Wide_Maps.Wide_Character_Set;
+      From   : Positive;
+      Test   : Strings.Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   is
+      SR : constant Shared_Wide_String_Access := Source.Reference;
+   begin
+      Wide_Search.Find_Token
+        (SR.Data (From .. SR.Last), Set, Test, First, Last);
+   end Find_Token;
+
+   procedure Find_Token
+     (Source : Unbounded_Wide_String;
+      Set    : Wide_Maps.Wide_Character_Set;
       Test   : Strings.Membership;
       First  : out Positive;
       Last   : out Natural)
    is
       SR : constant Shared_Wide_String_Access := Source.Reference;
    begin
-      Wide_Search.Find_Token (SR.Data (1 .. SR.Last), Set, Test, First, Last);
+      Wide_Search.Find_Token
+        (SR.Data (1 .. SR.Last), Set, Test, First, Last);
    end Find_Token;
 
    ----------
Index: a-stwiun-shared.ads
===================================================================
--- a-stwiun-shared.ads	(revision 165080)
+++ a-stwiun-shared.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -273,6 +273,15 @@  package Ada.Strings.Wide_Unbounded is
    procedure Find_Token
      (Source : Unbounded_Wide_String;
       Set    : Wide_Maps.Wide_Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+   pragma Ada_2012 (Find_Token);
+
+   procedure Find_Token
+     (Source : Unbounded_Wide_String;
+      Set    : Wide_Maps.Wide_Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);
Index: a-stwisu.adb
===================================================================
--- a-stwisu.adb	(revision 165080)
+++ a-stwisu.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2003-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 2003-2010, 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- --
@@ -796,6 +796,19 @@  package body Ada.Strings.Wide_Superbound
    procedure Super_Find_Token
      (Source : Super_String;
       Set    : Wide_Maps.Wide_Character_Set;
+      From   : Positive;
+      Test   : Strings.Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   is
+   begin
+      Wide_Search.Find_Token
+        (Source.Data (From .. Source.Current_Length), Set, Test, First, Last);
+   end Super_Find_Token;
+
+   procedure Super_Find_Token
+     (Source : Super_String;
+      Set    : Wide_Maps.Wide_Character_Set;
       Test   : Strings.Membership;
       First  : out Positive;
       Last   : out Natural)
Index: a-stwisu.ads
===================================================================
--- a-stwisu.ads	(revision 165080)
+++ a-stwisu.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 2003-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 2003-2010, 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- --
@@ -299,6 +299,14 @@  package Ada.Strings.Wide_Superbounded is
    procedure Super_Find_Token
      (Source : Super_String;
       Set    : Wide_Maps.Wide_Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+
+   procedure Super_Find_Token
+     (Source : Super_String;
+      Set    : Wide_Maps.Wide_Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);
Index: a-stzbou.ads
===================================================================
--- a-stzbou.ads	(revision 165080)
+++ a-stzbou.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -302,6 +302,15 @@  package Ada.Strings.Wide_Wide_Bounded is
       procedure Find_Token
         (Source : Bounded_Wide_Wide_String;
          Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
+         From   : Positive;
+         Test   : Membership;
+         First  : out Positive;
+         Last   : out Natural);
+      pragma Ada_2012 (Find_Token);
+
+      procedure Find_Token
+        (Source : Bounded_Wide_Wide_String;
+         Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
          Test   : Membership;
          First  : out Positive;
          Last   : out Natural);
@@ -769,6 +778,15 @@  package Ada.Strings.Wide_Wide_Bounded is
       procedure Find_Token
         (Source : Bounded_Wide_Wide_String;
          Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
+         From   : Positive;
+         Test   : Membership;
+         First  : out Positive;
+         Last   : out Natural)
+         renames Super_Find_Token;
+
+      procedure Find_Token
+        (Source : Bounded_Wide_Wide_String;
+         Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
          Test   : Membership;
          First  : out Positive;
          Last   : out Natural)
Index: a-strunb.adb
===================================================================
--- a-strunb.adb	(revision 165080)
+++ a-strunb.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -507,6 +507,19 @@  package body Ada.Strings.Unbounded is
    procedure Find_Token
      (Source : Unbounded_String;
       Set    : Maps.Character_Set;
+      From   : Positive;
+      Test   : Strings.Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   is
+   begin
+      Search.Find_Token
+        (Source.Reference (From .. Source.Last), Set, Test, First, Last);
+   end Find_Token;
+
+   procedure Find_Token
+     (Source : Unbounded_String;
+      Set    : Maps.Character_Set;
       Test   : Strings.Membership;
       First  : out Positive;
       Last   : out Natural)
Index: a-strunb.ads
===================================================================
--- a-strunb.ads	(revision 165080)
+++ a-strunb.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -259,6 +259,15 @@  package Ada.Strings.Unbounded is
    procedure Find_Token
      (Source : Unbounded_String;
       Set    : Maps.Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+   pragma Ada_2012 (Find_Token);
+
+   procedure Find_Token
+     (Source : Unbounded_String;
+      Set    : Maps.Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);
Index: a-strsea.adb
===================================================================
--- a-strsea.adb	(revision 165080)
+++ a-strsea.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -197,6 +197,40 @@  package body Ada.Strings.Search is
    procedure Find_Token
      (Source : String;
       Set    : Maps.Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   is
+   begin
+      for J in From .. Source'Last loop
+         if Belongs (Source (J), Set, Test) then
+            First := J;
+
+            for K in J + 1 .. Source'Last loop
+               if not Belongs (Source (K), Set, Test) then
+                  Last := K - 1;
+                  return;
+               end if;
+            end loop;
+
+            --  Here if J indexes first char of token, and all chars after J
+            --  are in the token.
+
+            Last := Source'Last;
+            return;
+         end if;
+      end loop;
+
+      --  Here if no token found
+
+      First := From;
+      Last  := 0;
+   end Find_Token;
+
+   procedure Find_Token
+     (Source : String;
+      Set    : Maps.Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural)
Index: a-strsea.ads
===================================================================
--- a-strsea.ads	(revision 165080)
+++ a-strsea.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -106,6 +106,14 @@  private package Ada.Strings.Search is
    procedure Find_Token
      (Source : String;
       Set    : Maps.Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+
+   procedure Find_Token
+     (Source : String;
+      Set    : Maps.Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);
Index: a-strfix.adb
===================================================================
--- a-strfix.adb	(revision 165080)
+++ a-strfix.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -123,6 +123,15 @@  package body Ada.Strings.Fixed is
    procedure Find_Token
      (Source : String;
       Set    : Maps.Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   renames Ada.Strings.Search.Find_Token;
+
+   procedure Find_Token
+     (Source : String;
+      Set    : Maps.Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural)
Index: a-strfix.ads
===================================================================
--- a-strfix.ads	(revision 165080)
+++ a-strfix.ads	(working copy)
@@ -102,6 +102,15 @@  package Ada.Strings.Fixed is
    procedure Find_Token
      (Source : String;
       Set    : Maps.Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+   pragma Ada_2012 (Find_Token);
+
+   procedure Find_Token
+     (Source : String;
+      Set    : Maps.Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);
Index: a-stzsup.adb
===================================================================
--- a-stzsup.adb	(revision 165080)
+++ a-stzsup.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2003-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 2003-2010, 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- --
@@ -799,6 +799,19 @@  package body Ada.Strings.Wide_Wide_Super
    procedure Super_Find_Token
      (Source : Super_String;
       Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
+      From   : Positive;
+      Test   : Strings.Membership;
+      First  : out Positive;
+      Last   : out Natural)
+   is
+   begin
+      Wide_Wide_Search.Find_Token
+        (Source.Data (From .. Source.Current_Length), Set, Test, First, Last);
+   end Super_Find_Token;
+
+   procedure Super_Find_Token
+     (Source : Super_String;
+      Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
       Test   : Strings.Membership;
       First  : out Positive;
       Last   : out Natural)
Index: a-stzsup.ads
===================================================================
--- a-stzsup.ads	(revision 165080)
+++ a-stzsup.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 2003-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 2003-2010, 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- --
@@ -307,6 +307,14 @@  package Ada.Strings.Wide_Wide_Superbound
    procedure Super_Find_Token
      (Source : Super_String;
       Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
+      From   : Positive;
+      Test   : Membership;
+      First  : out Positive;
+      Last   : out Natural);
+
+   procedure Super_Find_Token
+     (Source : Super_String;
+      Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
       Test   : Membership;
       First  : out Positive;
       Last   : out Natural);