1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . W I D E _ W I D E _ T E X T _ I O . E D I T I N G --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 with Ada
.Strings
.Fixed
;
33 with Ada
.Strings
.Wide_Wide_Fixed
;
35 package body Ada
.Wide_Wide_Text_IO
.Editing
is
37 package Strings
renames Ada
.Strings
;
38 package Strings_Fixed
renames Ada
.Strings
.Fixed
;
39 package Strings_Wide_Wide_Fixed
renames Ada
.Strings
.Wide_Wide_Fixed
;
40 package Wide_Wide_Text_IO
renames Ada
.Wide_Wide_Text_IO
;
42 -----------------------
43 -- Local_Subprograms --
44 -----------------------
46 function To_Wide
(C
: Character) return Wide_Wide_Character
;
47 pragma Inline
(To_Wide
);
48 -- Convert Character to corresponding Wide_Wide_Character
54 function Blank_When_Zero
(Pic
: Picture
) return Boolean is
56 return Pic
.Contents
.Original_BWZ
;
63 package body Decimal_Output
is
72 Currency
: Wide_Wide_String
:= Default_Currency
;
73 Fill
: Wide_Wide_Character
:= Default_Fill
;
74 Separator
: Wide_Wide_Character
:= Default_Separator
;
75 Radix_Mark
: Wide_Wide_Character
:= Default_Radix_Mark
)
76 return Wide_Wide_String
80 (Pic
.Contents
, Num
'Image (Item
),
81 Currency
, Fill
, Separator
, Radix_Mark
);
90 Currency
: Wide_Wide_String
:= Default_Currency
) return Natural
92 Picstr
: constant String := Pic_String
(Pic
);
93 V_Adjust
: Integer := 0;
94 Cur_Adjust
: Integer := 0;
97 -- Check if Picstr has 'V' or '$'
99 -- If 'V', then length is 1 less than otherwise
101 -- If '$', then length is Currency'Length-1 more than otherwise
103 -- This should use the string handling package ???
105 for J
in Picstr
'Range loop
106 if Picstr
(J
) = 'V' then
109 elsif Picstr
(J
) = '$' then
110 Cur_Adjust
:= Currency
'Length - 1;
114 return Picstr
'Length - V_Adjust
+ Cur_Adjust
;
122 (File
: Wide_Wide_Text_IO
.File_Type
;
125 Currency
: Wide_Wide_String
:= Default_Currency
;
126 Fill
: Wide_Wide_Character
:= Default_Fill
;
127 Separator
: Wide_Wide_Character
:= Default_Separator
;
128 Radix_Mark
: Wide_Wide_Character
:= Default_Radix_Mark
)
131 Wide_Wide_Text_IO
.Put
(File
, Image
(Item
, Pic
,
132 Currency
, Fill
, Separator
, Radix_Mark
));
138 Currency
: Wide_Wide_String
:= Default_Currency
;
139 Fill
: Wide_Wide_Character
:= Default_Fill
;
140 Separator
: Wide_Wide_Character
:= Default_Separator
;
141 Radix_Mark
: Wide_Wide_Character
:= Default_Radix_Mark
)
144 Wide_Wide_Text_IO
.Put
(Image
(Item
, Pic
,
145 Currency
, Fill
, Separator
, Radix_Mark
));
149 (To
: out Wide_Wide_String
;
152 Currency
: Wide_Wide_String
:= Default_Currency
;
153 Fill
: Wide_Wide_Character
:= Default_Fill
;
154 Separator
: Wide_Wide_Character
:= Default_Separator
;
155 Radix_Mark
: Wide_Wide_Character
:= Default_Radix_Mark
)
157 Result
: constant Wide_Wide_String
:=
158 Image
(Item
, Pic
, Currency
, Fill
, Separator
, Radix_Mark
);
161 if Result
'Length > To
'Length then
162 raise Wide_Wide_Text_IO
.Layout_Error
;
164 Strings_Wide_Wide_Fixed
.Move
(Source
=> Result
, Target
=> To
,
165 Justify
=> Strings
.Right
);
176 Currency
: Wide_Wide_String
:= Default_Currency
) return Boolean
180 Temp
: constant Wide_Wide_String
:= Image
(Item
, Pic
, Currency
);
181 pragma Warnings
(Off
, Temp
);
187 when Layout_Error
=> return False;
196 function Expand
(Picture
: String) return String is
197 Result
: String (1 .. MAX_PICSIZE
);
198 Picture_Index
: Integer := Picture
'First;
199 Result_Index
: Integer := Result
'First;
204 if Picture
'Length < 1 then
208 if Picture
(Picture
'First) = '(' then
213 case Picture
(Picture_Index
) is
217 -- We now need to scan out the count after a left paren. In
218 -- the non-wide version we used Integer_IO.Get, but that is
219 -- not convenient here, since we don't want to drag in normal
220 -- Text_IO just for this purpose. So we do the scan ourselves,
221 -- with the normal validity checks.
223 Last
:= Picture_Index
+ 1;
226 if Picture
(Last
) not in '0' .. '9' then
230 Count
:= Character'Pos (Picture
(Last
)) - Character'Pos ('0');
234 if Last
> Picture
'Last then
238 if Picture
(Last
) = '_' then
239 if Picture
(Last
- 1) = '_' then
243 elsif Picture
(Last
) = ')' then
246 elsif Picture
(Last
) not in '0' .. '9' then
251 + Character'Pos (Picture
(Last
)) -
258 -- In what follows note that one copy of the repeated
259 -- character has already been made, so a count of one is
260 -- no-op, and a count of zero erases a character.
262 for J
in 2 .. Count
loop
263 Result
(Result_Index
+ J
- 2) := Picture
(Picture_Index
- 1);
266 Result_Index
:= Result_Index
+ Count
- 1;
268 -- Last was a ')' throw it away too
270 Picture_Index
:= Last
+ 1;
276 Result
(Result_Index
) := Picture
(Picture_Index
);
277 Picture_Index
:= Picture_Index
+ 1;
278 Result_Index
:= Result_Index
+ 1;
282 exit when Picture_Index
> Picture
'Last;
285 return Result
(1 .. Result_Index
- 1);
296 function Format_Number
297 (Pic
: Format_Record
;
299 Currency_Symbol
: Wide_Wide_String
;
300 Fill_Character
: Wide_Wide_Character
;
301 Separator_Character
: Wide_Wide_Character
;
302 Radix_Point
: Wide_Wide_Character
) return Wide_Wide_String
304 Attrs
: Number_Attributes
:= Parse_Number_String
(Number
);
306 Rounded
: String := Number
;
308 Sign_Position
: Integer := Pic
.Sign_Position
; -- may float.
310 Answer
: Wide_Wide_String
(1 .. Pic
.Picture
.Length
);
312 Currency_Pos
: Integer := Pic
.Start_Currency
;
314 Dollar
: Boolean := False;
315 -- Overridden immediately if necessary
317 Zero
: Boolean := True;
318 -- Set to False when a non-zero digit is output
322 -- If the picture has fewer decimal places than the number, the image
323 -- must be rounded according to the usual rules.
325 if Attrs
.Has_Fraction
then
327 R
: constant Integer :=
328 (Attrs
.End_Of_Fraction
- Attrs
.Start_Of_Fraction
+ 1)
329 - Pic
.Max_Trailing_Digits
;
334 R_Pos
:= Rounded
'Length - R
;
336 if Rounded
(R_Pos
+ 1) > '4' then
338 if Rounded
(R_Pos
) = '.' then
342 if Rounded
(R_Pos
) /= '9' then
343 Rounded
(R_Pos
) := Character'Succ (Rounded
(R_Pos
));
345 Rounded
(R_Pos
) := '0';
349 if Rounded
(R_Pos
) = '.' then
353 if Rounded
(R_Pos
) /= '9' then
354 Rounded
(R_Pos
) := Character'Succ (Rounded
(R_Pos
));
357 Rounded
(R_Pos
) := '0';
362 -- The rounding may add a digit in front. Either the
363 -- leading blank or the sign (already captured) can be
367 Rounded
(R_Pos
) := '1';
368 Attrs
.Start_Of_Int
:= Attrs
.Start_Of_Int
- 1;
376 for J
in Answer
'Range loop
377 Answer
(J
) := To_Wide
(Pic
.Picture
.Expanded
(J
));
380 if Pic
.Start_Currency
/= Invalid_Position
then
381 Dollar
:= Answer
(Pic
.Start_Currency
) = '$';
384 -- Fix up "direct inserts" outside the playing field. Set up as one
385 -- loop to do the beginning, one (reverse) loop to do the end.
389 exit when Last
= Pic
.Start_Float
;
390 exit when Last
= Pic
.Radix_Position
;
391 exit when Answer
(Last
) = '9';
393 case Answer
(Last
) is
396 Answer
(Last
) := Separator_Character
;
399 Answer
(Last
) := ' ';
406 exit when Last
= Answer
'Last;
411 -- Now for the end...
413 for J
in reverse Last
.. Answer
'Last loop
414 exit when J
= Pic
.Radix_Position
;
416 -- Do this test First, Separator_Character can equal Pic.Floater
418 if Answer
(J
) = Pic
.Floater
then
425 Answer
(J
) := Separator_Character
;
441 if Pic
.Start_Currency
/= -1
442 and then Answer
(Pic
.Start_Currency
) = '#'
443 and then Pic
.Floater
/= '#'
445 if Currency_Symbol
'Length >
446 Pic
.End_Currency
- Pic
.Start_Currency
+ 1
450 elsif Currency_Symbol
'Length =
451 Pic
.End_Currency
- Pic
.Start_Currency
+ 1
453 Answer
(Pic
.Start_Currency
.. Pic
.End_Currency
) :=
456 elsif Pic
.Radix_Position
= Invalid_Position
457 or else Pic
.Start_Currency
< Pic
.Radix_Position
459 Answer
(Pic
.Start_Currency
.. Pic
.End_Currency
) :=
461 Answer
(Pic
.End_Currency
- Currency_Symbol
'Length + 1 ..
462 Pic
.End_Currency
) := Currency_Symbol
;
465 Answer
(Pic
.Start_Currency
.. Pic
.End_Currency
) :=
467 Answer
(Pic
.Start_Currency
..
468 Pic
.Start_Currency
+ Currency_Symbol
'Length - 1) :=
473 -- Fill in leading digits
475 if Attrs
.End_Of_Int
- Attrs
.Start_Of_Int
+ 1 >
476 Pic
.Max_Leading_Digits
481 if Pic
.Radix_Position
= Invalid_Position
then
482 Position
:= Answer
'Last;
484 Position
:= Pic
.Radix_Position
- 1;
487 for J
in reverse Attrs
.Start_Of_Int
.. Attrs
.End_Of_Int
loop
489 while Answer
(Position
) /= '9'
491 Answer
(Position
) /= Pic
.Floater
493 if Answer
(Position
) = '_' then
494 Answer
(Position
) := Separator_Character
;
496 elsif Answer
(Position
) = 'b' then
497 Answer
(Position
) := ' ';
500 Position
:= Position
- 1;
503 Answer
(Position
) := To_Wide
(Rounded
(J
));
505 if Rounded
(J
) /= '0' then
509 Position
:= Position
- 1;
514 if Pic
.Start_Float
= Invalid_Position
then
516 -- No leading floats, but need to change '9' to '0', '_' to
517 -- Separator_Character and 'b' to ' '.
519 for J
in Last
.. Position
loop
521 -- Last set when fixing the "uninteresting" leaders above.
522 -- Don't duplicate the work.
524 if Answer
(J
) = '9' then
527 elsif Answer
(J
) = '_' then
528 Answer
(J
) := Separator_Character
;
530 elsif Answer
(J
) = 'b' then
537 elsif Pic
.Floater
= '<'
543 for J
in Pic
.End_Float
.. Position
loop -- May be null range
544 if Answer
(J
) = '9' then
547 elsif Answer
(J
) = '_' then
548 Answer
(J
) := Separator_Character
;
550 elsif Answer
(J
) = 'b' then
556 if Position
> Pic
.End_Float
then
557 Position
:= Pic
.End_Float
;
560 for J
in Pic
.Start_Float
.. Position
- 1 loop
564 Answer
(Position
) := Pic
.Floater
;
565 Sign_Position
:= Position
;
567 elsif Pic
.Floater
= '$' then
569 for J
in Pic
.End_Float
.. Position
loop -- May be null range
570 if Answer
(J
) = '9' then
573 elsif Answer
(J
) = '_' then
574 Answer
(J
) := ' '; -- no separator before leftmost digit
576 elsif Answer
(J
) = 'b' then
581 if Position
> Pic
.End_Float
then
582 Position
:= Pic
.End_Float
;
585 for J
in Pic
.Start_Float
.. Position
- 1 loop
589 Answer
(Position
) := Pic
.Floater
;
590 Currency_Pos
:= Position
;
592 elsif Pic
.Floater
= '*' then
594 for J
in Pic
.End_Float
.. Position
loop -- May be null range
595 if Answer
(J
) = '9' then
598 elsif Answer
(J
) = '_' then
599 Answer
(J
) := Separator_Character
;
601 elsif Answer
(J
) = 'b' then
606 if Position
> Pic
.End_Float
then
607 Position
:= Pic
.End_Float
;
610 for J
in Pic
.Start_Float
.. Position
loop
615 if Pic
.Floater
= '#' then
616 Currency_Pos
:= Currency_Symbol
'Length;
619 for J
in reverse Pic
.Start_Float
.. Position
loop
623 Answer
(J
) := Fill_Character
;
625 when 'Z' |
'b' |
'/' |
'0' =>
631 when '.' |
'V' |
'v' |
'<' |
'$' |
'+' |
'-' =>
635 if Currency_Pos
= 0 then
638 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
639 Currency_Pos
:= Currency_Pos
- 1;
647 Answer
(J
) := Fill_Character
;
653 if Currency_Pos
= 0 then
657 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
658 Currency_Pos
:= Currency_Pos
- 1;
672 if Pic
.Floater
= '#' and then Currency_Pos
/= 0 then
679 if Sign_Position
= Invalid_Position
then
680 if Attrs
.Negative
then
685 if Attrs
.Negative
then
686 case Answer
(Sign_Position
) is
687 when 'C' |
'D' |
'-' =>
691 Answer
(Sign_Position
) := '-';
694 Answer
(Sign_Position
) := '(';
695 Answer
(Pic
.Second_Sign
) := ')';
704 case Answer
(Sign_Position
) is
707 Answer
(Sign_Position
) := ' ';
709 when '<' |
'C' |
'D' =>
710 Answer
(Sign_Position
) := ' ';
711 Answer
(Pic
.Second_Sign
) := ' ';
723 -- Fill in trailing digits
725 if Pic
.Max_Trailing_Digits
> 0 then
727 if Attrs
.Has_Fraction
then
728 Position
:= Attrs
.Start_Of_Fraction
;
729 Last
:= Pic
.Radix_Position
+ 1;
731 for J
in Last
.. Answer
'Last loop
733 if Answer
(J
) = '9' or else Answer
(J
) = Pic
.Floater
then
734 Answer
(J
) := To_Wide
(Rounded
(Position
));
736 if Rounded
(Position
) /= '0' then
740 Position
:= Position
+ 1;
743 -- Used up fraction but remember place in Answer
745 exit when Position
> Attrs
.End_Of_Fraction
;
747 elsif Answer
(J
) = 'b' then
750 elsif Answer
(J
) = '_' then
751 Answer
(J
) := Separator_Character
;
761 Position
:= Pic
.Radix_Position
+ 1;
764 -- Now fill remaining 9's with zeros and _ with separators
768 for J
in Position
.. Last
loop
769 if Answer
(J
) = '9' then
772 elsif Answer
(J
) = Pic
.Floater
then
775 elsif Answer
(J
) = '_' then
776 Answer
(J
) := Separator_Character
;
778 elsif Answer
(J
) = 'b' then
784 Position
:= Last
+ 1;
787 if Pic
.Floater
= '#' and then Currency_Pos
/= 0 then
791 -- No trailing digits, but now J may need to stick in a currency
794 if Pic
.Start_Currency
= Invalid_Position
then
795 Position
:= Answer
'Last + 1;
797 Position
:= Pic
.Start_Currency
;
801 for J
in Position
.. Answer
'Last loop
803 if Pic
.Start_Currency
/= Invalid_Position
and then
804 Answer
(Pic
.Start_Currency
) = '#' then
808 -- Note: There are some weird cases J can imagine with 'b' or '#'
809 -- in currency strings where the following code will cause
810 -- glitches. The trick is to tell when the character in the
811 -- answer should be checked, and when to look at the original
812 -- string. Some other time. RIE 11/26/96 ???
816 Answer
(J
) := Fill_Character
;
822 if Currency_Pos
> Currency_Symbol
'Length then
826 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
827 Currency_Pos
:= Currency_Pos
+ 1;
835 Answer
(J
) := Fill_Character
;
841 if Currency_Pos
> Currency_Symbol
'Length then
844 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
845 Currency_Pos
:= Currency_Pos
+ 1;
859 -- Now get rid of Blank_when_Zero and complete Star fill
861 if Zero
and then Pic
.Blank_When_Zero
then
863 -- Value is zero, and blank it
868 Last
:= Last
- 1 + Currency_Symbol
'Length;
871 if Pic
.Radix_Position
/= Invalid_Position
and then
872 Answer
(Pic
.Radix_Position
) = 'V' then
876 return Wide_Wide_String
'(1 .. Last => ' ');
878 elsif Zero and then Pic.Star_Fill then
882 Last := Last - 1 + Currency_Symbol'Length;
885 if Pic.Radix_Position /= Invalid_Position then
887 if Answer (Pic.Radix_Position) = 'V
' then
891 if Pic.Radix_Position > Pic.Start_Currency then
893 Wide_Wide_String'(1 .. Pic
.Radix_Position
- 1 => '*') &
895 Wide_Wide_String
'(Pic.Radix_Position + 1 .. Last => '*');
901 Pic
.Radix_Position
+ Currency_Symbol
'Length - 2
905 (Pic.Radix_Position + Currency_Symbol'Length .. Last
911 Wide_Wide_String'(1 .. Pic
.Radix_Position
- 1 => '*') &
913 Wide_Wide_String
'(Pic.Radix_Position + 1 .. Last => '*');
917 return Wide_Wide_String'(1 .. Last
=> '*');
920 -- This was once a simple return statement, now there are nine
921 -- different return cases. Not to mention the five above to deal
922 -- with zeros. Why not split things out?
924 -- Processing the radix and sign expansion separately
925 -- would require lots of copying--the string and some of its
926 -- indicies--without really simplifying the logic. The cases are:
928 -- 1) Expand $, replace '.' with Radix_Point
929 -- 2) No currency expansion, replace '.' with Radix_Point
930 -- 3) Expand $, radix blanked
931 -- 4) No currency expansion, radix blanked
933 -- 6) Expand $, Elide V
934 -- 7) Elide V, Expand $ (Two cases depending on order.)
935 -- 8) No radix, expand $
936 -- 9) No radix, no currency expansion
938 if Pic
.Radix_Position
/= Invalid_Position
then
940 if Answer
(Pic
.Radix_Position
) = '.' then
941 Answer
(Pic
.Radix_Position
) := Radix_Point
;
945 -- 1) Expand $, replace '.' with Radix_Point
947 return Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
948 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
951 -- 2) No currency expansion, replace '.' with Radix_Point
956 elsif Answer
(Pic
.Radix_Position
) = ' ' then -- blanked radix.
959 -- 3) Expand $, radix blanked
961 return Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
962 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
965 -- 4) No expansion, radix blanked
977 return Answer
(1 .. Pic
.Radix_Position
- 1) &
978 Answer
(Pic
.Radix_Position
+ 1 .. Answer
'Last);
980 elsif Currency_Pos
< Pic
.Radix_Position
then
982 -- 6) Expand $, Elide V
984 return Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
985 Answer
(Currency_Pos
+ 1 .. Pic
.Radix_Position
- 1) &
986 Answer
(Pic
.Radix_Position
+ 1 .. Answer
'Last);
989 -- 7) Elide V, Expand $
991 return Answer
(1 .. Pic
.Radix_Position
- 1) &
992 Answer
(Pic
.Radix_Position
+ 1 .. Currency_Pos
- 1) &
994 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
1000 -- 8) No radix, expand $
1002 return Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
1003 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
1006 -- 9) No radix, no currency expansion
1012 -------------------------
1013 -- Parse_Number_String --
1014 -------------------------
1016 function Parse_Number_String
(Str
: String) return Number_Attributes
is
1017 Answer
: Number_Attributes
;
1020 for J
in Str
'Range loop
1028 -- Decide if this is the start of a number.
1029 -- If so, figure out which one...
1031 if Answer
.Has_Fraction
then
1032 Answer
.End_Of_Fraction
:= J
;
1034 if Answer
.Start_Of_Int
= Invalid_Position
then
1036 Answer
.Start_Of_Int
:= J
;
1038 Answer
.End_Of_Int
:= J
;
1043 -- Only count a zero before the decimal point if it follows a
1044 -- non-zero digit. After the decimal point, zeros will be
1045 -- counted if followed by a non-zero digit.
1047 if not Answer
.Has_Fraction
then
1048 if Answer
.Start_Of_Int
/= Invalid_Position
then
1049 Answer
.End_Of_Int
:= J
;
1057 Answer
.Negative
:= True;
1061 -- Close integer, start fraction
1063 if Answer
.Has_Fraction
then
1064 raise Picture_Error
;
1067 -- Two decimal points is a no-no
1069 Answer
.Has_Fraction
:= True;
1070 Answer
.End_Of_Fraction
:= J
;
1072 -- Could leave this at Invalid_Position, but this seems the
1073 -- right way to indicate a null range...
1075 Answer
.Start_Of_Fraction
:= J
+ 1;
1076 Answer
.End_Of_Int
:= J
- 1;
1079 raise Picture_Error
; -- can this happen? probably not!
1083 if Answer
.Start_Of_Int
= Invalid_Position
then
1084 Answer
.Start_Of_Int
:= Answer
.End_Of_Int
+ 1;
1087 -- No significant (intger) digits needs a null range
1090 end Parse_Number_String
;
1096 -- The following ensures that we return B and not b being careful not
1097 -- to break things which expect lower case b for blank. See CXF3A02.
1099 function Pic_String
(Pic
: Picture
) return String is
1100 Temp
: String (1 .. Pic
.Contents
.Picture
.Length
) :=
1101 Pic
.Contents
.Picture
.Expanded
;
1103 for J
in Temp
'Range loop
1104 if Temp
(J
) = 'b' then
1116 procedure Precalculate
(Pic
: in out Format_Record
) is
1118 Computed_BWZ
: Boolean := True;
1120 type Legality
is (Okay
, Reject
);
1121 State
: Legality
:= Reject
;
1122 -- Start in reject, which will reject null strings
1124 Index
: Pic_Index
:= Pic
.Picture
.Expanded
'First;
1126 function At_End
return Boolean;
1127 pragma Inline
(At_End
);
1129 procedure Set_State
(L
: Legality
);
1130 pragma Inline
(Set_State
);
1132 function Look
return Character;
1133 pragma Inline
(Look
);
1135 function Is_Insert
return Boolean;
1136 pragma Inline
(Is_Insert
);
1139 pragma Inline
(Skip
);
1141 procedure Trailing_Currency
;
1142 procedure Trailing_Bracket
;
1143 procedure Number_Fraction
;
1144 procedure Number_Completion
;
1145 procedure Number_Fraction_Or_Bracket
;
1146 procedure Number_Fraction_Or_Z_Fill
;
1147 procedure Zero_Suppression
;
1148 procedure Floating_Bracket
;
1149 procedure Number_Fraction_Or_Star_Fill
;
1150 procedure Star_Suppression
;
1151 procedure Number_Fraction_Or_Dollar
;
1152 procedure Leading_Dollar
;
1153 procedure Number_Fraction_Or_Pound
;
1154 procedure Leading_Pound
;
1156 procedure Floating_Plus
;
1157 procedure Floating_Minus
;
1158 procedure Picture_Plus
;
1159 procedure Picture_Minus
;
1160 procedure Picture_Bracket
;
1162 procedure Optional_RHS_Sign
;
1163 procedure Picture_String
;
1169 function At_End
return Boolean is
1171 return Index
> Pic
.Picture
.Length
;
1174 ----------------------
1175 -- Floating_Bracket --
1176 ----------------------
1178 -- Note that Floating_Bracket is only called with an acceptable
1179 -- prefix. But we don't set Okay, because we must end with a '>'.
1181 procedure Floating_Bracket
is
1184 Pic
.End_Float
:= Index
;
1185 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1187 -- First bracket wasn't counted...
1198 when '_' |
'0' |
'/' =>
1199 Pic
.End_Float
:= Index
;
1203 Pic
.End_Float
:= Index
;
1204 Pic
.Picture
.Expanded
(Index
) := 'b';
1208 Pic
.End_Float
:= Index
;
1209 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1221 when 'V' |
'v' |
'.' =>
1222 Pic
.Radix_Position
:= Index
;
1224 Number_Fraction_Or_Bracket
;
1231 end Floating_Bracket
;
1233 --------------------
1234 -- Floating_Minus --
1235 --------------------
1237 procedure Floating_Minus
is
1245 when '_' |
'0' |
'/' =>
1246 Pic
.End_Float
:= Index
;
1250 Pic
.End_Float
:= Index
;
1251 Pic
.Picture
.Expanded
(Index
) := 'b';
1255 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1256 Pic
.End_Float
:= Index
;
1263 when '.' |
'V' |
'v' =>
1264 Pic
.Radix_Position
:= Index
;
1267 while Is_Insert
loop
1284 Pic
.Max_Trailing_Digits
:=
1285 Pic
.Max_Trailing_Digits
+ 1;
1286 Pic
.End_Float
:= Index
;
1289 when '_' |
'0' |
'/' =>
1293 Pic
.Picture
.Expanded
(Index
) := 'b';
1318 procedure Floating_Plus
is
1326 when '_' |
'0' |
'/' =>
1327 Pic
.End_Float
:= Index
;
1331 Pic
.End_Float
:= Index
;
1332 Pic
.Picture
.Expanded
(Index
) := 'b';
1336 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1337 Pic
.End_Float
:= Index
;
1344 when '.' |
'V' |
'v' =>
1345 Pic
.Radix_Position
:= Index
;
1348 while Is_Insert
loop
1365 Pic
.Max_Trailing_Digits
:=
1366 Pic
.Max_Trailing_Digits
+ 1;
1367 Pic
.End_Float
:= Index
;
1370 when '_' |
'0' |
'/' =>
1374 Pic
.Picture
.Expanded
(Index
) := 'b';
1400 function Is_Insert
return Boolean is
1406 case Pic
.Picture
.Expanded
(Index
) is
1408 when '_' |
'0' |
'/' => return True;
1411 Pic
.Picture
.Expanded
(Index
) := 'b'; -- canonical
1414 when others => return False;
1418 --------------------
1419 -- Leading_Dollar --
1420 --------------------
1422 -- Note that Leading_Dollar can be called in either State. It will set
1423 -- state to Okay only if a 9 or (second) is encountered.
1425 -- Also notice the tricky bit with State and Zero_Suppression.
1426 -- Zero_Suppression is Picture_Error if a '$' or a '9' has been
1427 -- encountered, exactly the cases where State has been set.
1429 procedure Leading_Dollar
is
1431 -- Treat as a floating dollar, and unwind otherwise
1434 Pic
.Start_Currency
:= Index
;
1435 Pic
.End_Currency
:= Index
;
1436 Pic
.Start_Float
:= Index
;
1437 Pic
.End_Float
:= Index
;
1439 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
1451 when '_' |
'0' |
'/' =>
1452 Pic
.End_Float
:= Index
;
1455 -- A trailing insertion character is not part of the
1456 -- floating currency, so need to look ahead.
1459 Pic
.End_Float
:= Pic
.End_Float
- 1;
1463 Pic
.End_Float
:= Index
;
1464 Pic
.Picture
.Expanded
(Index
) := 'b';
1468 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
1470 if State
= Okay
then
1471 raise Picture_Error
;
1473 -- Will overwrite Floater and Start_Float
1479 if State
= Okay
then
1480 raise Picture_Error
;
1482 -- Will overwrite Floater and Start_Float
1488 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1489 Pic
.End_Float
:= Index
;
1490 Pic
.End_Currency
:= Index
;
1491 Set_State
(Okay
); Skip
;
1494 if State
/= Okay
then
1496 Pic
.Start_Float
:= Invalid_Position
;
1497 Pic
.End_Float
:= Invalid_Position
;
1500 -- A single dollar does not a floating make
1505 when 'V' |
'v' |
'.' =>
1506 if State
/= Okay
then
1508 Pic
.Start_Float
:= Invalid_Position
;
1509 Pic
.End_Float
:= Invalid_Position
;
1512 -- Only one dollar before the sign is okay, but doesn't
1515 Pic
.Radix_Position
:= Index
;
1517 Number_Fraction_Or_Dollar
;
1531 -- This one is complex! A Leading_Pound can be fixed or floating,
1532 -- but in some cases the decision has to be deferred until we leave
1533 -- this procedure. Also note that Leading_Pound can be called in
1536 -- It will set state to Okay only if a 9 or (second) # is encountered
1538 -- One Last note: In ambiguous cases, the currency is treated as
1539 -- floating unless there is only one '#'.
1541 procedure Leading_Pound
is
1543 Inserts
: Boolean := False;
1544 -- Set to True if a '_', '0', '/', 'B', or 'b' is encountered
1546 Must_Float
: Boolean := False;
1547 -- Set to true if a '#' occurs after an insert
1550 -- Treat as a floating currency. If it isn't, this will be
1551 -- overwritten later.
1555 Pic
.Start_Currency
:= Index
;
1556 Pic
.End_Currency
:= Index
;
1557 Pic
.Start_Float
:= Index
;
1558 Pic
.End_Float
:= Index
;
1560 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
1563 Pic
.Max_Currency_Digits
:= 1; -- we've seen one.
1574 when '_' |
'0' |
'/' =>
1575 Pic
.End_Float
:= Index
;
1580 Pic
.Picture
.Expanded
(Index
) := 'b';
1581 Pic
.End_Float
:= Index
;
1586 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
1589 raise Picture_Error
;
1591 Pic
.Max_Leading_Digits
:= 0;
1593 -- Will overwrite Floater and Start_Float
1600 raise Picture_Error
;
1602 Pic
.Max_Leading_Digits
:= 0;
1604 -- Will overwrite Floater and Start_Float
1614 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1615 Pic
.End_Float
:= Index
;
1616 Pic
.End_Currency
:= Index
;
1621 if State
/= Okay
then
1623 -- A single '#' doesn't float
1626 Pic
.Start_Float
:= Invalid_Position
;
1627 Pic
.End_Float
:= Invalid_Position
;
1633 when 'V' |
'v' |
'.' =>
1634 if State
/= Okay
then
1636 Pic
.Start_Float
:= Invalid_Position
;
1637 Pic
.End_Float
:= Invalid_Position
;
1640 -- Only one pound before the sign is okay, but doesn't
1643 Pic
.Radix_Position
:= Index
;
1645 Number_Fraction_Or_Pound
;
1658 function Look
return Character is
1661 raise Picture_Error
;
1664 return Pic
.Picture
.Expanded
(Index
);
1676 when '_' |
'0' |
'/' =>
1680 Pic
.Picture
.Expanded
(Index
) := 'b';
1684 Computed_BWZ
:= False;
1685 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1689 when '.' |
'V' |
'v' =>
1690 Pic
.Radix_Position
:= Index
;
1704 -- Will return in Okay state if a '9' was seen
1709 -----------------------
1710 -- Number_Completion --
1711 -----------------------
1713 procedure Number_Completion
is
1715 while not At_End
loop
1718 when '_' |
'0' |
'/' =>
1722 Pic
.Picture
.Expanded
(Index
) := 'b';
1726 Computed_BWZ
:= False;
1727 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1731 when 'V' |
'v' |
'.' =>
1732 Pic
.Radix_Position
:= Index
;
1741 end Number_Completion
;
1743 ---------------------
1744 -- Number_Fraction --
1745 ---------------------
1747 procedure Number_Fraction
is
1749 -- Note that number fraction can be called in either State.
1750 -- It will set state to Valid only if a 9 is encountered.
1758 when '_' |
'0' |
'/' =>
1762 Pic
.Picture
.Expanded
(Index
) := 'b';
1766 Computed_BWZ
:= False;
1767 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1768 Set_State
(Okay
); Skip
;
1774 end Number_Fraction
;
1776 --------------------------------
1777 -- Number_Fraction_Or_Bracket --
1778 --------------------------------
1780 procedure Number_Fraction_Or_Bracket
is
1789 when '_' |
'0' |
'/' => Skip
;
1792 Pic
.Picture
.Expanded
(Index
) := 'b';
1796 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1797 Pic
.End_Float
:= Index
;
1806 when '_' |
'0' |
'/' =>
1810 Pic
.Picture
.Expanded
(Index
) := 'b';
1814 Pic
.Max_Trailing_Digits
:=
1815 Pic
.Max_Trailing_Digits
+ 1;
1816 Pic
.End_Float
:= Index
;
1829 end Number_Fraction_Or_Bracket
;
1831 -------------------------------
1832 -- Number_Fraction_Or_Dollar --
1833 -------------------------------
1835 procedure Number_Fraction_Or_Dollar
is
1843 when '_' |
'0' |
'/' =>
1847 Pic
.Picture
.Expanded
(Index
) := 'b';
1851 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1852 Pic
.End_Float
:= Index
;
1861 when '_' |
'0' |
'/' =>
1865 Pic
.Picture
.Expanded
(Index
) := 'b';
1869 Pic
.Max_Trailing_Digits
:=
1870 Pic
.Max_Trailing_Digits
+ 1;
1871 Pic
.End_Float
:= Index
;
1884 end Number_Fraction_Or_Dollar
;
1886 ------------------------------
1887 -- Number_Fraction_Or_Pound --
1888 ------------------------------
1890 procedure Number_Fraction_Or_Pound
is
1899 when '_' |
'0' |
'/' =>
1903 Pic
.Picture
.Expanded
(Index
) := 'b';
1907 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1908 Pic
.End_Float
:= Index
;
1918 when '_' |
'0' |
'/' =>
1922 Pic
.Picture
.Expanded
(Index
) := 'b';
1926 Pic
.Max_Trailing_Digits
:=
1927 Pic
.Max_Trailing_Digits
+ 1;
1928 Pic
.End_Float
:= Index
;
1943 end Number_Fraction_Or_Pound
;
1945 ----------------------------------
1946 -- Number_Fraction_Or_Star_Fill --
1947 ----------------------------------
1949 procedure Number_Fraction_Or_Star_Fill
is
1958 when '_' |
'0' |
'/' =>
1962 Pic
.Picture
.Expanded
(Index
) := 'b';
1966 Pic
.Star_Fill
:= True;
1967 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1968 Pic
.End_Float
:= Index
;
1978 when '_' |
'0' |
'/' =>
1982 Pic
.Picture
.Expanded
(Index
) := 'b';
1986 Pic
.Star_Fill
:= True;
1987 Pic
.Max_Trailing_Digits
:=
1988 Pic
.Max_Trailing_Digits
+ 1;
1989 Pic
.End_Float
:= Index
;
2003 end Number_Fraction_Or_Star_Fill
;
2005 -------------------------------
2006 -- Number_Fraction_Or_Z_Fill --
2007 -------------------------------
2009 procedure Number_Fraction_Or_Z_Fill
is
2018 when '_' |
'0' |
'/' =>
2022 Pic
.Picture
.Expanded
(Index
) := 'b';
2026 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
2027 Pic
.End_Float
:= Index
;
2028 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2039 when '_' |
'0' |
'/' =>
2043 Pic
.Picture
.Expanded
(Index
) := 'b';
2047 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2049 Pic
.Max_Trailing_Digits
:=
2050 Pic
.Max_Trailing_Digits
+ 1;
2051 Pic
.End_Float
:= Index
;
2064 end Number_Fraction_Or_Z_Fill
;
2066 -----------------------
2067 -- Optional_RHS_Sign --
2068 -----------------------
2070 procedure Optional_RHS_Sign
is
2079 Pic
.Sign_Position
:= Index
;
2084 Pic
.Sign_Position
:= Index
;
2085 Pic
.Picture
.Expanded
(Index
) := 'C';
2088 if Look
= 'R' or else Look
= 'r' then
2089 Pic
.Second_Sign
:= Index
;
2090 Pic
.Picture
.Expanded
(Index
) := 'R';
2094 raise Picture_Error
;
2100 Pic
.Sign_Position
:= Index
;
2101 Pic
.Picture
.Expanded
(Index
) := 'D';
2104 if Look
= 'B' or else Look
= 'b' then
2105 Pic
.Second_Sign
:= Index
;
2106 Pic
.Picture
.Expanded
(Index
) := 'B';
2110 raise Picture_Error
;
2116 if Pic
.Picture
.Expanded
(Pic
.Sign_Position
) = '<' then
2117 Pic
.Second_Sign
:= Index
;
2121 raise Picture_Error
;
2128 end Optional_RHS_Sign
;
2134 -- Note that Picture can be called in either State
2136 -- It will set state to Valid only if a 9 is encountered or floating
2137 -- currency is called.
2139 procedure Picture
is
2148 when '_' |
'0' |
'/' =>
2152 Pic
.Picture
.Expanded
(Index
) := 'b';
2164 Computed_BWZ
:= False;
2166 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2169 when 'V' |
'v' |
'.' =>
2170 Pic
.Radix_Position
:= Index
;
2183 ---------------------
2184 -- Picture_Bracket --
2185 ---------------------
2187 procedure Picture_Bracket
is
2189 Pic
.Sign_Position
:= Index
;
2190 Pic
.Sign_Position
:= Index
;
2192 -- Treat as a floating sign, and unwind otherwise
2195 Pic
.Start_Float
:= Index
;
2196 Pic
.End_Float
:= Index
;
2198 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
2201 Skip
; -- Known Bracket
2206 when '_' |
'0' |
'/' =>
2207 Pic
.End_Float
:= Index
;
2211 Pic
.End_Float
:= Index
;
2212 Pic
.Picture
.Expanded
(Index
) := 'b';
2216 Set_State
(Okay
); -- "<<>" is enough.
2222 when '$' |
'#' |
'9' |
'*' =>
2223 if State
/= Okay
then
2225 Pic
.Start_Float
:= Invalid_Position
;
2226 Pic
.End_Float
:= Invalid_Position
;
2234 when '.' |
'V' |
'v' =>
2235 if State
/= Okay
then
2237 Pic
.Start_Float
:= Invalid_Position
;
2238 Pic
.End_Float
:= Invalid_Position
;
2241 -- Don't assume that state is okay, haven't seen a digit
2248 raise Picture_Error
;
2252 end Picture_Bracket
;
2258 procedure Picture_Minus
is
2260 Pic
.Sign_Position
:= Index
;
2262 -- Treat as a floating sign, and unwind otherwise
2265 Pic
.Start_Float
:= Index
;
2266 Pic
.End_Float
:= Index
;
2268 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
2271 Skip
; -- Known Minus
2276 when '_' |
'0' |
'/' =>
2277 Pic
.End_Float
:= Index
;
2281 Pic
.End_Float
:= Index
;
2282 Pic
.Picture
.Expanded
(Index
) := 'b';
2286 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2287 Pic
.End_Float
:= Index
;
2289 Set_State
(Okay
); -- "-- " is enough.
2294 when '$' |
'#' |
'9' |
'*' =>
2295 if State
/= Okay
then
2297 Pic
.Start_Float
:= Invalid_Position
;
2298 Pic
.End_Float
:= Invalid_Position
;
2307 -- Can't have Z and a floating sign
2309 if State
= Okay
then
2313 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2319 when '.' |
'V' |
'v' =>
2320 if State
/= Okay
then
2322 Pic
.Start_Float
:= Invalid_Position
;
2323 Pic
.End_Float
:= Invalid_Position
;
2326 -- Don't assume that state is okay, haven't seen a digit
2342 procedure Picture_Plus
is
2344 Pic
.Sign_Position
:= Index
;
2346 -- Treat as a floating sign, and unwind otherwise
2349 Pic
.Start_Float
:= Index
;
2350 Pic
.End_Float
:= Index
;
2352 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
2360 when '_' |
'0' |
'/' =>
2361 Pic
.End_Float
:= Index
;
2365 Pic
.End_Float
:= Index
;
2366 Pic
.Picture
.Expanded
(Index
) := 'b';
2370 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2371 Pic
.End_Float
:= Index
;
2373 Set_State
(Okay
); -- "++" is enough
2378 when '$' |
'#' |
'9' |
'*' =>
2379 if State
/= Okay
then
2381 Pic
.Start_Float
:= Invalid_Position
;
2382 Pic
.End_Float
:= Invalid_Position
;
2390 if State
= Okay
then
2394 -- Can't have Z and a floating sign
2396 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2398 -- '+Z' is acceptable
2407 when '.' |
'V' |
'v' =>
2408 if State
/= Okay
then
2410 Pic
.Start_Float
:= Invalid_Position
;
2411 Pic
.End_Float
:= Invalid_Position
;
2414 -- Don't assume that state is okay, haven't seen a digit
2426 --------------------
2427 -- Picture_String --
2428 --------------------
2430 procedure Picture_String
is
2432 while Is_Insert
loop
2452 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2462 when '9' |
'.' |
'V' |
'v' =>
2468 raise Picture_Error
;
2472 -- Blank when zero either if the PIC does not contain a '9' or if
2473 -- requested by the user and no '*'.
2475 Pic
.Blank_When_Zero
:=
2476 (Computed_BWZ
or else Pic
.Blank_When_Zero
)
2477 and then not Pic
.Star_Fill
;
2479 -- Star fill if '*' and no '9'
2481 Pic
.Star_Fill
:= Pic
.Star_Fill
and then Computed_BWZ
;
2493 procedure Set_State
(L
: Legality
) is
2507 ----------------------
2508 -- Star_Suppression --
2509 ----------------------
2511 procedure Star_Suppression
is
2514 Pic
.Start_Float
:= Index
;
2515 Pic
.End_Float
:= Index
;
2516 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2519 -- Even a single * is a valid picture
2521 Pic
.Star_Fill
:= True;
2531 when '_' |
'0' |
'/' =>
2532 Pic
.End_Float
:= Index
;
2536 Pic
.End_Float
:= Index
;
2537 Pic
.Picture
.Expanded
(Index
) := 'b';
2541 Pic
.End_Float
:= Index
;
2542 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2543 Set_State
(Okay
); Skip
;
2550 when '.' |
'V' |
'v' =>
2551 Pic
.Radix_Position
:= Index
;
2553 Number_Fraction_Or_Star_Fill
;
2561 when others => raise Picture_Error
;
2564 end Star_Suppression
;
2566 ----------------------
2567 -- Trailing_Bracket --
2568 ----------------------
2570 procedure Trailing_Bracket
is
2573 Pic
.Second_Sign
:= Index
;
2576 raise Picture_Error
;
2578 end Trailing_Bracket
;
2580 -----------------------
2581 -- Trailing_Currency --
2582 -----------------------
2584 procedure Trailing_Currency
is
2591 Pic
.Start_Currency
:= Index
;
2592 Pic
.End_Currency
:= Index
;
2596 while not At_End
and then Look
= '#' loop
2597 if Pic
.Start_Currency
= Invalid_Position
then
2598 Pic
.Start_Currency
:= Index
;
2601 Pic
.End_Currency
:= Index
;
2612 when '_' |
'0' |
'/' => Skip
;
2615 Pic
.Picture
.Expanded
(Index
) := 'b';
2618 when others => return;
2621 end Trailing_Currency
;
2623 ----------------------
2624 -- Zero_Suppression --
2625 ----------------------
2627 procedure Zero_Suppression
is
2630 Pic
.Start_Float
:= Index
;
2631 Pic
.End_Float
:= Index
;
2632 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2633 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2638 -- Even a single Z is a valid picture
2646 when '_' |
'0' |
'/' =>
2647 Pic
.End_Float
:= Index
;
2651 Pic
.End_Float
:= Index
;
2652 Pic
.Picture
.Expanded
(Index
) := 'b';
2656 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2658 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2659 Pic
.End_Float
:= Index
;
2668 when '.' |
'V' |
'v' =>
2669 Pic
.Radix_Position
:= Index
;
2671 Number_Fraction_Or_Z_Fill
;
2683 end Zero_Suppression
;
2685 -- Start of processing for Precalculate
2690 if State
= Reject
then
2691 raise Picture_Error
;
2696 when Constraint_Error
=>
2698 -- To deal with special cases like null strings
2700 raise Picture_Error
;
2709 (Pic_String
: String;
2710 Blank_When_Zero
: Boolean := False) return Picture
2716 Item
: constant String := Expand
(Pic_String
);
2719 Result
.Contents
.Picture
:= (Item
'Length, Item
);
2720 Result
.Contents
.Original_BWZ
:= Blank_When_Zero
;
2721 Result
.Contents
.Blank_When_Zero
:= Blank_When_Zero
;
2722 Precalculate
(Result
.Contents
);
2728 raise Picture_Error
;
2736 function To_Wide
(C
: Character) return Wide_Wide_Character
is
2738 return Wide_Wide_Character
'Val (Character'Pos (C
));
2746 (Pic_String
: String;
2747 Blank_When_Zero
: Boolean := False) return Boolean
2751 Expanded_Pic
: constant String := Expand
(Pic_String
);
2752 -- Raises Picture_Error if Item not well-formed
2754 Format_Rec
: Format_Record
;
2757 Format_Rec
.Picture
:= (Expanded_Pic
'Length, Expanded_Pic
);
2758 Format_Rec
.Blank_When_Zero
:= Blank_When_Zero
;
2759 Format_Rec
.Original_BWZ
:= Blank_When_Zero
;
2760 Precalculate
(Format_Rec
);
2762 -- False only if Blank_When_0 is True but the pic string has a '*'
2764 return not Blank_When_Zero
2765 or else Strings_Fixed
.Index
(Expanded_Pic
, "*") = 0;
2769 when others => return False;
2772 end Ada
.Wide_Wide_Text_IO
.Editing
;