OSDN Git Service

2008-05-27 Vincent Celier <celier@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-teioed.adb
index bd86830..a5c2b66 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2005 Free Software Foundation, Inc.          --
+--          Copyright (C) 1992-2007, 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- --
@@ -42,7 +42,7 @@ package body Ada.Text_IO.Editing is
    -- Blank_When_Zero --
    ---------------------
 
-   function Blank_When_Zero (Pic : in Picture) return Boolean is
+   function Blank_When_Zero (Pic : Picture) return Boolean is
    begin
       return Pic.Contents.Original_BWZ;
    end Blank_When_Zero;
@@ -51,7 +51,7 @@ package body Ada.Text_IO.Editing is
    -- Expand --
    ------------
 
-   function Expand (Picture : in String) return String is
+   function Expand (Picture : String) return String is
       Result        : String (1 .. MAX_PICSIZE);
       Picture_Index : Integer := Picture'First;
       Result_Index  : Integer := Result'First;
@@ -90,7 +90,7 @@ package body Ada.Text_IO.Editing is
 
                Result_Index := Result_Index + Count - 1;
 
-               --  Last + 1 was a ')' throw it away too.
+               --  Last + 1 was a ')' throw it away too
 
                Picture_Index := Last + 2;
 
@@ -124,8 +124,7 @@ package body Ada.Text_IO.Editing is
       Currency_Symbol     : String;
       Fill_Character      : Character;
       Separator_Character : Character;
-      Radix_Point         : Character)
-      return                String
+      Radix_Point         : Character) return String
    is
       Attrs    : Number_Attributes := Parse_Number_String (Number);
       Position : Integer;
@@ -139,10 +138,10 @@ package body Ada.Text_IO.Editing is
       In_Currency   : Boolean := False;
 
       Dollar : Boolean := False;
-      --  Overridden immediately if necessary.
+      --  Overridden immediately if necessary
 
       Zero : Boolean := True;
-      --  Set to False when a non-zero digit is output.
+      --  Set to False when a non-zero digit is output
 
    begin
 
@@ -236,7 +235,7 @@ package body Ada.Text_IO.Editing is
       for J in reverse Last .. Answer'Last loop
          exit when J = Pic.Radix_Position;
 
-         --  Do this test First, Separator_Character can equal Pic.Floater.
+         --  Do this test First, Separator_Character can equal Pic.Floater
 
          if Answer (J) = Pic.Floater then
             exit;
@@ -418,7 +417,7 @@ package body Ada.Text_IO.Editing is
                Answer (J) := Separator_Character;
 
             elsif Answer (J) = 'b' then
-               Answer (J) := '*';
+               Answer (J) := Fill_Character;
             end if;
          end loop;
 
@@ -427,7 +426,7 @@ package body Ada.Text_IO.Editing is
          end if;
 
          for J in Pic.Start_Float .. Position loop
-            Answer (J) := '*';
+            Answer (J) := Fill_Character;
          end loop;
 
       else
@@ -692,11 +691,11 @@ package body Ada.Text_IO.Editing is
          end case;
       end loop;
 
-      --  Now get rid of Blank_when_Zero and complete Star fill.
+      --  Now get rid of Blank_when_Zero and complete Star fill
 
       if Zero and Pic.Blank_When_Zero then
 
-         --  Value is zero, and blank it.
+         --  Value is zero, and blank it
 
          Last := Answer'Last;
 
@@ -897,7 +896,7 @@ package body Ada.Text_IO.Editing is
                   raise Picture_Error;
                end if;
 
-               --  Two decimal points is a no-no.
+               --  Two decimal points is a no-no
 
                Answer.Has_Fraction    := True;
                Answer.End_Of_Fraction := J;
@@ -917,7 +916,7 @@ package body Ada.Text_IO.Editing is
          Answer.Start_Of_Int := Answer.End_Of_Int + 1;
       end if;
 
-      --  No significant (intger) digits needs a null range.
+      --  No significant (integer) digits needs a null range
 
       return Answer;
    end Parse_Number_String;
@@ -929,12 +928,14 @@ package body Ada.Text_IO.Editing is
    --  The following ensures that we return B and not b being careful not
    --  to break things which expect lower case b for blank. See CXF3A02.
 
-   function Pic_String (Pic : in Picture) return String is
+   function Pic_String (Pic : Picture) return String is
       Temp : String (1 .. Pic.Contents.Picture.Length) :=
                               Pic.Contents.Picture.Expanded;
    begin
       for J in Temp'Range loop
