-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2009, 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- --
--- ware Foundation; either version 2, or (at your option) any later ver- --
+-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
--- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
--- for more details. You should have received a copy of the GNU General --
--- Public License distributed with GNAT; see file COPYING. If not, write --
--- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
--- Boston, MA 02110-1301, USA. --
+-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
--- As a special exception, if other files instantiate generics from this --
--- unit, or you link this unit with other files to produce an executable, --
--- this unit does not by itself cause the resulting executable to be --
--- covered by the GNU General Public License. This exception does not --
--- however invalidate any other reasons why the executable file might be --
--- covered by the GNU Public License. --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception, --
+-- version 3.1, as published by the Free Software Foundation. --
+-- --
+-- You should have received a copy of the GNU General Public License and --
+-- a copy of the GCC Runtime Library Exception along with this program; --
+-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
+-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
case Picture (Picture_Index) is
when '(' =>
- Int_IO.Get (Picture (Picture_Index + 1 .. Picture'Last),
- Count, Last);
+ Int_IO.Get
+ (Picture (Picture_Index + 1 .. Picture'Last), Count, Last);
if Picture (Last + 1) /= ')' then
raise Picture_Error;
end if;
- -- In what follows note that one copy of the repeated
- -- character has already been made, so a count of one is a
- -- no-op, and a count of zero erases a character.
+ -- In what follows note that one copy of the repeated character
+ -- has already been made, so a count of one is a no-op, and a
+ -- count of zero erases a character.
+
+ if Result_Index + Count - 2 > Result'Last then
+ raise Picture_Error;
+ end if;
for J in 2 .. Count loop
Result (Result_Index + J - 2) := Picture (Picture_Index - 1);
raise Picture_Error;
when others =>
+ if Result_Index > Result'Last then
+ raise Picture_Error;
+ end if;
+
Result (Result_Index) := Picture (Picture_Index);
Picture_Index := Picture_Index + 1;
Result_Index := Result_Index + 1;
raise Ada.Text_IO.Layout_Error;
end if;
- if Pic.Radix_Position = Invalid_Position then
- Position := Answer'Last;
- else
- Position := Pic.Radix_Position - 1;
- end if;
+ Position :=
+ (if Pic.Radix_Position = Invalid_Position
+ then Answer'Last
+ else Pic.Radix_Position - 1);
for J in reverse Attrs.Start_Of_Int .. Attrs.End_Of_Int loop
-
while Answer (Position) /= '9'
- and Answer (Position) /= Pic.Floater
+ and then
+ Answer (Position) /= Pic.Floater
loop
if Answer (Position) = '_' then
Answer (Position) := Separator_Character;
Answer (J) := Separator_Character;
elsif Answer (J) = 'b' then
- Answer (J) := '*';
+ Answer (J) := Fill_Character;
end if;
end loop;
end if;
for J in Pic.Start_Float .. Position loop
- Answer (J) := '*';
+ Answer (J) := Fill_Character;
end loop;
else
Last := Pic.Radix_Position + 1;
for J in Last .. Answer'Last loop
-
- if Answer (J) = '9' or Answer (J) = Pic.Floater then
+ if Answer (J) = '9' or else Answer (J) = Pic.Floater then
Answer (J) := Rounded (Position);
if Rounded (Position) /= '0' then
-- No trailing digits, but now J may need to stick in a currency
-- symbol or sign.
- if Pic.Start_Currency = Invalid_Position then
- Position := Answer'Last + 1;
- else
- Position := Pic.Start_Currency;
- end if;
+ Position :=
+ (if Pic.Start_Currency = Invalid_Position
+ then Answer'Last + 1
+ else Pic.Start_Currency);
end if;
for J in Position .. Answer'Last loop
-
if Pic.Start_Currency /= Invalid_Position and then
Answer (Pic.Start_Currency) = '#' then
Currency_Pos := 1;
-- Now get rid of Blank_when_Zero and complete Star fill
- if Zero and Pic.Blank_When_Zero then
+ if Zero and then Pic.Blank_When_Zero then
-- Value is zero, and blank it
return String'(1 .. Last => ' ');
- elsif Zero and Pic.Star_Fill then
+ elsif Zero and then Pic.Star_Fill then
Last := Answer'Last;
if Dollar then
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;
Pic.Picture.Expanded (Index) := 'C';
Skip;
- if Look = 'R' or Look = 'r' then
+ if Look = 'R' or else Look = 'r' then
Pic.Second_Sign := Index;
Pic.Picture.Expanded (Index) := 'R';
Skip;
Pic.Picture.Expanded (Index) := 'D';
Skip;
- if Look = 'B' or Look = 'b' then
+ if Look = 'B' or else Look = 'b' then
Pic.Second_Sign := Index;
Pic.Picture.Expanded (Index) := 'B';
Skip;
-- requested by the user and no '*'.
Pic.Blank_When_Zero :=
- (Computed_BWZ or Pic.Blank_When_Zero) and not Pic.Star_Fill;
+ (Computed_BWZ or else Pic.Blank_When_Zero)
+ and then not Pic.Star_Fill;
-- Star fill if '*' and no '9'
- Pic.Star_Fill := Pic.Star_Fill and Computed_BWZ;
+ Pic.Star_Fill := Pic.Star_Fill and then Computed_BWZ;
if not At_End then
Set_State (Reject);
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;
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;