CVS difference for ais/ai-00301.txt

Differences between 1.8 and version 1.9
Log of other versions for file ais/ai-00301.txt

--- ais/ai-00301.txt	2003/10/29 22:54:12	1.8
+++ ais/ai-00301.txt	2003/11/25 22:48:39	1.9
@@ -1,16 +1,17 @@
-!standard A.4.5                                     03-09-18  AI95-00301/05
+!standard A.4.5                                     03-11-25  AI95-00301/06
 !class amendment 02-06-12
 !status work item 02-06-12
 !status received 02-06-12
 !priority Medium
 !difficulty Easy
-!subject Missing operations in Ada.Strings.Unbounded
+!subject Operations on language-defined string types
 
 !summary
 
-Additional Index functions are added to Ada.Strings.Fixed,
-Ada.Strings.Bounded, and Ada.Strings.Unbouned. Some additional operations are
-added to Ada.Strings.Unbounded and Ada.Strings.Bounded. I/O operations on
+Additional Index functions are added to Ada.Strings.Fixed, Ada.Strings.Bounded,
+and Ada.Strings.Unbounded with From parameters so that partial string searches
+can be made. Additional operations are added to Ada.Strings.Unbounded and
+Ada.Strings.Bounded. A Get_Line function is added to Text_IO. I/O operations on
 unbounded strings are provided in a new child package of Ada.Text_IO.
 
 !problem
@@ -47,8 +48,8 @@
 
 And finally, I/O operations with Unbounded_Strings as parameters are not
 provided. These are commonly needed, and (in the case of Get_Line) are not
-trivial to write. An child package similar to the ones provided for Complex
-types would be valuable.
+trivial to write. A child package similar to the ones provided for Complex
+types is valuable.
 
 !proposal
 