-         if Temp (J) = 'b' then Temp (J) := 'B'; end if;
+         if Temp (J) = 'b' then
+            Temp (J) := 'B';
+         end if;
       end loop;
 
       return Temp;
@@ -953,7 +954,7 @@ package body Ada.Text_IO.Editing is
       type Legality is  (Okay, Reject);
 
       State : Legality := Reject;
-      --  Start in reject, which will reject null strings.
+      --  Start in reject, which will reject null strings
 
       Index : Pic_Index := Pic.Picture.Expanded'First;
 
@@ -975,7 +976,7 @@ package body Ada.Text_IO.Editing is
       procedure Debug_Start (Name : String);
       pragma Inline (Debug_Start);
 
-      procedure Debug_Integer  (Value : in Integer; S : String);
+      procedure Debug_Integer  (Value : Integer; S : String);
       pragma Inline (Debug_Integer);
 
       procedure Trailing_Currency;
@@ -1032,7 +1033,7 @@ package body Ada.Text_IO.Editing is
       -- Debug_Integer --
       -------------------
 
-      procedure Debug_Integer  (Value : in Integer; S : String) is
+      procedure Debug_Integer (Value : Integer; S : String) is
          use Ada.Text_IO; --  needed for >
 
       begin
@@ -1067,7 +1068,7 @@ package body Ada.Text_IO.Editing is
       begin
          Debug_Start ("Floating_Bracket");
 
-         --  Two different floats not allowed.
+         --  Two different floats not allowed
 
          if Pic.Floater /= '!' and then Pic.Floater /= '<' then
             raise Picture_Error;
@@ -1393,6 +1394,7 @@ package body Ada.Text_IO.Editing is
                      raise Picture_Error;
                   else
                      --  Overwrite Floater and Start_Float
+
                      Pic.Floater := '*';
                      Pic.Start_Float := Index;
                      Star_Suppression;
@@ -1411,7 +1413,7 @@ package body Ada.Text_IO.Editing is
                      Pic.End_Float := Invalid_Position;
                   end if;
 
-                  --  A single dollar does not a floating make.
+                  --  A single dollar does not a floating make
 
                   Number_Completion;
                   return;
@@ -1423,8 +1425,8 @@ package body Ada.Text_IO.Editing is
                      Pic.End_Float := Invalid_Position;
                   end if;
 
-                  --  Only one dollar before the sign is okay,
-                  --  but doesn't float.
+                  --  Only one dollar before the sign is okay, but doesn't
+                  --  float.
 
                   Pic.Radix_Position := Index;
                   Skip;
@@ -1459,7 +1461,7 @@ package body Ada.Text_IO.Editing is
          --  Set to True if a '_', '0', '/', 'B', or 'b' is encountered
 
          Must_Float : Boolean := False;
-         --  Set to true if a '#' occurs after an insert.
+         --  Set to true if a '#' occurs after an insert
 
       begin
          Debug_Start ("Leading_Pound");
@@ -1548,7 +1550,7 @@ package body Ada.Text_IO.Editing is
                when '9' =>
                   if State /= Okay then
 
-                     --  A single '#' doesn't float.
+                     --  A single '#' doesn't float
 
                      Pic.Floater := '!';
                      Pic.Start_Float := Invalid_Position;
@@ -1565,8 +1567,8 @@ package body Ada.Text_IO.Editing is
                      Pic.End_Float := Invalid_Position;
                   end if;
 
-                  --  Only one pound before the sign is okay,
-                  --  but doesn't float.
+                  --  Only one pound before the sign is okay, but doesn't
+                  --  float.
 
                   Pic.Radix_Position := Index;
                   Skip;
@@ -1631,7 +1633,7 @@ package body Ada.Text_IO.Editing is
                return;
             end if;
 
-            --  Will return in Okay state if a '9' was seen.
+            --  Will return in Okay state if a '9' was seen
 
          end loop;
       end Number;
@@ -2075,7 +2077,7 @@ package body Ada.Text_IO.Editing is
       -- Picture --
       -------------
 
-      --  Note that Picture can be called in either State.
+      --  Note that Picture can be called in either State
 
       --  It will set state to Valid only if a 9 is encountered or floating
       --  currency is called.
@@ -2136,7 +2138,7 @@ package body Ada.Text_IO.Editing is
          Debug_Start ("Picture_Bracket");
          Pic.Sign_Position := Index;
 
-         --  Treat as a floating sign, and unwind otherwise.
+         --  Treat as a floating sign, and unwind otherwise
 
          Pic.Floater := '<';
          Pic.Start_Float := Index;
