1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . W I D E _ T E X T _ I O . E D I T I N G --
9 -- Copyright (C) 1992-2016, 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_Fixed
;
35 package body Ada
.Wide_Text_IO
.Editing
is
37 package Strings
renames Ada
.Strings
;
38 package Strings_Fixed
renames Ada
.Strings
.Fixed
;
39 package Strings_Wide_Fixed
renames Ada
.Strings
.Wide_Fixed
;
40 package Wide_Text_IO
renames Ada
.Wide_Text_IO
;
42 -----------------------
43 -- Local_Subprograms --
44 -----------------------
46 function To_Wide
(C
: Character) return Wide_Character;
47 pragma Inline
(To_Wide
);
48 -- Convert Character to corresponding 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_String := Default_Currency
;
73 Fill
: Wide_Character := Default_Fill
;
74 Separator
: Wide_Character := Default_Separator
;
75 Radix_Mark
: Wide_Character := Default_Radix_Mark
) return Wide_String
79 (Pic
.Contents
, Num
'Image (Item
),
80 Currency
, Fill
, Separator
, Radix_Mark
);
89 Currency
: Wide_String := Default_Currency
) return Natural
91 Picstr
: constant String := Pic_String
(Pic
);
92 V_Adjust
: Integer := 0;
93 Cur_Adjust
: Integer := 0;
96 -- Check if Picstr has 'V' or '$'
98 -- If 'V', then length is 1 less than otherwise
100 -- If '$', then length is Currency'Length-1 more than otherwise
102 -- This should use the string handling package ???
104 for J
in Picstr
'Range loop
105 if Picstr
(J
) = 'V' then
108 elsif Picstr
(J
) = '$' then
109 Cur_Adjust
:= Currency
'Length - 1;
113 return Picstr
'Length - V_Adjust
+ Cur_Adjust
;
121 (File
: Wide_Text_IO
.File_Type
;
124 Currency
: Wide_String := Default_Currency
;
125 Fill
: Wide_Character := Default_Fill
;
126 Separator
: Wide_Character := Default_Separator
;
127 Radix_Mark
: Wide_Character := Default_Radix_Mark
)
130 Wide_Text_IO
.Put
(File
, Image
(Item
, Pic
,
131 Currency
, Fill
, Separator
, Radix_Mark
));
137 Currency
: Wide_String := Default_Currency
;
138 Fill
: Wide_Character := Default_Fill
;
139 Separator
: Wide_Character := Default_Separator
;
140 Radix_Mark
: Wide_Character := Default_Radix_Mark
)
143 Wide_Text_IO
.Put
(Image
(Item
, Pic
,
144 Currency
, Fill
, Separator
, Radix_Mark
));
148 (To
: out Wide_String;
151 Currency
: Wide_String := Default_Currency
;
152 Fill
: Wide_Character := Default_Fill
;
153 Separator
: Wide_Character := Default_Separator
;
154 Radix_Mark
: Wide_Character := Default_Radix_Mark
)
156 Result
: constant Wide_String :=
157 Image
(Item
, Pic
, Currency
, Fill
, Separator
, Radix_Mark
);
160 if Result
'Length > To
'Length then
161 raise Wide_Text_IO
.Layout_Error
;
163 Strings_Wide_Fixed
.Move
(Source
=> Result
, Target
=> To
,
164 Justify
=> Strings
.Right
);
175 Currency
: Wide_String := Default_Currency
) return Boolean
179 Temp
: constant Wide_String := Image
(Item
, Pic
, Currency
);
180 pragma Warnings
(Off
, Temp
);
186 when Layout_Error
=> return False;
195 function Expand
(Picture
: String) return String is
196 Result
: String (1 .. MAX_PICSIZE
);
197 Picture_Index
: Integer := Picture
'First;
198 Result_Index
: Integer := Result
'First;
203 if Picture
'Length < 1 then
207 if Picture
(Picture
'First) = '(' then
212 case Picture
(Picture_Index
) is
215 -- We now need to scan out the count after a left paren. In
216 -- the non-wide version we used Integer_IO.Get, but that is
217 -- not convenient here, since we don't want to drag in normal
218 -- Text_IO just for this purpose. So we do the scan ourselves,
219 -- with the normal validity checks.
221 Last
:= Picture_Index
+ 1;
224 if Picture
(Last
) not in '0' .. '9' then
228 Count
:= Character'Pos (Picture
(Last
)) - Character'Pos ('0');
232 if Last
> Picture
'Last then
236 if Picture
(Last
) = '_' then
237 if Picture
(Last
- 1) = '_' then
241 elsif Picture
(Last
) = ')' then
244 elsif Picture
(Last
) not in '0' .. '9' then
249 + Character'Pos (Picture
(Last
)) -
256 -- In what follows note that one copy of the repeated
257 -- character has already been made, so a count of one is
258 -- no-op, and a count of zero erases a character.
260 for J
in 2 .. Count
loop
261 Result
(Result_Index
+ J
- 2) := Picture
(Picture_Index
- 1);
264 Result_Index
:= Result_Index
+ Count
- 1;
266 -- Last was a ')' throw it away too
268 Picture_Index
:= Last
+ 1;
274 Result
(Result_Index
) := Picture
(Picture_Index
);
275 Picture_Index
:= Picture_Index
+ 1;
276 Result_Index
:= Result_Index
+ 1;
279 exit when Picture_Index
> Picture
'Last;
282 return Result
(1 .. Result_Index
- 1);
293 function Format_Number
294 (Pic
: Format_Record
;
296 Currency_Symbol
: Wide_String;
297 Fill_Character
: Wide_Character;
298 Separator_Character
: Wide_Character;
299 Radix_Point
: Wide_Character) return Wide_String
301 Attrs
: Number_Attributes
:= Parse_Number_String
(Number
);
303 Rounded
: String := Number
;
305 Sign_Position
: Integer := Pic
.Sign_Position
; -- may float.
307 Answer
: Wide_String (1 .. Pic
.Picture
.Length
);
309 Currency_Pos
: Integer := Pic
.Start_Currency
;
311 Dollar
: Boolean := False;
312 -- Overridden immediately if necessary
314 Zero
: Boolean := True;
315 -- Set to False when a non-zero digit is output
319 -- If the picture has fewer decimal places than the number, the image
320 -- must be rounded according to the usual rules.
322 if Attrs
.Has_Fraction
then
324 R
: constant Integer :=
325 (Attrs
.End_Of_Fraction
- Attrs
.Start_Of_Fraction
+ 1)
326 - Pic
.Max_Trailing_Digits
;
331 R_Pos
:= Rounded
'Length - R
;
333 if Rounded
(R_Pos
+ 1) > '4' then
335 if Rounded
(R_Pos
) = '.' then
339 if Rounded
(R_Pos
) /= '9' then
340 Rounded
(R_Pos
) := Character'Succ (Rounded
(R_Pos
));
342 Rounded
(R_Pos
) := '0';
346 if Rounded
(R_Pos
) = '.' then
350 if Rounded
(R_Pos
) /= '9' then
351 Rounded
(R_Pos
) := Character'Succ (Rounded
(R_Pos
));
354 Rounded
(R_Pos
) := '0';
359 -- The rounding may add a digit in front. Either the
360 -- leading blank or the sign (already captured) can be
364 Rounded
(R_Pos
) := '1';
365 Attrs
.Start_Of_Int
:= Attrs
.Start_Of_Int
- 1;
373 for J
in Answer
'Range loop
374 Answer
(J
) := To_Wide
(Pic
.Picture
.Expanded
(J
));
377 if Pic
.Start_Currency
/= Invalid_Position
then
378 Dollar
:= Answer
(Pic
.Start_Currency
) = '$';
381 -- Fix up "direct inserts" outside the playing field. Set up as one
382 -- loop to do the beginning, one (reverse) loop to do the end.
386 exit when Last
= Pic
.Start_Float
;
387 exit when Last
= Pic
.Radix_Position
;
388 exit when Answer
(Last
) = '9';
390 case Answer
(Last
) is
392 Answer
(Last
) := Separator_Character
;
395 Answer
(Last
) := ' ';
401 exit when Last
= Answer
'Last;
406 -- Now for the end...
408 for J
in reverse Last
.. Answer
'Last loop
409 exit when J
= Pic
.Radix_Position
;
411 -- Do this test First, Separator_Character can equal Pic.Floater
413 if Answer
(J
) = Pic
.Floater
then
419 Answer
(J
) := Separator_Character
;
434 if Pic
.Start_Currency
/= -1
435 and then Answer
(Pic
.Start_Currency
) = '#'
436 and then Pic
.Floater
/= '#'
438 if Currency_Symbol
'Length >
439 Pic
.End_Currency
- Pic
.Start_Currency
+ 1
443 elsif Currency_Symbol
'Length =
444 Pic
.End_Currency
- Pic
.Start_Currency
+ 1
446 Answer
(Pic
.Start_Currency
.. Pic
.End_Currency
) :=
449 elsif Pic
.Radix_Position
= Invalid_Position
450 or else Pic
.Start_Currency
< Pic
.Radix_Position
452 Answer
(Pic
.Start_Currency
.. Pic
.End_Currency
) :=
454 Answer
(Pic
.End_Currency
- Currency_Symbol
'Length + 1 ..
455 Pic
.End_Currency
) := Currency_Symbol
;
458 Answer
(Pic
.Start_Currency
.. Pic
.End_Currency
) :=
460 Answer
(Pic
.Start_Currency
..
461 Pic
.Start_Currency
+ Currency_Symbol
'Length - 1) :=
466 -- Fill in leading digits
468 if Attrs
.End_Of_Int
- Attrs
.Start_Of_Int
+ 1 >
469 Pic
.Max_Leading_Digits
475 (if Pic
.Radix_Position
= Invalid_Position
then Answer
'Last
476 else Pic
.Radix_Position
- 1);
478 for J
in reverse Attrs
.Start_Of_Int
.. Attrs
.End_Of_Int
loop
479 while Answer
(Position
) /= '9'
481 Answer
(Position
) /= Pic
.Floater
483 if Answer
(Position
) = '_' then
484 Answer
(Position
) := Separator_Character
;
485 elsif Answer
(Position
) = 'b' then
486 Answer
(Position
) := ' ';
489 Position
:= Position
- 1;
492 Answer
(Position
) := To_Wide
(Rounded
(J
));
494 if Rounded
(J
) /= '0' then
498 Position
:= Position
- 1;
503 if Pic
.Start_Float
= Invalid_Position
then
505 -- No leading floats, but need to change '9' to '0', '_' to
506 -- Separator_Character and 'b' to ' '.
508 for J
in Last
.. Position
loop
510 -- Last set when fixing the "uninteresting" leaders above.
511 -- Don't duplicate the work.
513 if Answer
(J
) = '9' then
516 elsif Answer
(J
) = '_' then
517 Answer
(J
) := Separator_Character
;
519 elsif Answer
(J
) = 'b' then
526 elsif Pic
.Floater
= '<'
532 for J
in Pic
.End_Float
.. Position
loop -- May be null range
533 if Answer
(J
) = '9' then
536 elsif Answer
(J
) = '_' then
537 Answer
(J
) := Separator_Character
;
539 elsif Answer
(J
) = 'b' then
545 if Position
> Pic
.End_Float
then
546 Position
:= Pic
.End_Float
;
549 for J
in Pic
.Start_Float
.. Position
- 1 loop
553 Answer
(Position
) := Pic
.Floater
;
554 Sign_Position
:= Position
;
556 elsif Pic
.Floater
= '$' then
558 for J
in Pic
.End_Float
.. Position
loop -- May be null range
559 if Answer
(J
) = '9' then
562 elsif Answer
(J
) = '_' then
563 Answer
(J
) := ' '; -- no separator before leftmost digit
565 elsif Answer
(J
) = 'b' then
570 if Position
> Pic
.End_Float
then
571 Position
:= Pic
.End_Float
;
574 for J
in Pic
.Start_Float
.. Position
- 1 loop
578 Answer
(Position
) := Pic
.Floater
;
579 Currency_Pos
:= Position
;
581 elsif Pic
.Floater
= '*' then
583 for J
in Pic
.End_Float
.. Position
loop -- May be null range
584 if Answer
(J
) = '9' then
587 elsif Answer
(J
) = '_' then
588 Answer
(J
) := Separator_Character
;
590 elsif Answer
(J
) = 'b' then
595 if Position
> Pic
.End_Float
then
596 Position
:= Pic
.End_Float
;
599 for J
in Pic
.Start_Float
.. Position
loop
604 if Pic
.Floater
= '#' then
605 Currency_Pos
:= Currency_Symbol
'Length;
608 for J
in reverse Pic
.Start_Float
.. Position
loop
611 Answer
(J
) := Fill_Character
;
613 when 'Z' |
'b' |
'/' |
'0' =>
619 when '.' |
'V' |
'v' |
'<' |
'$' |
'+' |
'-' =>
623 if Currency_Pos
= 0 then
626 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
627 Currency_Pos
:= Currency_Pos
- 1;
633 Answer
(J
) := Fill_Character
;
639 if Currency_Pos
= 0 then
643 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
644 Currency_Pos
:= Currency_Pos
- 1;
656 if Pic
.Floater
= '#' and then Currency_Pos
/= 0 then
663 if Sign_Position
= Invalid_Position
then
664 if Attrs
.Negative
then
669 if Attrs
.Negative
then
670 case Answer
(Sign_Position
) is
671 when 'C' |
'D' |
'-' =>
675 Answer
(Sign_Position
) := '-';
678 Answer
(Sign_Position
) := '(';
679 Answer
(Pic
.Second_Sign
) := ')';
687 case Answer
(Sign_Position
) is
689 Answer
(Sign_Position
) := ' ';
691 when '<' |
'C' |
'D' =>
692 Answer
(Sign_Position
) := ' ';
693 Answer
(Pic
.Second_Sign
) := ' ';
704 -- Fill in trailing digits
706 if Pic
.Max_Trailing_Digits
> 0 then
708 if Attrs
.Has_Fraction
then
709 Position
:= Attrs
.Start_Of_Fraction
;
710 Last
:= Pic
.Radix_Position
+ 1;
712 for J
in Last
.. Answer
'Last loop
713 if Answer
(J
) = '9' or else Answer
(J
) = Pic
.Floater
then
714 Answer
(J
) := To_Wide
(Rounded
(Position
));
716 if Rounded
(Position
) /= '0' then
720 Position
:= Position
+ 1;
723 -- Used up fraction but remember place in Answer
725 exit when Position
> Attrs
.End_Of_Fraction
;
727 elsif Answer
(J
) = 'b' then
730 elsif Answer
(J
) = '_' then
731 Answer
(J
) := Separator_Character
;
741 Position
:= Pic
.Radix_Position
+ 1;
744 -- Now fill remaining 9's with zeros and _ with separators
748 for J
in Position
.. Last
loop
749 if Answer
(J
) = '9' then
752 elsif Answer
(J
) = Pic
.Floater
then
755 elsif Answer
(J
) = '_' then
756 Answer
(J
) := Separator_Character
;
758 elsif Answer
(J
) = 'b' then
764 Position
:= Last
+ 1;
767 if Pic
.Floater
= '#' and then Currency_Pos
/= 0 then
771 -- No trailing digits, but now J may need to stick in a currency
775 (if Pic
.Start_Currency
= Invalid_Position
then Answer
'Last + 1
776 else Pic
.Start_Currency
);
779 for J
in Position
.. Answer
'Last loop
780 if Pic
.Start_Currency
/= Invalid_Position
781 and then Answer
(Pic
.Start_Currency
) = '#'
786 -- Note: There are some weird cases J can imagine with 'b' or '#' in
787 -- currency strings where the following code will cause glitches. The
788 -- trick is to tell when the character in the answer should be
789 -- checked, and when to look at the original string. Some other time.
794 Answer
(J
) := Fill_Character
;
800 if Currency_Pos
> Currency_Symbol
'Length then
804 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
805 Currency_Pos
:= Currency_Pos
+ 1;
812 Answer
(J
) := Fill_Character
;
818 if Currency_Pos
> Currency_Symbol
'Length then
821 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
822 Currency_Pos
:= Currency_Pos
+ 1;
834 -- Now get rid of Blank_when_Zero and complete Star fill
836 if Zero
and then Pic
.Blank_When_Zero
then
838 -- Value is zero, and blank it
843 Last
:= Last
- 1 + Currency_Symbol
'Length;
846 if Pic
.Radix_Position
/= Invalid_Position
847 and then Answer
(Pic
.Radix_Position
) = 'V'
852 return Wide_String'(1 .. Last => ' ');
854 elsif Zero and then Pic.Star_Fill then
858 Last := Last - 1 + Currency_Symbol'Length;
861 if Pic.Radix_Position /= Invalid_Position then
863 if Answer (Pic.Radix_Position) = 'V
' then
867 if Pic.Radix_Position > Pic.Start_Currency then
868 return Wide_String'(1 .. Pic
.Radix_Position
- 1 => '*') &
870 Wide_String'(Pic.Radix_Position + 1 .. Last => '*');
876 Pic
.Radix_Position
+ Currency_Symbol
'Length - 2
880 (Pic.Radix_Position + Currency_Symbol'Length .. Last
886 Wide_String'(1 .. Pic
.Radix_Position
- 1 => '*') &
888 Wide_String'(Pic.Radix_Position + 1 .. Last => '*');
892 return Wide_String'(1 .. Last
=> '*');
895 -- This was once a simple return statement, now there are nine
896 -- different return cases. Not to mention the five above to deal
897 -- with zeros. Why not split things out?
899 -- Processing the radix and sign expansion separately would require
900 -- lots of copying--the string and some of its indexes--without
901 -- really simplifying the logic. The cases are:
903 -- 1) Expand $, replace '.' with Radix_Point
904 -- 2) No currency expansion, replace '.' with Radix_Point
905 -- 3) Expand $, radix blanked
906 -- 4) No currency expansion, radix blanked
908 -- 6) Expand $, Elide V
909 -- 7) Elide V, Expand $ (Two cases depending on order.)
910 -- 8) No radix, expand $
911 -- 9) No radix, no currency expansion
913 if Pic
.Radix_Position
/= Invalid_Position
then
915 if Answer
(Pic
.Radix_Position
) = '.' then
916 Answer
(Pic
.Radix_Position
) := Radix_Point
;
920 -- 1) Expand $, replace '.' with Radix_Point
923 Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
924 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
927 -- 2) No currency expansion, replace '.' with Radix_Point
932 elsif Answer
(Pic
.Radix_Position
) = ' ' then -- blanked radix.
935 -- 3) Expand $, radix blanked
937 return Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
938 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
941 -- 4) No expansion, radix blanked
953 return Answer
(1 .. Pic
.Radix_Position
- 1) &
954 Answer
(Pic
.Radix_Position
+ 1 .. Answer
'Last);
956 elsif Currency_Pos
< Pic
.Radix_Position
then
958 -- 6) Expand $, Elide V
960 return Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
961 Answer
(Currency_Pos
+ 1 .. Pic
.Radix_Position
- 1) &
962 Answer
(Pic
.Radix_Position
+ 1 .. Answer
'Last);
965 -- 7) Elide V, Expand $
967 return Answer
(1 .. Pic
.Radix_Position
- 1) &
968 Answer
(Pic
.Radix_Position
+ 1 .. Currency_Pos
- 1) &
970 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
976 -- 8) No radix, expand $
978 return Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
979 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
982 -- 9) No radix, no currency expansion
988 -------------------------
989 -- Parse_Number_String --
990 -------------------------
992 function Parse_Number_String
(Str
: String) return Number_Attributes
is
993 Answer
: Number_Attributes
;
996 for J
in Str
'Range loop
1003 -- Decide if this is the start of a number.
1004 -- If so, figure out which one...
1006 if Answer
.Has_Fraction
then
1007 Answer
.End_Of_Fraction
:= J
;
1009 if Answer
.Start_Of_Int
= Invalid_Position
then
1011 Answer
.Start_Of_Int
:= J
;
1013 Answer
.End_Of_Int
:= J
;
1018 -- Only count a zero before the decimal point if it follows a
1019 -- non-zero digit. After the decimal point, zeros will be
1020 -- counted if followed by a non-zero digit.
1022 if not Answer
.Has_Fraction
then
1023 if Answer
.Start_Of_Int
/= Invalid_Position
then
1024 Answer
.End_Of_Int
:= J
;
1032 Answer
.Negative
:= True;
1036 -- Close integer, start fraction
1038 if Answer
.Has_Fraction
then
1039 raise Picture_Error
;
1042 -- Two decimal points is a no-no
1044 Answer
.Has_Fraction
:= True;
1045 Answer
.End_Of_Fraction
:= J
;
1047 -- Could leave this at Invalid_Position, but this seems the
1048 -- right way to indicate a null range...
1050 Answer
.Start_Of_Fraction
:= J
+ 1;
1051 Answer
.End_Of_Int
:= J
- 1;
1054 raise Picture_Error
; -- can this happen? probably not
1058 if Answer
.Start_Of_Int
= Invalid_Position
then
1059 Answer
.Start_Of_Int
:= Answer
.End_Of_Int
+ 1;
1062 -- No significant (intger) digits needs a null range
1065 end Parse_Number_String
;
1071 -- The following ensures that we return B and not b being careful not
1072 -- to break things which expect lower case b for blank. See CXF3A02.
1074 function Pic_String
(Pic
: Picture
) return String is
1075 Temp
: String (1 .. Pic
.Contents
.Picture
.Length
) :=
1076 Pic
.Contents
.Picture
.Expanded
;
1078 for J
in Temp
'Range loop
1079 if Temp
(J
) = 'b' then
1091 procedure Precalculate
(Pic
: in out Format_Record
) is
1093 Computed_BWZ
: Boolean := True;
1095 type Legality
is (Okay
, Reject
);
1096 State
: Legality
:= Reject
;
1097 -- Start in reject, which will reject null strings
1099 Index
: Pic_Index
:= Pic
.Picture
.Expanded
'First;
1101 function At_End
return Boolean;
1102 pragma Inline
(At_End
);
1104 procedure Set_State
(L
: Legality
);
1105 pragma Inline
(Set_State
);
1107 function Look
return Character;
1108 pragma Inline
(Look
);
1110 function Is_Insert
return Boolean;
1111 pragma Inline
(Is_Insert
);
1114 pragma Inline
(Skip
);
1116 procedure Trailing_Currency
;
1117 procedure Trailing_Bracket
;
1118 procedure Number_Fraction
;
1119 procedure Number_Completion
;
1120 procedure Number_Fraction_Or_Bracket
;
1121 procedure Number_Fraction_Or_Z_Fill
;
1122 procedure Zero_Suppression
;
1123 procedure Floating_Bracket
;
1124 procedure Number_Fraction_Or_Star_Fill
;
1125 procedure Star_Suppression
;
1126 procedure Number_Fraction_Or_Dollar
;
1127 procedure Leading_Dollar
;
1128 procedure Number_Fraction_Or_Pound
;
1129 procedure Leading_Pound
;
1131 procedure Floating_Plus
;
1132 procedure Floating_Minus
;
1133 procedure Picture_Plus
;
1134 procedure Picture_Minus
;
1135 procedure Picture_Bracket
;
1137 procedure Optional_RHS_Sign
;
1138 procedure Picture_String
;
1144 function At_End
return Boolean is
1146 return Index
> Pic
.Picture
.Length
;
1149 ----------------------
1150 -- Floating_Bracket --
1151 ----------------------
1153 -- Note that Floating_Bracket is only called with an acceptable
1154 -- prefix. But we don't set Okay, because we must end with a '>'.
1156 procedure Floating_Bracket
is
1159 Pic
.End_Float
:= Index
;
1160 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1162 -- First bracket wasn't counted...
1172 when '_' |
'0' |
'/' =>
1173 Pic
.End_Float
:= Index
;
1177 Pic
.End_Float
:= Index
;
1178 Pic
.Picture
.Expanded
(Index
) := 'b';
1182 Pic
.End_Float
:= Index
;
1183 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1195 when 'V' |
'v' |
'.' =>
1196 Pic
.Radix_Position
:= Index
;
1198 Number_Fraction_Or_Bracket
;
1205 end Floating_Bracket
;
1207 --------------------
1208 -- Floating_Minus --
1209 --------------------
1211 procedure Floating_Minus
is
1219 when '_' |
'0' |
'/' =>
1220 Pic
.End_Float
:= Index
;
1224 Pic
.End_Float
:= Index
;
1225 Pic
.Picture
.Expanded
(Index
) := 'b';
1229 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1230 Pic
.End_Float
:= Index
;
1237 when '.' |
'V' |
'v' =>
1238 Pic
.Radix_Position
:= Index
;
1241 while Is_Insert
loop
1257 Pic
.Max_Trailing_Digits
:=
1258 Pic
.Max_Trailing_Digits
+ 1;
1259 Pic
.End_Float
:= Index
;
1262 when '_' |
'0' |
'/' =>
1266 Pic
.Picture
.Expanded
(Index
) := 'b';
1290 procedure Floating_Plus
is
1298 when '_' |
'0' |
'/' =>
1299 Pic
.End_Float
:= Index
;
1303 Pic
.End_Float
:= Index
;
1304 Pic
.Picture
.Expanded
(Index
) := 'b';
1308 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1309 Pic
.End_Float
:= Index
;
1316 when '.' |
'V' |
'v' =>
1317 Pic
.Radix_Position
:= Index
;
1320 while Is_Insert
loop
1336 Pic
.Max_Trailing_Digits
:=
1337 Pic
.Max_Trailing_Digits
+ 1;
1338 Pic
.End_Float
:= Index
;
1341 when '_' |
'0' |
'/' =>
1345 Pic
.Picture
.Expanded
(Index
) := 'b';
1369 function Is_Insert
return Boolean is
1375 case Pic
.Picture
.Expanded
(Index
) is
1376 when '_' |
'0' |
'/' =>
1380 Pic
.Picture
.Expanded
(Index
) := 'b'; -- canonical
1388 --------------------
1389 -- Leading_Dollar --
1390 --------------------
1392 -- Note that Leading_Dollar can be called in either State.
1393 -- It will set state to Okay only if a 9 or (second) $ is encountered.
1395 -- Also notice the tricky bit with State and Zero_Suppression.
1396 -- Zero_Suppression is Picture_Error if a '$' or a '9' has been
1397 -- encountered, exactly the cases where State has been set.
1399 procedure Leading_Dollar
is
1401 -- Treat as a floating dollar, and unwind otherwise
1404 Pic
.Start_Currency
:= Index
;
1405 Pic
.End_Currency
:= Index
;
1406 Pic
.Start_Float
:= Index
;
1407 Pic
.End_Float
:= Index
;
1409 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
1420 when '_' |
'0' |
'/' =>
1421 Pic
.End_Float
:= Index
;
1424 -- A trailing insertion character is not part of the
1425 -- floating currency, so need to look ahead.
1428 Pic
.End_Float
:= Pic
.End_Float
- 1;
1432 Pic
.End_Float
:= Index
;
1433 Pic
.Picture
.Expanded
(Index
) := 'b';
1437 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
1439 if State
= Okay
then
1440 raise Picture_Error
;
1442 -- Will overwrite Floater and Start_Float
1448 if State
= Okay
then
1449 raise Picture_Error
;
1451 -- Will overwrite Floater and Start_Float
1457 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1458 Pic
.End_Float
:= Index
;
1459 Pic
.End_Currency
:= Index
;
1460 Set_State
(Okay
); Skip
;
1463 if State
/= Okay
then
1465 Pic
.Start_Float
:= Invalid_Position
;
1466 Pic
.End_Float
:= Invalid_Position
;
1469 -- A single dollar does not a floating make
1474 when 'V' |
'v' |
'.' =>
1475 if State
/= Okay
then
1477 Pic
.Start_Float
:= Invalid_Position
;
1478 Pic
.End_Float
:= Invalid_Position
;
1481 -- Only one dollar before the sign is okay, but doesn't
1484 Pic
.Radix_Position
:= Index
;
1486 Number_Fraction_Or_Dollar
;
1499 -- This one is complex. A Leading_Pound can be fixed or floating,
1500 -- but in some cases the decision has to be deferred until we leave
1501 -- this procedure. Also note that Leading_Pound can be called in
1504 -- It will set state to Okay only if a 9 or (second) # is
1507 -- One Last note: In ambiguous cases, the currency is treated as
1508 -- floating unless there is only one '#'.
1510 procedure Leading_Pound
is
1512 Inserts
: Boolean := False;
1513 -- Set to True if a '_', '0', '/', 'B', or 'b' is encountered
1515 Must_Float
: Boolean := False;
1516 -- Set to true if a '#' occurs after an insert
1519 -- Treat as a floating currency. If it isn't, this will be
1520 -- overwritten later.
1524 Pic
.Start_Currency
:= Index
;
1525 Pic
.End_Currency
:= Index
;
1526 Pic
.Start_Float
:= Index
;
1527 Pic
.End_Float
:= Index
;
1529 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
1532 Pic
.Max_Currency_Digits
:= 1; -- we've seen one.
1542 when '_' |
'0' |
'/' =>
1543 Pic
.End_Float
:= Index
;
1548 Pic
.Picture
.Expanded
(Index
) := 'b';
1549 Pic
.End_Float
:= Index
;
1554 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
1557 raise Picture_Error
;
1559 Pic
.Max_Leading_Digits
:= 0;
1561 -- Will overwrite Floater and Start_Float
1568 raise Picture_Error
;
1570 Pic
.Max_Leading_Digits
:= 0;
1572 -- Will overwrite Floater and Start_Float
1582 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1583 Pic
.End_Float
:= Index
;
1584 Pic
.End_Currency
:= Index
;
1589 if State
/= Okay
then
1591 -- A single '#' doesn't float
1594 Pic
.Start_Float
:= Invalid_Position
;
1595 Pic
.End_Float
:= Invalid_Position
;
1601 when 'V' |
'v' |
'.' =>
1602 if State
/= Okay
then
1604 Pic
.Start_Float
:= Invalid_Position
;
1605 Pic
.End_Float
:= Invalid_Position
;
1608 -- Only one pound before the sign is okay, but doesn't
1611 Pic
.Radix_Position
:= Index
;
1613 Number_Fraction_Or_Pound
;
1626 function Look
return Character is
1629 raise Picture_Error
;
1632 return Pic
.Picture
.Expanded
(Index
);
1643 when '_' |
'0' |
'/' =>
1647 Pic
.Picture
.Expanded
(Index
) := 'b';
1651 Computed_BWZ
:= False;
1652 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1656 when '.' |
'V' |
'v' =>
1657 Pic
.Radix_Position
:= Index
;
1670 -- Will return in Okay state if a '9' was seen
1675 -----------------------
1676 -- Number_Completion --
1677 -----------------------
1679 procedure Number_Completion
is
1681 while not At_End
loop
1683 when '_' |
'0' |
'/' =>
1687 Pic
.Picture
.Expanded
(Index
) := 'b';
1691 Computed_BWZ
:= False;
1692 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1696 when 'V' |
'v' |
'.' =>
1697 Pic
.Radix_Position
:= Index
;
1706 end Number_Completion
;
1708 ---------------------
1709 -- Number_Fraction --
1710 ---------------------
1712 procedure Number_Fraction
is
1714 -- Note that number fraction can be called in either State.
1715 -- It will set state to Valid only if a 9 is encountered.
1723 when '_' |
'0' |
'/' =>
1727 Pic
.Picture
.Expanded
(Index
) := 'b';
1731 Computed_BWZ
:= False;
1732 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1733 Set_State
(Okay
); Skip
;
1739 end Number_Fraction
;
1741 --------------------------------
1742 -- Number_Fraction_Or_Bracket --
1743 --------------------------------
1745 procedure Number_Fraction_Or_Bracket
is
1753 when '_' |
'0' |
'/' =>
1757 Pic
.Picture
.Expanded
(Index
) := 'b';
1761 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1762 Pic
.End_Float
:= Index
;
1771 when '_' |
'0' |
'/' =>
1775 Pic
.Picture
.Expanded
(Index
) := 'b';
1779 Pic
.Max_Trailing_Digits
:=
1780 Pic
.Max_Trailing_Digits
+ 1;
1781 Pic
.End_Float
:= Index
;
1794 end Number_Fraction_Or_Bracket
;
1796 -------------------------------
1797 -- Number_Fraction_Or_Dollar --
1798 -------------------------------
1800 procedure Number_Fraction_Or_Dollar
is
1808 when '_' |
'0' |
'/' =>
1812 Pic
.Picture
.Expanded
(Index
) := 'b';
1816 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1817 Pic
.End_Float
:= Index
;
1826 when '_' |
'0' |
'/' =>
1830 Pic
.Picture
.Expanded
(Index
) := 'b';
1834 Pic
.Max_Trailing_Digits
:=
1835 Pic
.Max_Trailing_Digits
+ 1;
1836 Pic
.End_Float
:= Index
;
1849 end Number_Fraction_Or_Dollar
;
1851 ------------------------------
1852 -- Number_Fraction_Or_Pound --
1853 ------------------------------
1855 procedure Number_Fraction_Or_Pound
is
1863 when '_' |
'0' |
'/' =>
1867 Pic
.Picture
.Expanded
(Index
) := 'b';
1871 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1872 Pic
.End_Float
:= Index
;
1881 when '_' |
'0' |
'/' =>
1885 Pic
.Picture
.Expanded
(Index
) := 'b';
1889 Pic
.Max_Trailing_Digits
:=
1890 Pic
.Max_Trailing_Digits
+ 1;
1891 Pic
.End_Float
:= Index
;
1904 end Number_Fraction_Or_Pound
;
1906 ----------------------------------
1907 -- Number_Fraction_Or_Star_Fill --
1908 ----------------------------------
1910 procedure Number_Fraction_Or_Star_Fill
is
1918 when '_' |
'0' |
'/' =>
1922 Pic
.Picture
.Expanded
(Index
) := 'b';
1926 Pic
.Star_Fill
:= True;
1927 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1928 Pic
.End_Float
:= Index
;
1937 when '_' |
'0' |
'/' =>
1941 Pic
.Picture
.Expanded
(Index
) := 'b';
1945 Pic
.Star_Fill
:= True;
1946 Pic
.Max_Trailing_Digits
:=
1947 Pic
.Max_Trailing_Digits
+ 1;
1948 Pic
.End_Float
:= Index
;
1961 end Number_Fraction_Or_Star_Fill
;
1963 -------------------------------
1964 -- Number_Fraction_Or_Z_Fill --
1965 -------------------------------
1967 procedure Number_Fraction_Or_Z_Fill
is
1975 when '_' |
'0' |
'/' =>
1979 Pic
.Picture
.Expanded
(Index
) := 'b';
1983 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1984 Pic
.End_Float
:= Index
;
1985 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
1995 when '_' |
'0' |
'/' =>
1999 Pic
.Picture
.Expanded
(Index
) := 'b';
2003 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2005 Pic
.Max_Trailing_Digits
:=
2006 Pic
.Max_Trailing_Digits
+ 1;
2007 Pic
.End_Float
:= Index
;
2020 end Number_Fraction_Or_Z_Fill
;
2022 -----------------------
2023 -- Optional_RHS_Sign --
2024 -----------------------
2026 procedure Optional_RHS_Sign
is
2034 Pic
.Sign_Position
:= Index
;
2039 Pic
.Sign_Position
:= Index
;
2040 Pic
.Picture
.Expanded
(Index
) := 'C';
2043 if Look
= 'R' or else Look
= 'r' then
2044 Pic
.Second_Sign
:= Index
;
2045 Pic
.Picture
.Expanded
(Index
) := 'R';
2049 raise Picture_Error
;
2055 Pic
.Sign_Position
:= Index
;
2056 Pic
.Picture
.Expanded
(Index
) := 'D';
2059 if Look
= 'B' or else Look
= 'b' then
2060 Pic
.Second_Sign
:= Index
;
2061 Pic
.Picture
.Expanded
(Index
) := 'B';
2065 raise Picture_Error
;
2071 if Pic
.Picture
.Expanded
(Pic
.Sign_Position
) = '<' then
2072 Pic
.Second_Sign
:= Index
;
2076 raise Picture_Error
;
2082 end Optional_RHS_Sign
;
2088 -- Note that Picture can be called in either State
2090 -- It will set state to Valid only if a 9 is encountered or floating
2091 -- currency is called.
2093 procedure Picture
is
2101 when '_' |
'0' |
'/' =>
2105 Pic
.Picture
.Expanded
(Index
) := 'b';
2117 Computed_BWZ
:= False;
2119 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2122 when 'V' |
'v' |
'.' =>
2123 Pic
.Radix_Position
:= Index
;
2135 ---------------------
2136 -- Picture_Bracket --
2137 ---------------------
2139 procedure Picture_Bracket
is
2141 Pic
.Sign_Position
:= Index
;
2142 Pic
.Sign_Position
:= Index
;
2144 -- Treat as a floating sign, and unwind otherwise
2147 Pic
.Start_Float
:= Index
;
2148 Pic
.End_Float
:= Index
;
2150 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
2153 Skip
; -- Known Bracket
2157 when '_' |
'0' |
'/' =>
2158 Pic
.End_Float
:= Index
;
2162 Pic
.End_Float
:= Index
;
2163 Pic
.Picture
.Expanded
(Index
) := 'b';
2167 Set_State
(Okay
); -- "<<>" is enough.
2173 when '$' |
'#' |
'9' |
'*' =>
2174 if State
/= Okay
then
2176 Pic
.Start_Float
:= Invalid_Position
;
2177 Pic
.End_Float
:= Invalid_Position
;
2185 when '.' |
'V' |
'v' =>
2186 if State
/= Okay
then
2188 Pic
.Start_Float
:= Invalid_Position
;
2189 Pic
.End_Float
:= Invalid_Position
;
2192 -- Don't assume that state is okay, haven't seen a digit
2199 raise Picture_Error
;
2202 end Picture_Bracket
;
2208 procedure Picture_Minus
is
2210 Pic
.Sign_Position
:= Index
;
2212 -- Treat as a floating sign, and unwind otherwise
2215 Pic
.Start_Float
:= Index
;
2216 Pic
.End_Float
:= Index
;
2218 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
2221 Skip
; -- Known Minus
2225 when '_' |
'0' |
'/' =>
2226 Pic
.End_Float
:= Index
;
2230 Pic
.End_Float
:= Index
;
2231 Pic
.Picture
.Expanded
(Index
) := 'b';
2235 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2236 Pic
.End_Float
:= Index
;
2238 Set_State
(Okay
); -- "-- " is enough
2243 when '$' |
'#' |
'9' |
'*' =>
2244 if State
/= Okay
then
2246 Pic
.Start_Float
:= Invalid_Position
;
2247 Pic
.End_Float
:= Invalid_Position
;
2256 -- Can't have Z and a floating sign
2258 if State
= Okay
then
2262 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2268 when '.' |
'V' |
'v' =>
2269 if State
/= Okay
then
2271 Pic
.Start_Float
:= Invalid_Position
;
2272 Pic
.End_Float
:= Invalid_Position
;
2275 -- Don't assume that state is okay, haven't seen a digit
2290 procedure Picture_Plus
is
2292 Pic
.Sign_Position
:= Index
;
2294 -- Treat as a floating sign, and unwind otherwise
2297 Pic
.Start_Float
:= Index
;
2298 Pic
.End_Float
:= Index
;
2300 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
2307 when '_' |
'0' |
'/' =>
2308 Pic
.End_Float
:= Index
;
2312 Pic
.End_Float
:= Index
;
2313 Pic
.Picture
.Expanded
(Index
) := 'b';
2317 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2318 Pic
.End_Float
:= Index
;
2320 Set_State
(Okay
); -- "++" is enough
2325 when '$' |
'#' |
'9' |
'*' =>
2326 if State
/= Okay
then
2328 Pic
.Start_Float
:= Invalid_Position
;
2329 Pic
.End_Float
:= Invalid_Position
;
2337 if State
= Okay
then
2341 -- Can't have Z and a floating sign
2343 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2345 -- '+Z' is acceptable
2354 when '.' |
'V' |
'v' =>
2355 if State
/= Okay
then
2357 Pic
.Start_Float
:= Invalid_Position
;
2358 Pic
.End_Float
:= Invalid_Position
;
2361 -- Don't assume that state is okay, haven't seen a digit
2372 --------------------
2373 -- Picture_String --
2374 --------------------
2376 procedure Picture_String
is
2378 while Is_Insert
loop
2397 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2407 when '9' |
'.' |
'V' |
'v' =>
2413 raise Picture_Error
;
2416 -- Blank when zero either if the PIC does not contain a '9' or if
2417 -- requested by the user and no '*'.
2419 Pic
.Blank_When_Zero
:=
2420 (Computed_BWZ
or else Pic
.Blank_When_Zero
)
2421 and then not Pic
.Star_Fill
;
2423 -- Star fill if '*' and no '9'
2425 Pic
.Star_Fill
:= Pic
.Star_Fill
and then Computed_BWZ
;
2436 procedure Set_State
(L
: Legality
) is
2450 ----------------------
2451 -- Star_Suppression --
2452 ----------------------
2454 procedure Star_Suppression
is
2457 Pic
.Start_Float
:= Index
;
2458 Pic
.End_Float
:= Index
;
2459 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2462 -- Even a single * is a valid picture
2464 Pic
.Star_Fill
:= True;
2473 when '_' |
'0' |
'/' =>
2474 Pic
.End_Float
:= Index
;
2478 Pic
.End_Float
:= Index
;
2479 Pic
.Picture
.Expanded
(Index
) := 'b';
2483 Pic
.End_Float
:= Index
;
2484 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2485 Set_State
(Okay
); Skip
;
2492 when '.' |
'V' |
'v' =>
2493 Pic
.Radix_Position
:= Index
;
2495 Number_Fraction_Or_Star_Fill
;
2504 raise Picture_Error
;
2507 end Star_Suppression
;
2509 ----------------------
2510 -- Trailing_Bracket --
2511 ----------------------
2513 procedure Trailing_Bracket
is
2516 Pic
.Second_Sign
:= Index
;
2519 raise Picture_Error
;
2521 end Trailing_Bracket
;
2523 -----------------------
2524 -- Trailing_Currency --
2525 -----------------------
2527 procedure Trailing_Currency
is
2534 Pic
.Start_Currency
:= Index
;
2535 Pic
.End_Currency
:= Index
;
2539 while not At_End
and then Look
= '#' loop
2540 if Pic
.Start_Currency
= Invalid_Position
then
2541 Pic
.Start_Currency
:= Index
;
2544 Pic
.End_Currency
:= Index
;
2555 when '_' |
'0' |
'/' =>
2559 Pic
.Picture
.Expanded
(Index
) := 'b';
2566 end Trailing_Currency
;
2568 ----------------------
2569 -- Zero_Suppression --
2570 ----------------------
2572 procedure Zero_Suppression
is
2575 Pic
.Start_Float
:= Index
;
2576 Pic
.End_Float
:= Index
;
2577 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2578 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2583 -- Even a single Z is a valid picture
2591 when '_' |
'0' |
'/' =>
2592 Pic
.End_Float
:= Index
;
2596 Pic
.End_Float
:= Index
;
2597 Pic
.Picture
.Expanded
(Index
) := 'b';
2601 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2603 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2604 Pic
.End_Float
:= Index
;
2613 when '.' |
'V' |
'v' =>
2614 Pic
.Radix_Position
:= Index
;
2616 Number_Fraction_Or_Z_Fill
;
2628 end Zero_Suppression
;
2630 -- Start of processing for Precalculate
2635 if State
= Reject
then
2636 raise Picture_Error
;
2641 when Constraint_Error
=>
2643 -- To deal with special cases like null strings
2645 raise Picture_Error
;
2653 (Pic_String
: String;
2654 Blank_When_Zero
: Boolean := False) return Picture
2660 Item
: constant String := Expand
(Pic_String
);
2663 Result
.Contents
.Picture
:= (Item
'Length, Item
);
2664 Result
.Contents
.Original_BWZ
:= Blank_When_Zero
;
2665 Result
.Contents
.Blank_When_Zero
:= Blank_When_Zero
;
2666 Precalculate
(Result
.Contents
);
2672 raise Picture_Error
;
2680 function To_Wide
(C
: Character) return Wide_Character is
2682 return Wide_Character'Val (Character'Pos (C
));
2690 (Pic_String
: String;
2691 Blank_When_Zero
: Boolean := False) return Boolean
2695 Expanded_Pic
: constant String := Expand
(Pic_String
);
2696 -- Raises Picture_Error if Item not well-formed
2698 Format_Rec
: Format_Record
;
2701 Format_Rec
.Picture
:= (Expanded_Pic
'Length, Expanded_Pic
);
2702 Format_Rec
.Blank_When_Zero
:= Blank_When_Zero
;
2703 Format_Rec
.Original_BWZ
:= Blank_When_Zero
;
2704 Precalculate
(Format_Rec
);
2706 -- False only if Blank_When_0 is True but the pic string has a '*'
2708 return not Blank_When_Zero
2709 or else Strings_Fixed
.Index
(Expanded_Pic
, "*") = 0;
2713 when others => return False;
2716 end Ada
.Wide_Text_IO
.Editing
;