@@ -64,7 +65,7 @@
     --    Index (Source(From..Source'Last), Pattern, Going, Mapping)
     -- Otherwise, this is equivalent to
     --    Index (Source(Source'First..From), Pattern, Going, Mapping)
-    -- Index_Error is propogated if From is not in Source'range.
+    -- Index_Error is propagated if From is not in Source'range.
 
     function Index (Source : in String;
                     Pattern : in String;
@@ -75,7 +76,7 @@
     --    Index (Source(From..Source'Last), Pattern, Going, Mapping)
     -- Otherwise, this is equivalent to
     --    Index (Source(Source'First..From), Pattern, Going, Mapping)
-    -- Index_Error is propogated if From is not in Source'range.
+    -- Index_Error is propagated if From is not in Source'range.
 
     function Index (Source : in String;
                     Set : in Maps.Character_Set;
@@ -86,7 +87,7 @@
     --    Index (Source(From..Source'Last), Set, Test, Going)
     -- Otherwise, this is equivalent to
     --    Index (Source(Source'First..From), Set, Test, Going)
-    -- Index_Error is propogated if From is not in Source'range.
+    -- Index_Error is propagated if From is not in Source'range.
 
     function Index_Non_Blank (Source : in String;
                               From : in Positive;
@@ -95,7 +96,7 @@
     --    Index_Non_Blank (Source(From..Source'Last), Going)
     -- Otherwise, this is equivalent to
     --    Index_Non_Blank (Source(Source'First..From), Going)
-    -- Index_Error is propogated if From is not in Source'range.
+    -- Index_Error is propagated if From is not in Source'range.
 
 
 Similar functions are added to Ada.Strings.Bounded and Ada.Strings.Unbounded;
@@ -105,12 +106,6 @@
 
 The following operations are added to package Ada.Strings.Bounded:
 
-   function "+" (Source : Bounded_String) return String;
-   --  Identical in effect to To_String (Source);
-
-   function "+" (Source : String) return Bounded_String;
-   --  Identical in effect to To_Bounded_String (Source, Error);
-
    procedure Set_Bounded_String
      (Target :    out Bounded_String;
       Source : in     String);
@@ -118,7 +113,7 @@
    --  Identical in effect to Target := To_Bounded_String (Source, Drop);
 
    function Bounded_Slice
-     (Source : in Unbounded_String;
+     (Source : in Bounded_String;
       Low    : in Positive;
       High   : in Natural;
       Drop   : in     Truncation := Error)
@@ -126,8 +121,8 @@
    --  Identical to To_Bounded_String (Slice (Source, Low, High), Drop);
 
    procedure Bounded_Slice
-     (Source : in     Unbounded_String;
-      Target :    out Unbounded_String;
+     (Source : in     Bounded_String;
+      Target :    out Bounded_String;
       Low    : in     Positive;
       High   : in     Natural;
       Drop   : in     Truncation := Error)
@@ -135,12 +130,6 @@
 
 The following operations are added to package Ada.Strings.Unbounded:
 
-   function "+" (Source : Unbounded_String) return String;
-   --  Identical in effect to To_String (Source);
-
-   function "+" (Source : String) return Unbounded_String;
-   --  Identical in effect to To_Unbounded_String (Source);
-
    procedure Set_Unbounded_String
      (Target :    out Unbounded_String;
       Source : in     String);
@@ -161,6 +150,12 @@
    --  Identical to Target := To_Unbounded_String (Slice (Source, Low, High));
 
 
+The following function are added to Text_IO:
+  function Get_Line (File : in File_Type) return String;
+  function Get_Line return String;
+   --  Returns the result of reading characters until the next end of line
+   --  as a string with lower bound 1.
+
 The following child package is defined:
 
 with Ada.Strings.Unbounded;
@@ -192,14 +187,7 @@
     (File : in File_Type)
     return Ada.Strings.Unbounded.Unbounded_String;
   -- Equivalent to:
-  -- declare
-  --     Buffer : String (1 .. String'Last);
-  --     Last : Natural;
-  -- begin
-  --     Get_Line (File, Buffer, Last);
-  --     return Ada.Strings.Unbounded.To_Unbounded_String(Buffer(1..Last));
-  -- end;
-  -- Note: This code will not work on most compilers.
+  --     return Ada.Strings.Unbounded.To_Unbounded_String(Text_IO.Get_Line (File));
 
   function Get_Line
     return Ada.Strings.Unbounded.Unbounded_String;
@@ -218,14 +206,351 @@
 There is a similar package for Ada.Wide_Text_IO.Wide_Unbounded_IO.
 
 !wording
+
+Add after A.4.3(8):
+
+function Index (Source : in String;
+                Pattern : in String;
+                From : in Positive;
+                Going : in Direction := Forward;
+                Mapping : in Maps.Character_Mapping := Maps.Identity)
+                     return Natural;
+
+function Index (Source : in String;
+                Pattern : in String;
+                From : in Positive;
+                Going : in Direction := Forward;
+                Mapping : in Maps.Character_Mapping_Function) return Natural;
+
+function Index (Source : in String;
+                Set : in Maps.Character_Set;
+                From : in Positive;
+                Test : in Membership := Inside;
+                Going : in Direction := Forward) return Natural;
+
+function Index_Non_Blank (Source : in String;
+                          From : in Positive;
+                          Going : in Direction := Forward) return Natural;
+
+
+Add after A.4.3(56):
+
+function Index (Source : in String;
+                Pattern : in String;
+                From : in Positive;
+                Going : in Direction := Forward;
+                Mapping : in Maps.Character_Mapping := Maps.Identity)
+                     return Natural;
+
+function Index (Source : in String;
+                Pattern : in String;
+                From : in Positive;
+                Going : in Direction := Forward;
+                Mapping : in Maps.Character_Mapping_Function) return Natural;
+
+   Each Index function searches, starting from From, for a slice of Source,
+   with length Pattern'Length, that matches Pattern with respect to Mapping;
+   the parameter Going indicates the direction of the lookup. If Going =
+   Forward, then Index returns the smallest index I which is greater than or
+   equal to From such that the slice of Source starting
+   at I matches Pattern. If Going = Backward, then Index returns the largest
+   index I such that the slice of Source starting at I matches Pattern and has
+   an upper bound less than or equal to From.
+   If there is no such slice, then 0 is returned. If Pattern is the null string
+   then Pattern_Error is propagated.
+
+   AARM Note: There is no default parameter for From; the default value
+   would need to depend on other parameters (the bounds of Source and the
+   direction Going). It is better to use overloaded functions rather than a
+   special value to represent the default.
+
+   (Also, move AARM A.4.3(58.a) here.)
+
+Replace A.4.3(58) by:
+
+   If Going = Forward, returns
+      Index (Source, Pattern, Source'First, Forward, Mapping);
+   otherwise returns
+      Index (Source, Pattern, Source'Last, Backward, Mapping);
+
+function Index (Source : in String;
+                Set : in Maps.Character_Set;
+                From : in Positive;
+                Test : in Membership := Inside;
+                Going : in Direction := Forward) return Natural;
+
+   Index searches for the first or last occurrence of any of a set of
+   characters (when Test=Inside), or any of the complement of a set of
+   characters (when Test=Outside). It returns the smallest index I >= From (if
+   Going=Forward) or the largest index I <= From (if Going=Backward) such that
+   Source(I) satisfies the Test condition with respect to Set; it returns 0 if
+   there is no such Character in Source.
+
+Replace A.4.3(60) by:
+
+   If Going = Forward, returns
+      Index (Source, Set, Source'First, Test, Forward);
+   otherwise returns
+      Index (Source, Set, Source'Last, Test, Backward);
+
+function Index_Non_Blank (Source : in String;
+                          From : in Positive;
+                          Going : in Direction := Forward) return Natural;
+
+    Returns Index (Source, Maps.To_Set(Space), From, Outside, Going);
+
+
+Add after A.4.4(12):
+
+procedure Set_Bounded_String
+   (Target :    out Bounded_String;
+    Source : in     String);
+    Drop   : in     Truncation := Error);
+
+Add after A.4.4(28):
+
+function Bounded_Slice
+   (Source : in Bounded_String;
+    Low    : in Positive;
+    High   : in Natural;
+    Drop   : in Truncation := Error)
+       return Unbounded_String;
+
+procedure Bounded_Slice
+   (Source : in     Bounded_String;
+    Target :    out Bounded_String;
+    Low    : in     Positive;
+    High   : in     Natural;
+    Drop   : in     Truncation := Error)
+
+Add after A.4.4(43):
+
+function Index (Source : in Bounded_String;
+                Pattern : in String;
+                From : in Positive;
+                Going : in Direction := Forward;
+                Mapping : in Maps.Character_Mapping := Maps.Identity)
+                     return Natural;
+
+function Index (Source : in Bounded_String;
+                Pattern : in String;
+                From : in Positive;
+                Going : in Direction := Forward;
+                Mapping : in Maps.Character_Mapping_Function) return Natural;
+
+function Index (Source : in Bounded_String;
+                Set : in Maps.Character_Set;
+                From : in Positive;
+                Test : in Membership := Inside;
+                Going : in Direction := Forward) return Natural;
+
+function Index_Non_Blank (Source : in Bounded_String;
+                          From : in Positive;
+                          Going : in Direction := Forward) return Natural;
+
+Add after A.4.4(92):
+
+procedure Set_Bounded_String
+   (Target :    out Bounded_String;
+    Source : in     String);
+    Drop   : in     Truncation := Error);
+
+    Equivalent to Target := To_Bounded_String (Source, Drop);
+
+Add after A.4.4(101/1):
+
+function Bounded_Slice
+   (Source : in Bounded_String;
+    Low    : in Positive;
+    High   : in Natural;
+    Drop   : in Truncation := Error)
+       return Bounded_String;
+
+    Returns the slice at positions Low through High in the string represented
+    by Source as a bounded string; propagates Index_Error if Low >
+    Length(Source)+1 or High > Length(Source).
+
+procedure Bounded_Slice
+   (Source : in     Bounded_String;
+    Target :    out Bounded_String;
+    Low    : in     Positive;
+    High   : in     Natural;
+    Drop   : in     Truncation := Error)
+
+    Equivalent to Target := Bounded_Slice (Soruce, Low, High, Drop);
+
+Add after A.4.5(11):
+
+procedure Set_Unbounded_String
+   (Target :    out Unbounded_String;
+    Source : in     String);
+    Drop   : in     Truncation := Error);
+
+Add after A.4.5(22):
+
+function Unbounded_Slice
+   (Source : in Unbounded_String;
+    Low    : in Positive;
+    High   : in Natural;
+    Drop   : in Truncation := Error)
+       return Unbounded_String;
+
+procedure Unbounded_Slice
+   (Source : in     Unbounded_String;
+    Target :    out Unbounded_String;
+    Low    : in     Positive;
+    High   : in     Natural;
+    Drop   : in     Truncation := Error)
+
+Add after A.4.5(38):
+
+function Index (Source : in Unbounded_String;
+                Pattern : in String;
+                From : in Positive;
+                Going : in Direction := Forward;
+                Mapping : in Maps.Character_Mapping := Maps.Identity)
+                     return Natural;
+
+function Index (Source : in Unbounded_String;
+                Pattern : in String;
+                From : in Positive;
+                Going : in Direction := Forward;
+                Mapping : in Maps.Character_Mapping_Function) return Natural;
+
+function Index (Source : in Unbounded_String;
+                Set : in Maps.Character_Set;
+                From : in Positive;
+                Test : in Membership := Inside;
+                Going : in Direction := Forward) return Natural;
+
+function Index_Non_Blank (Source : in Unbounded_String;
+                          From : in Positive;
+                          Going : in Direction := Forward) return Natural;
+
+Add after A.4.5(79):
+
+The procedure Set_Unbounded_String set Target to an Unbounded_String that
+represents Source.
+
+Add after A.4.5(82):
+
+The function Unbounded_Slice returns the slice at positions Low through High in
+the string represented by Source as a Unbounded_String. The procedure
+Unbounded_Slice sets Target to the Unbounded_String representing the slice at
+positions Low through High in the string represented by Source. Both routines
+propagate Index_Error if Low > Length(Source)+1 or High > Length(Source).
+
+Add after A.10.1(48):
+
+function Get_Line(File : in  File_Type) return String;
+function Get_Line return String;
+
+Add after A.10.7(17):
+
+function Get_Line(File : in  File_Type) return String;
+function Get_Line return String;
+
+   Returns a result string constructed by reading successive characters from
+   the specified input file, and assigning them to successive characters of the
+   result string. The result string has a lower bound 1 and an upper bound of
+   the number of characters read. Reading stops when the end of the line is
+   met; Skip_Line is then (in effect) called with a spacing of 1.
+
+   The exception End_Error is propagated if an attempt is made to skip a file
+   terminator.
+
+Add a new clause:
+
+A.10.11 Input-output for Unbounded Strings
+
+The package Text_IO.Unbounded_IO provides input-output in human-readable form
+for Unbounded_Strings.
+
+Static Semantics
+
+The library package Text_IO.Unbounded_IO has the following declaration:
+
+with Ada.Strings.Unbounded;
+package Ada.Text_IO.Unbounded_IO is
+
+  procedure Put
+    (File : in File_Type;
+     Item : in Strings.Unbounded.Unbounded_String);
+
+  procedure Put
+    (Item : in Strings.Unbounded.Unbounded_String);
+
+  procedure Put_Line
+    (File : in Text_IO.File_Type;
+     Item : in Strings.Unbounded.Unbounded_String);
+
+  procedure Put_Line
+    (Item : in Strings.Unbounded.Unbounded_String);
+
+  function Get_Line
+    (File : in File_Type)
+    return Strings.Unbounded.Unbounded_String;
+
+  function Get_Line
+    return Strings.Unbounded.Unbounded_String;
+
+  procedure Get_Line
+    (File : in File_Type; Item : out Strings.Unbounded.Unbounded_String);
+
+  procedure Get_Line
+    (Item : out Strings.Unbounded.Unbounded_String);
+
+end Ada.Text_IO.Unbounded_IO;
+
+procedure Put
+  (File : in File_Type;
+   Item : in Strings.Unbounded.Unbounded_String);
+
+   Equivalent to Text_IO.Put (File, Strings.Unbounded.To_String(Item));
+
+procedure Put
+  (Item : in Strings.Unbounded.Unbounded_String);
+
+   Equivalent to Text_IO.Put (Strings.Unbounded.To_String(Item));
+
+procedure Put_Line
+  (File : in Text_IO.File_Type;
+   Item : in Strings.Unbounded.Unbounded_String);
+
+   Equivalent to Text_IO.Put_Line (File, Strings.Unbounded.To_String(Item));
+
+procedure Put_Line
+  (Item : in Strings.Unbounded.Unbounded_String);
+
+   Equivalent to Text_IO.Put_Line (Strings.Unbounded.To_String(Item));
+
+function Get_Line
+  (File : in File_Type)
+  return Strings.Unbounded.Unbounded_String;
+
+   Returns Strings.Unbounded.To_Unbounded_String(Text_IO.Get_Line(File));
+
+function Get_Line
+  return Strings.Unbounded.Unbounded_String;
+
+   Returns Strings.Unbounded.To_Unbounded_String(Text_IO.Get_Line);
+
+procedure Get_Line
+  (File : in File_Type; Item : out Strings.Unbounded.Unbounded_String);
+
+   Equivalent to Item := Get_Line (File);
+
+procedure Get_Line
+  (Item : out Strings.Unbounded.Unbounded_String);
 
-Detailed wording changes are not yet provided.
+   Equivalent to Item := Get_Line;
 
-However, the existing Index routines ought to be described in terms of the
-new versions with the From parameter, not the other way around.
+Add after A.11(3):
 
-Get_Line ought to be described in terms of words similar to the existing
-Get_Line, not as above.
+The specification of package Wide_Text_IO.Wide_Unbounded_IO is the same as
+that for Text_IO.Unbounded_IO, exception that any occurrence of Unbounded_String
+is replaced by Wide_Unbounded_String, and any occurrence of package Unbounded
+is replaced by Wide_Unbounded.
 
 !discussion
 
@@ -241,11 +566,10 @@
 new routines have relatively lengthy names), and no programs change meaning
 (any incompatibilities cause compile-time errors).
 
-If the compatibility issues were considered to be significant enough, then
-these new routines could have been added as child packages. Such a child
-package would not cause compatibility problems; however, it would look like an
-ugly add-on. And, choosing a name is difficult. Some of the names proposed
-include Ada.Strings.Unbounded.Additional_Operations,
+We considered adding these new routines as child packages in order to
+eliminate compatibility problems. However, these packages would have looked
+like an ugly add-on. And, choosing a name is difficult. Some of the names
+proposed include Ada.Strings.Unbounded.Additional_Operations,
 Ada.Strings.Unbounded.Enhancements, Ada.Strings.Unbounded.More,
 Ada.Strings.Unbounded.Unbounded_Operations, or
 Ada.Strings.Unbounded.Stuff_that_should_have_been_here_all_along. (OK, the last
@@ -738,7 +1062,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---    $Revision: 1.8 $                              --
+--                            $Revision: 1.9 $                              --
 --                                                                          --
 --          Copyright (C) 1992-1998, Free Software Foundation, Inc.         --
 --                                                                          --

Questions? Ask the ACAA Technical Agent