@@ -2208,7 +2210,7 @@ package body Ada.Text_IO.Editing is
 
          Pic.Sign_Position := Index;
 
-         --  Treat as a floating sign, and unwind otherwise.
+         --  Treat as a floating sign, and unwind otherwise
 
          Pic.Floater := '-';
          Pic.Start_Float := Index;
@@ -2253,7 +2255,7 @@ package body Ada.Text_IO.Editing is
 
                when 'Z' | 'z' =>
 
-                  --  Can't have Z and a floating sign.
+                  --  Can't have Z and a floating sign
 
                   if State = Okay then
                      Set_State (Reject);
@@ -2272,7 +2274,7 @@ package body Ada.Text_IO.Editing is
                      Pic.End_Float := Invalid_Position;
                   end if;
 
-                  --  Don't assume that state is okay, haven't seen a digit.
+                  --  Don't assume that state is okay, haven't seen a digit
 
                   Picture;
                   return;
@@ -2293,7 +2295,7 @@ package body Ada.Text_IO.Editing is
          Debug_Start ("Picture_Plus");
          Pic.Sign_Position := Index;
 
-         --  Treat as a floating sign, and unwind otherwise.
+         --  Treat as a floating sign, and unwind otherwise
 
          Pic.Floater := '+';
          Pic.Start_Float := Index;
@@ -2320,7 +2322,7 @@ package body Ada.Text_IO.Editing is
                   Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1;
                   Pic.End_Float := Index;
                   Skip;
-                  Set_State (Okay);  --  "++" is enough.
+                  Set_State (Okay);  --  "++" is enough
                   Floating_Plus;
                   Trailing_Currency;
                   return;
@@ -2341,7 +2343,7 @@ package body Ada.Text_IO.Editing is
                      Set_State (Reject);
                   end if;
 
-                  --  Can't have Z and a floating sign.
+                  --  Can't have Z and a floating sign
 
                   Pic.Picture.Expanded (Index) := 'Z'; -- consistency
 
@@ -2366,7 +2368,7 @@ package body Ada.Text_IO.Editing is
                      Pic.End_Float := Invalid_Position;
                   end if;
 
-                  --  Don't assume that state is okay, haven't seen a digit.
+                  --  Don't assume that state is okay, haven't seen a digit
 
                   Picture;
                   return;
@@ -2427,12 +2429,12 @@ package body Ada.Text_IO.Editing is
          end case;
 
          --  Blank when zero either if the PIC does not contain a '9' or if
-         --  requested by the user and no '*'
+         --  requested by the user and no '*'.
 
          Pic.Blank_When_Zero :=
            (Computed_BWZ or Pic.Blank_When_Zero) and not Pic.Star_Fill;
 
-         --  Star fill if '*' and no '9'.
+         --  Star fill if '*' and no '9'
 
          Pic.Star_Fill := Pic.Star_Fill and Computed_BWZ;
 
@@ -2448,9 +2450,10 @@ package body Ada.Text_IO.Editing is
 
       procedure Set_State (L : Legality) is
       begin
-         if Debug then Ada.Text_IO.Put_Line
-            ("  Set state from " & Legality'Image (State) &
-                             " to " & Legality'Image (L));
+         if Debug then
+            Ada.Text_IO.Put_Line
+              ("  Set state from " & Legality'Image (State)
+               & " to " & Legality'Image (L));
          end if;
 
          State := L;
@@ -2462,8 +2465,8 @@ package body Ada.Text_IO.Editing is
 
       procedure Skip is
       begin
-         if Debug then Ada.Text_IO.Put_Line
-            ("  Skip " & Pic.Picture.Expanded (Index));
+         if Debug then
+            Ada.Text_IO.Put_Line ("  Skip " & Pic.Picture.Expanded (Index));
          end if;
 
          Index := Index + 1;
@@ -2706,7 +2709,7 @@ package body Ada.Text_IO.Editing is
 
       when Constraint_Error =>
 
-         --  To deal with special cases like null strings.
+      --  To deal with special cases like null strings
 
       raise Picture_Error;
    end Precalculate;
@@ -2716,9 +2719,8 @@ package body Ada.Text_IO.Editing is
    ----------------
 
    function To_Picture
-     (Pic_String      : in String;
-      Blank_When_Zero : in Boolean := False)
-      return            Picture
+     (Pic_String      : String;
+      Blank_When_Zero : Boolean := False) return Picture
    is
       Result : Picture;
 
@@ -2744,9 +2746,8 @@ package body Ada.Text_IO.Editing is
    -----------
 
    function Valid
-     (Pic_String      : in String;
-      Blank_When_Zero : in Boolean := False)
-      return            Boolean
+     (Pic_String      : String;
+      Blank_When_Zero : Boolean := False) return Boolean
    is
    begin
       declare
@@ -2763,8 +2764,8 @@ package body Ada.Text_IO.Editing is
 
          --  False only if Blank_When_Zero is True but the pic string has a '*'
 
-         return not Blank_When_Zero or
-           Strings_Fixed.Index (Expanded_Pic, "*") = 0;
+         return not Blank_When_Zero
+           or else Strings_Fixed.Index (Expanded_Pic, "*") = 0;
       end;
 
    exception
@@ -2782,13 +2783,12 @@ package body Ada.Text_IO.Editing is
       -----------
 
       function Image
-        (Item       : in Num;
-         Pic        : in Picture;
-         Currency   : in String    := Default_Currency;
-         Fill       : in Character := Default_Fill;
-         Separator  : in Character := Default_Separator;
-         Radix_Mark : in Character := Default_Radix_Mark)
-         return       String
+        (Item       : Num;
+         Pic        : Picture;
+         Currency   : String    := Default_Currency;
+         Fill       : Character := Default_Fill;
+         Separator  : Character := Default_Separator;
+         Radix_Mark : Character := Default_Radix_Mark) return String
       is
       begin
          return Format_Number
@@ -2801,9 +2801,8 @@ package body Ada.Text_IO.Editing is
       ------------
 
       function Length
-        (Pic      : in Picture;
-         Currency : in String := Default_Currency)
-         return     Natural
+        (Pic      : Picture;
+         Currency : String := Default_Currency) return Natural
       is
          Picstr     : constant String := Pic_String (Pic);
          V_Adjust   : Integer := 0;
@@ -2835,13 +2834,13 @@ package body Ada.Text_IO.Editing is
       ---------
 
       procedure Put
-        (File       : in Text_IO.File_Type;
-         Item       : in Num;
-         Pic        : in Picture;
-         Currency   : in String    := Default_Currency;
-         Fill       : in Character := Default_Fill;
-         Separator  : in Character := Default_Separator;
-         Radix_Mark : in Character := Default_Radix_Mark)
+        (File       : Text_IO.File_Type;
+         Item       : Num;
+         Pic        : Picture;
+         Currency   : String    := Default_Currency;
+         Fill       : Character := Default_Fill;
+         Separator  : Character := Default_Separator;
+         Radix_Mark : Character := Default_Radix_Mark)
       is
       begin
          Text_IO.Put (File, Image (Item, Pic,
@@ -2849,12 +2848,12 @@ package body Ada.Text_IO.Editing is
       end Put;
 
       procedure Put
-        (Item       : in Num;
-         Pic        : in Picture;
-         Currency   : in String    := Default_Currency;
-         Fill       : in Character := Default_Fill;
-         Separator  : in Character := Default_Separator;
-         Radix_Mark : in Character := Default_Radix_Mark)
+        (Item       : Num;
+         Pic        : Picture;
+         Currency   : String    := Default_Currency;
+         Fill       : Character := Default_Fill;
+         Separator  : Character := Default_Separator;
+         Radix_Mark : Character := Default_Radix_Mark)
       is
       begin
          Text_IO.Put (Image (Item, Pic,
@@ -2863,12 +2862,12 @@ package body Ada.Text_IO.Editing is
 
       procedure Put
         (To         : out String;
-         Item       : in Num;
-         Pic        : in Picture;
-         Currency   : in String    := Default_Currency;
-         Fill       : in Character := Default_Fill;
-         Separator  : in Character := Default_Separator;
-         Radix_Mark : in Character := Default_Radix_Mark)
+         Item       : Num;
+         Pic        : Picture;
+         Currency   : String    := Default_Currency;
+         Fill       : Character := Default_Fill;
+         Separator  : Character := Default_Separator;
+         Radix_Mark : Character := Default_Radix_Mark)
       is
          Result : constant String :=
            Image (Item, Pic, Currency, Fill, Separator, Radix_Mark);
@@ -2888,9 +2887,8 @@ package body Ada.Text_IO.Editing is
 
       function Valid
         (Item     : Num;
-         Pic      : in Picture;
-         Currency : in String := Default_Currency)
-         return     Boolean
+         Pic      : Picture;
+         Currency : String := Default_Currency) return Boolean
       is
       begin
          declare