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-2018, 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
216 -- We now need to scan out the count after a left paren. In
217 -- the non-wide version we used Integer_IO.Get, but that is
218 -- not convenient here, since we don't want to drag in normal
219 -- Text_IO just for this purpose. So we do the scan ourselves,
220 -- with the normal validity checks.
222 Last
:= Picture_Index
+ 1;
225 if Picture
(Last
) not in '0' .. '9' then
229 Count
:= Character'Pos (Picture
(Last
)) - Character'Pos ('0');
233 if Last
> Picture
'Last then
237 if Picture
(Last
) = '_' then
238 if Picture
(Last
- 1) = '_' then
242 elsif Picture
(Last
) = ')' then
245 elsif Picture
(Last
) not in '0' .. '9' then
250 + Character'Pos (Picture
(Last
)) -
257 -- In what follows note that one copy of the repeated
258 -- character has already been made, so a count of one is
259 -- no-op, and a count of zero erases a character.
261 for J
in 2 .. Count
loop
262 Result
(Result_Index
+ J
- 2) := Picture
(Picture_Index
- 1);
265 Result_Index
:= Result_Index
+ Count
- 1;
267 -- Last was a ')' throw it away too
269 Picture_Index
:= Last
+ 1;
275 Result
(Result_Index
) := Picture
(Picture_Index
);
276 Picture_Index
:= Picture_Index
+ 1;
277 Result_Index
:= Result_Index
+ 1;
280 exit when Picture_Index
> Picture
'Last;
283 return Result
(1 .. Result_Index
- 1);
294 function Format_Number
295 (Pic
: Format_Record
;
297 Currency_Symbol
: Wide_Wide_String
;
298 Fill_Character
: Wide_Wide_Character
;
299 Separator_Character
: Wide_Wide_Character
;
300 Radix_Point
: Wide_Wide_Character
) return Wide_Wide_String
302 Attrs
: Number_Attributes
:= Parse_Number_String
(Number
);
304 Rounded
: String := Number
;
306 Sign_Position
: Integer := Pic
.Sign_Position
; -- may float.
308 Answer
: Wide_Wide_String
(1 .. Pic
.Picture
.Length
);
310 Currency_Pos
: Integer := Pic
.Start_Currency
;
312 Dollar
: Boolean := False;
313 -- Overridden immediately if necessary
315 Zero
: Boolean := True;
316 -- Set to False when a non-zero digit is output
320 -- If the picture has fewer decimal places than the number, the image
321 -- must be rounded according to the usual rules.
323 if Attrs
.Has_Fraction
then
325 R
: constant Integer :=
326 (Attrs
.End_Of_Fraction
- Attrs
.Start_Of_Fraction
+ 1)
327 - Pic
.Max_Trailing_Digits
;
332 R_Pos
:= Rounded
'Length - R
;
334 if Rounded
(R_Pos
+ 1) > '4' then
336 if Rounded
(R_Pos
) = '.' then
340 if Rounded
(R_Pos
) /= '9' then
341 Rounded
(R_Pos
) := Character'Succ (Rounded
(R_Pos
));
343 Rounded
(R_Pos
) := '0';
347 if Rounded
(R_Pos
) = '.' then
351 if Rounded
(R_Pos
) /= '9' then
352 Rounded
(R_Pos
) := Character'Succ (Rounded
(R_Pos
));
355 Rounded
(R_Pos
) := '0';
360 -- The rounding may add a digit in front. Either the
361 -- leading blank or the sign (already captured) can be
365 Rounded
(R_Pos
) := '1';
366 Attrs
.Start_Of_Int
:= Attrs
.Start_Of_Int
- 1;
374 for J
in Answer
'Range loop
375 Answer
(J
) := To_Wide
(Pic
.Picture
.Expanded
(J
));
378 if Pic
.Start_Currency
/= Invalid_Position
then
379 Dollar
:= Answer
(Pic
.Start_Currency
) = '$';
382 -- Fix up "direct inserts" outside the playing field. Set up as one
383 -- loop to do the beginning, one (reverse) loop to do the end.
387 exit when Last
= Pic
.Start_Float
;
388 exit when Last
= Pic
.Radix_Position
;
389 exit when Answer
(Last
) = '9';
391 case Answer
(Last
) is
393 Answer
(Last
) := Separator_Character
;
396 Answer
(Last
) := ' ';
402 exit when Last
= Answer
'Last;
407 -- Now for the end...
409 for J
in reverse Last
.. Answer
'Last loop
410 exit when J
= Pic
.Radix_Position
;
412 -- Do this test First, Separator_Character can equal Pic.Floater
414 if Answer
(J
) = Pic
.Floater
then
420 Answer
(J
) := Separator_Character
;
435 if Pic
.Start_Currency
/= -1
436 and then Answer
(Pic
.Start_Currency
) = '#'
437 and then Pic
.Floater
/= '#'
439 if Currency_Symbol
'Length >
440 Pic
.End_Currency
- Pic
.Start_Currency
+ 1
444 elsif Currency_Symbol
'Length =
445 Pic
.End_Currency
- Pic
.Start_Currency
+ 1
447 Answer
(Pic
.Start_Currency
.. Pic
.End_Currency
) :=
450 elsif Pic
.Radix_Position
= Invalid_Position
451 or else Pic
.Start_Currency
< Pic
.Radix_Position
453 Answer
(Pic
.Start_Currency
.. Pic
.End_Currency
) :=
455 Answer
(Pic
.End_Currency
- Currency_Symbol
'Length + 1 ..
456 Pic
.End_Currency
) := Currency_Symbol
;
459 Answer
(Pic
.Start_Currency
.. Pic
.End_Currency
) :=
461 Answer
(Pic
.Start_Currency
..
462 Pic
.Start_Currency
+ Currency_Symbol
'Length - 1) :=
467 -- Fill in leading digits
469 if Attrs
.End_Of_Int
- Attrs
.Start_Of_Int
+ 1 >
470 Pic
.Max_Leading_Digits
476 (if Pic
.Radix_Position
= Invalid_Position
then Answer
'Last
477 else Pic
.Radix_Position
- 1);
479 for J
in reverse Attrs
.Start_Of_Int
.. Attrs
.End_Of_Int
loop
480 while Answer
(Position
) /= '9'
482 Answer
(Position
) /= Pic
.Floater
484 if Answer
(Position
) = '_' then
485 Answer
(Position
) := Separator_Character
;
486 elsif Answer
(Position
) = 'b' then
487 Answer
(Position
) := ' ';
490 Position
:= Position
- 1;
493 Answer
(Position
) := To_Wide
(Rounded
(J
));
495 if Rounded
(J
) /= '0' then
499 Position
:= Position
- 1;
504 if Pic
.Start_Float
= Invalid_Position
then
506 -- No leading floats, but need to change '9' to '0', '_' to
507 -- Separator_Character and 'b' to ' '.
509 for J
in Last
.. Position
loop
511 -- Last set when fixing the "uninteresting" leaders above.
512 -- Don't duplicate the work.
514 if Answer
(J
) = '9' then
517 elsif Answer
(J
) = '_' then
518 Answer
(J
) := Separator_Character
;
520 elsif Answer
(J
) = 'b' then
527 elsif Pic
.Floater
= '<'
533 for J
in Pic
.End_Float
.. Position
loop -- May be null range
534 if Answer
(J
) = '9' then
537 elsif Answer
(J
) = '_' then
538 Answer
(J
) := Separator_Character
;
540 elsif Answer
(J
) = 'b' then
546 if Position
> Pic
.End_Float
then
547 Position
:= Pic
.End_Float
;
550 for J
in Pic
.Start_Float
.. Position
- 1 loop
554 Answer
(Position
) := Pic
.Floater
;
555 Sign_Position
:= Position
;
557 elsif Pic
.Floater
= '$' then
559 for J
in Pic
.End_Float
.. Position
loop -- May be null range
560 if Answer
(J
) = '9' then
563 elsif Answer
(J
) = '_' then
564 Answer
(J
) := ' '; -- no separator before leftmost digit
566 elsif Answer
(J
) = 'b' then
571 if Position
> Pic
.End_Float
then
572 Position
:= Pic
.End_Float
;
575 for J
in Pic
.Start_Float
.. Position
- 1 loop
579 Answer
(Position
) := Pic
.Floater
;
580 Currency_Pos
:= Position
;
582 elsif Pic
.Floater
= '*' then
584 for J
in Pic
.End_Float
.. Position
loop -- May be null range
585 if Answer
(J
) = '9' then
588 elsif Answer
(J
) = '_' then
589 Answer
(J
) := Separator_Character
;
591 elsif Answer
(J
) = 'b' then
596 if Position
> Pic
.End_Float
then
597 Position
:= Pic
.End_Float
;
600 for J
in Pic
.Start_Float
.. Position
loop
605 if Pic
.Floater
= '#' then
606 Currency_Pos
:= Currency_Symbol
'Length;
609 for J
in reverse Pic
.Start_Float
.. Position
loop
612 Answer
(J
) := Fill_Character
;
614 when 'Z' |
'b' |
'/' |
'0' =>
620 when '.' |
'V' |
'v' |
'<' |
'$' |
'+' |
'-' =>
624 if Currency_Pos
= 0 then
627 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
628 Currency_Pos
:= Currency_Pos
- 1;
634 Answer
(J
) := Fill_Character
;
640 if Currency_Pos
= 0 then
644 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
645 Currency_Pos
:= Currency_Pos
- 1;
657 if Pic
.Floater
= '#' and then Currency_Pos
/= 0 then
664 if Sign_Position
= Invalid_Position
then
665 if Attrs
.Negative
then
670 if Attrs
.Negative
then
671 case Answer
(Sign_Position
) is
672 when 'C' |
'D' |
'-' =>
676 Answer
(Sign_Position
) := '-';
679 Answer
(Sign_Position
) := '(';
680 Answer
(Pic
.Second_Sign
) := ')';
688 case Answer
(Sign_Position
) is
690 Answer
(Sign_Position
) := ' ';
692 when '<' |
'C' |
'D' =>
693 Answer
(Sign_Position
) := ' ';
694 Answer
(Pic
.Second_Sign
) := ' ';
705 -- Fill in trailing digits
707 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
;
740 Position
:= Pic
.Radix_Position
+ 1;
743 -- Now fill remaining 9's with zeros and _ with separators
747 for J
in Position
.. Last
loop
748 if Answer
(J
) = '9' then
751 elsif Answer
(J
) = Pic
.Floater
then
754 elsif Answer
(J
) = '_' then
755 Answer
(J
) := Separator_Character
;
757 elsif Answer
(J
) = 'b' then
762 Position
:= Last
+ 1;
765 if Pic
.Floater
= '#' and then Currency_Pos
/= 0 then
769 -- No trailing digits, but now J may need to stick in a currency
773 (if Pic
.Start_Currency
= Invalid_Position
then Answer
'Last + 1
774 else Pic
.Start_Currency
);
777 for J
in Position
.. Answer
'Last loop
778 if Pic
.Start_Currency
/= Invalid_Position
779 and then Answer
(Pic
.Start_Currency
) = '#'
784 -- Note: There are some weird cases J can imagine with 'b' or '#'
785 -- in currency strings where the following code will cause
786 -- glitches. The trick is to tell when the character in the
787 -- answer should be checked, and when to look at the original
788 -- string. Some other time. RIE 11/26/96 ???
792 Answer
(J
) := Fill_Character
;
798 if Currency_Pos
> Currency_Symbol
'Length then
802 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
803 Currency_Pos
:= Currency_Pos
+ 1;
809 Answer
(J
) := Fill_Character
;
815 if Currency_Pos
> Currency_Symbol
'Length then
818 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
819 Currency_Pos
:= Currency_Pos
+ 1;
831 -- Now get rid of Blank_when_Zero and complete Star fill
833 if Zero
and then Pic
.Blank_When_Zero
then
835 -- Value is zero, and blank it
840 Last
:= Last
- 1 + Currency_Symbol
'Length;
843 if Pic
.Radix_Position
/= Invalid_Position
844 and then Answer
(Pic
.Radix_Position
) = 'V'
849 return Wide_Wide_String
'(1 .. Last => ' ');
851 elsif Zero and then Pic.Star_Fill then
855 Last := Last - 1 + Currency_Symbol'Length;
858 if Pic.Radix_Position /= Invalid_Position then
860 if Answer (Pic.Radix_Position) = 'V
' then
864 if Pic.Radix_Position > Pic.Start_Currency then
866 Wide_Wide_String'(1 .. Pic
.Radix_Position
- 1 => '*') &
868 Wide_Wide_String
'(Pic.Radix_Position + 1 .. Last => '*');
874 Pic
.Radix_Position
+ Currency_Symbol
'Length - 2
878 (Pic.Radix_Position + Currency_Symbol'Length .. Last
884 Wide_Wide_String'(1 .. Pic
.Radix_Position
- 1 => '*') &
886 Wide_Wide_String
'(Pic.Radix_Position + 1 .. Last => '*');
890 return Wide_Wide_String'(1 .. Last
=> '*');
893 -- This was once a simple return statement, now there are nine different
894 -- return cases. Not to mention the five above to deal with zeros. Why
895 -- not split things out?
897 -- Processing the radix and sign expansion separately would require
898 -- lots of copying--the string and some of its indexes--without
899 -- really simplifying the logic. The cases are:
901 -- 1) Expand $, replace '.' with Radix_Point
902 -- 2) No currency expansion, replace '.' with Radix_Point
903 -- 3) Expand $, radix blanked
904 -- 4) No currency expansion, radix blanked
906 -- 6) Expand $, Elide V
907 -- 7) Elide V, Expand $ (Two cases depending on order.)
908 -- 8) No radix, expand $
909 -- 9) No radix, no currency expansion
911 if Pic
.Radix_Position
/= Invalid_Position
then
912 if Answer
(Pic
.Radix_Position
) = '.' then
913 Answer
(Pic
.Radix_Position
) := Radix_Point
;
917 -- 1) Expand $, replace '.' with Radix_Point
919 return Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
920 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
923 -- 2) No currency expansion, replace '.' with Radix_Point
928 elsif Answer
(Pic
.Radix_Position
) = ' ' then -- blanked radix.
931 -- 3) Expand $, radix blanked
933 return Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
934 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
937 -- 4) No expansion, radix blanked
949 return Answer
(1 .. Pic
.Radix_Position
- 1) &
950 Answer
(Pic
.Radix_Position
+ 1 .. Answer
'Last);
952 elsif Currency_Pos
< Pic
.Radix_Position
then
954 -- 6) Expand $, Elide V
956 return Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
957 Answer
(Currency_Pos
+ 1 .. Pic
.Radix_Position
- 1) &
958 Answer
(Pic
.Radix_Position
+ 1 .. Answer
'Last);
961 -- 7) Elide V, Expand $
963 return Answer
(1 .. Pic
.Radix_Position
- 1) &
964 Answer
(Pic
.Radix_Position
+ 1 .. Currency_Pos
- 1) &
966 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
972 -- 8) No radix, expand $
974 return Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
975 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
978 -- 9) No radix, no currency expansion
984 -------------------------
985 -- Parse_Number_String --
986 -------------------------
988 function Parse_Number_String
(Str
: String) return Number_Attributes
is
989 Answer
: Number_Attributes
;
992 for J
in Str
'Range loop
999 -- Decide if this is the start of a number.
1000 -- If so, figure out which one...
1002 if Answer
.Has_Fraction
then
1003 Answer
.End_Of_Fraction
:= J
;
1005 if Answer
.Start_Of_Int
= Invalid_Position
then
1007 Answer
.Start_Of_Int
:= J
;
1009 Answer
.End_Of_Int
:= J
;
1014 -- Only count a zero before the decimal point if it follows a
1015 -- non-zero digit. After the decimal point, zeros will be
1016 -- counted if followed by a non-zero digit.
1018 if not Answer
.Has_Fraction
then
1019 if Answer
.Start_Of_Int
/= Invalid_Position
then
1020 Answer
.End_Of_Int
:= J
;
1028 Answer
.Negative
:= True;
1032 -- Close integer, start fraction
1034 if Answer
.Has_Fraction
then
1035 raise Picture_Error
;
1038 -- Two decimal points is a no-no
1040 Answer
.Has_Fraction
:= True;
1041 Answer
.End_Of_Fraction
:= J
;
1043 -- Could leave this at Invalid_Position, but this seems the
1044 -- right way to indicate a null range...
1046 Answer
.Start_Of_Fraction
:= J
+ 1;
1047 Answer
.End_Of_Int
:= J
- 1;
1050 raise Picture_Error
; -- can this happen? probably not
1054 if Answer
.Start_Of_Int
= Invalid_Position
then
1055 Answer
.Start_Of_Int
:= Answer
.End_Of_Int
+ 1;
1058 -- No significant (intger) digits needs a null range
1061 end Parse_Number_String
;
1067 -- The following ensures that we return B and not b being careful not
1068 -- to break things which expect lower case b for blank. See CXF3A02.
1070 function Pic_String
(Pic
: Picture
) return String is
1071 Temp
: String (1 .. Pic
.Contents
.Picture
.Length
) :=
1072 Pic
.Contents
.Picture
.Expanded
;
1074 for J
in Temp
'Range loop
1075 if Temp
(J
) = 'b' then
1087 procedure Precalculate
(Pic
: in out Format_Record
) is
1089 Computed_BWZ
: Boolean := True;
1091 type Legality
is (Okay
, Reject
);
1092 State
: Legality
:= Reject
;
1093 -- Start in reject, which will reject null strings
1095 Index
: Pic_Index
:= Pic
.Picture
.Expanded
'First;
1097 function At_End
return Boolean;
1098 pragma Inline
(At_End
);
1100 procedure Set_State
(L
: Legality
);
1101 pragma Inline
(Set_State
);
1103 function Look
return Character;
1104 pragma Inline
(Look
);
1106 function Is_Insert
return Boolean;
1107 pragma Inline
(Is_Insert
);
1110 pragma Inline
(Skip
);
1112 procedure Trailing_Currency
;
1113 procedure Trailing_Bracket
;
1114 procedure Number_Fraction
;
1115 procedure Number_Completion
;
1116 procedure Number_Fraction_Or_Bracket
;
1117 procedure Number_Fraction_Or_Z_Fill
;
1118 procedure Zero_Suppression
;
1119 procedure Floating_Bracket
;
1120 procedure Number_Fraction_Or_Star_Fill
;
1121 procedure Star_Suppression
;
1122 procedure Number_Fraction_Or_Dollar
;
1123 procedure Leading_Dollar
;
1124 procedure Number_Fraction_Or_Pound
;
1125 procedure Leading_Pound
;
1127 procedure Floating_Plus
;
1128 procedure Floating_Minus
;
1129 procedure Picture_Plus
;
1130 procedure Picture_Minus
;
1131 procedure Picture_Bracket
;
1133 procedure Optional_RHS_Sign
;
1134 procedure Picture_String
;
1140 function At_End
return Boolean is
1142 return Index
> Pic
.Picture
.Length
;
1145 ----------------------
1146 -- Floating_Bracket --
1147 ----------------------
1149 -- Note that Floating_Bracket is only called with an acceptable
1150 -- prefix. But we don't set Okay, because we must end with a '>'.
1152 procedure Floating_Bracket
is
1155 Pic
.End_Float
:= Index
;
1156 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1158 -- First bracket wasn't counted...
1168 when '_' |
'0' |
'/' =>
1169 Pic
.End_Float
:= Index
;
1173 Pic
.End_Float
:= Index
;
1174 Pic
.Picture
.Expanded
(Index
) := 'b';
1178 Pic
.End_Float
:= Index
;
1179 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1191 when 'V' |
'v' |
'.' =>
1192 Pic
.Radix_Position
:= Index
;
1194 Number_Fraction_Or_Bracket
;
1201 end Floating_Bracket
;
1203 --------------------
1204 -- Floating_Minus --
1205 --------------------
1207 procedure Floating_Minus
is
1215 when '_' |
'0' |
'/' =>
1216 Pic
.End_Float
:= Index
;
1220 Pic
.End_Float
:= Index
;
1221 Pic
.Picture
.Expanded
(Index
) := 'b';
1225 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1226 Pic
.End_Float
:= Index
;
1233 when '.' |
'V' |
'v' =>
1234 Pic
.Radix_Position
:= Index
;
1237 while Is_Insert
loop
1253 Pic
.Max_Trailing_Digits
:=
1254 Pic
.Max_Trailing_Digits
+ 1;
1255 Pic
.End_Float
:= Index
;
1258 when '_' |
'0' |
'/' =>
1262 Pic
.Picture
.Expanded
(Index
) := 'b';
1286 procedure Floating_Plus
is
1294 when '_' |
'0' |
'/' =>
1295 Pic
.End_Float
:= Index
;
1299 Pic
.End_Float
:= Index
;
1300 Pic
.Picture
.Expanded
(Index
) := 'b';
1304 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1305 Pic
.End_Float
:= Index
;
1312 when '.' |
'V' |
'v' =>
1313 Pic
.Radix_Position
:= Index
;
1316 while Is_Insert
loop
1332 Pic
.Max_Trailing_Digits
:=
1333 Pic
.Max_Trailing_Digits
+ 1;
1334 Pic
.End_Float
:= Index
;
1337 when '_' |
'0' |
'/' =>
1341 Pic
.Picture
.Expanded
(Index
) := 'b';
1365 function Is_Insert
return Boolean is
1371 case Pic
.Picture
.Expanded
(Index
) is
1372 when '_' |
'0' |
'/' =>
1376 Pic
.Picture
.Expanded
(Index
) := 'b'; -- canonical
1384 --------------------
1385 -- Leading_Dollar --
1386 --------------------
1388 -- Note that Leading_Dollar can be called in either State. It will set
1389 -- state to Okay only if a 9 or (second) is encountered.
1391 -- Also notice the tricky bit with State and Zero_Suppression.
1392 -- Zero_Suppression is Picture_Error if a '$' or a '9' has been
1393 -- encountered, exactly the cases where State has been set.
1395 procedure Leading_Dollar
is
1397 -- Treat as a floating dollar, and unwind otherwise
1400 Pic
.Start_Currency
:= Index
;
1401 Pic
.End_Currency
:= Index
;
1402 Pic
.Start_Float
:= Index
;
1403 Pic
.End_Float
:= Index
;
1405 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
1416 when '_' |
'0' |
'/' =>
1417 Pic
.End_Float
:= Index
;
1420 -- A trailing insertion character is not part of the
1421 -- floating currency, so need to look ahead.
1424 Pic
.End_Float
:= Pic
.End_Float
- 1;
1428 Pic
.End_Float
:= Index
;
1429 Pic
.Picture
.Expanded
(Index
) := 'b';
1433 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
1435 if State
= Okay
then
1436 raise Picture_Error
;
1438 -- Will overwrite Floater and Start_Float
1444 if State
= Okay
then
1445 raise Picture_Error
;
1447 -- Will overwrite Floater and Start_Float
1453 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1454 Pic
.End_Float
:= Index
;
1455 Pic
.End_Currency
:= Index
;
1456 Set_State
(Okay
); Skip
;
1459 if State
/= Okay
then
1461 Pic
.Start_Float
:= Invalid_Position
;
1462 Pic
.End_Float
:= Invalid_Position
;
1465 -- A single dollar does not a floating make
1470 when 'V' |
'v' |
'.' =>
1471 if State
/= Okay
then
1473 Pic
.Start_Float
:= Invalid_Position
;
1474 Pic
.End_Float
:= Invalid_Position
;
1477 -- Only one dollar before the sign is okay, but doesn't
1480 Pic
.Radix_Position
:= Index
;
1482 Number_Fraction_Or_Dollar
;
1495 -- This one is complex. A Leading_Pound can be fixed or floating, but
1496 -- in some cases the decision has to be deferred until we leave this
1497 -- procedure. Also note that Leading_Pound can be called in either
1500 -- It will set state to Okay only if a 9 or (second) # is encountered
1502 -- One Last note: In ambiguous cases, the currency is treated as
1503 -- floating unless there is only one '#'.
1505 procedure Leading_Pound
is
1506 Inserts
: Boolean := False;
1507 -- Set to True if a '_', '0', '/', 'B', or 'b' is encountered
1509 Must_Float
: Boolean := False;
1510 -- Set to true if a '#' occurs after an insert
1513 -- Treat as a floating currency. If it isn't, this will be
1514 -- overwritten later.
1518 Pic
.Start_Currency
:= Index
;
1519 Pic
.End_Currency
:= Index
;
1520 Pic
.Start_Float
:= Index
;
1521 Pic
.End_Float
:= Index
;
1523 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
1526 Pic
.Max_Currency_Digits
:= 1; -- we've seen one.
1536 when '_' |
'0' |
'/' =>
1537 Pic
.End_Float
:= Index
;
1542 Pic
.Picture
.Expanded
(Index
) := 'b';
1543 Pic
.End_Float
:= Index
;
1548 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
1551 raise Picture_Error
;
1553 Pic
.Max_Leading_Digits
:= 0;
1555 -- Will overwrite Floater and Start_Float
1562 raise Picture_Error
;
1564 Pic
.Max_Leading_Digits
:= 0;
1566 -- Will overwrite Floater and Start_Float
1576 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1577 Pic
.End_Float
:= Index
;
1578 Pic
.End_Currency
:= Index
;
1583 if State
/= Okay
then
1585 -- A single '#' doesn't float
1588 Pic
.Start_Float
:= Invalid_Position
;
1589 Pic
.End_Float
:= Invalid_Position
;
1595 when 'V' |
'v' |
'.' =>
1596 if State
/= Okay
then
1598 Pic
.Start_Float
:= Invalid_Position
;
1599 Pic
.End_Float
:= Invalid_Position
;
1602 -- Only one pound before the sign is okay, but doesn't
1605 Pic
.Radix_Position
:= Index
;
1607 Number_Fraction_Or_Pound
;
1620 function Look
return Character is
1623 raise Picture_Error
;
1626 return Pic
.Picture
.Expanded
(Index
);
1637 when '_' |
'0' |
'/' =>
1641 Pic
.Picture
.Expanded
(Index
) := 'b';
1645 Computed_BWZ
:= False;
1646 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1650 when '.' |
'V' |
'v' =>
1651 Pic
.Radix_Position
:= Index
;
1665 -- Will return in Okay state if a '9' was seen
1670 -----------------------
1671 -- Number_Completion --
1672 -----------------------
1674 procedure Number_Completion
is
1676 while not At_End
loop
1678 when '_' |
'0' |
'/' =>
1682 Pic
.Picture
.Expanded
(Index
) := 'b';
1686 Computed_BWZ
:= False;
1687 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1691 when 'V' |
'v' |
'.' =>
1692 Pic
.Radix_Position
:= Index
;
1701 end Number_Completion
;
1703 ---------------------
1704 -- Number_Fraction --
1705 ---------------------
1707 procedure Number_Fraction
is
1709 -- Note that number fraction can be called in either State.
1710 -- It will set state to Valid only if a 9 is encountered.
1718 when '_' |
'0' |
'/' =>
1722 Pic
.Picture
.Expanded
(Index
) := 'b';
1726 Computed_BWZ
:= False;
1727 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1728 Set_State
(Okay
); Skip
;
1734 end Number_Fraction
;
1736 --------------------------------
1737 -- Number_Fraction_Or_Bracket --
1738 --------------------------------
1740 procedure Number_Fraction_Or_Bracket
is
1748 when '_' |
'0' |
'/' =>
1752 Pic
.Picture
.Expanded
(Index
) := 'b';
1756 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1757 Pic
.End_Float
:= Index
;
1766 when '_' |
'0' |
'/' =>
1770 Pic
.Picture
.Expanded
(Index
) := 'b';
1774 Pic
.Max_Trailing_Digits
:=
1775 Pic
.Max_Trailing_Digits
+ 1;
1776 Pic
.End_Float
:= Index
;
1789 end Number_Fraction_Or_Bracket
;
1791 -------------------------------
1792 -- Number_Fraction_Or_Dollar --
1793 -------------------------------
1795 procedure Number_Fraction_Or_Dollar
is
1803 when '_' |
'0' |
'/' =>
1807 Pic
.Picture
.Expanded
(Index
) := 'b';
1811 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1812 Pic
.End_Float
:= Index
;
1821 when '_' |
'0' |
'/' =>
1825 Pic
.Picture
.Expanded
(Index
) := 'b';
1829 Pic
.Max_Trailing_Digits
:=
1830 Pic
.Max_Trailing_Digits
+ 1;
1831 Pic
.End_Float
:= Index
;
1844 end Number_Fraction_Or_Dollar
;
1846 ------------------------------
1847 -- Number_Fraction_Or_Pound --
1848 ------------------------------
1850 procedure Number_Fraction_Or_Pound
is
1858 when '_' |
'0' |
'/' =>
1862 Pic
.Picture
.Expanded
(Index
) := 'b';
1866 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1867 Pic
.End_Float
:= Index
;
1876 when '_' |
'0' |
'/' =>
1880 Pic
.Picture
.Expanded
(Index
) := 'b';
1884 Pic
.Max_Trailing_Digits
:=
1885 Pic
.Max_Trailing_Digits
+ 1;
1886 Pic
.End_Float
:= Index
;
1899 end Number_Fraction_Or_Pound
;
1901 ----------------------------------
1902 -- Number_Fraction_Or_Star_Fill --
1903 ----------------------------------
1905 procedure Number_Fraction_Or_Star_Fill
is
1913 when '_' |
'0' |
'/' =>
1917 Pic
.Picture
.Expanded
(Index
) := 'b';
1921 Pic
.Star_Fill
:= True;
1922 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1923 Pic
.End_Float
:= Index
;
1932 when '_' |
'0' |
'/' =>
1936 Pic
.Picture
.Expanded
(Index
) := 'b';
1940 Pic
.Star_Fill
:= True;
1941 Pic
.Max_Trailing_Digits
:=
1942 Pic
.Max_Trailing_Digits
+ 1;
1943 Pic
.End_Float
:= Index
;
1956 end Number_Fraction_Or_Star_Fill
;
1958 -------------------------------
1959 -- Number_Fraction_Or_Z_Fill --
1960 -------------------------------
1962 procedure Number_Fraction_Or_Z_Fill
is
1970 when '_' |
'0' |
'/' =>
1974 Pic
.Picture
.Expanded
(Index
) := 'b';
1978 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1979 Pic
.End_Float
:= Index
;
1980 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
1990 when '_' |
'0' |
'/' =>
1994 Pic
.Picture
.Expanded
(Index
) := 'b';
1998 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2000 Pic
.Max_Trailing_Digits
:=
2001 Pic
.Max_Trailing_Digits
+ 1;
2002 Pic
.End_Float
:= Index
;
2015 end Number_Fraction_Or_Z_Fill
;
2017 -----------------------
2018 -- Optional_RHS_Sign --
2019 -----------------------
2021 procedure Optional_RHS_Sign
is
2029 Pic
.Sign_Position
:= Index
;
2034 Pic
.Sign_Position
:= Index
;
2035 Pic
.Picture
.Expanded
(Index
) := 'C';
2038 if Look
= 'R' or else Look
= 'r' then
2039 Pic
.Second_Sign
:= Index
;
2040 Pic
.Picture
.Expanded
(Index
) := 'R';
2044 raise Picture_Error
;
2050 Pic
.Sign_Position
:= Index
;
2051 Pic
.Picture
.Expanded
(Index
) := 'D';
2054 if Look
= 'B' or else Look
= 'b' then
2055 Pic
.Second_Sign
:= Index
;
2056 Pic
.Picture
.Expanded
(Index
) := 'B';
2060 raise Picture_Error
;
2066 if Pic
.Picture
.Expanded
(Pic
.Sign_Position
) = '<' then
2067 Pic
.Second_Sign
:= Index
;
2071 raise Picture_Error
;
2077 end Optional_RHS_Sign
;
2083 -- Note that Picture can be called in either State
2085 -- It will set state to Valid only if a 9 is encountered or floating
2086 -- currency is called.
2088 procedure Picture
is
2096 when '_' |
'0' |
'/' =>
2100 Pic
.Picture
.Expanded
(Index
) := 'b';
2112 Computed_BWZ
:= False;
2114 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2117 when 'V' |
'v' |
'.' =>
2118 Pic
.Radix_Position
:= Index
;
2130 ---------------------
2131 -- Picture_Bracket --
2132 ---------------------
2134 procedure Picture_Bracket
is
2136 Pic
.Sign_Position
:= Index
;
2137 Pic
.Sign_Position
:= Index
;
2139 -- Treat as a floating sign, and unwind otherwise
2142 Pic
.Start_Float
:= Index
;
2143 Pic
.End_Float
:= Index
;
2145 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
2148 Skip
; -- Known Bracket
2152 when '_' |
'0' |
'/' =>
2153 Pic
.End_Float
:= Index
;
2157 Pic
.End_Float
:= Index
;
2158 Pic
.Picture
.Expanded
(Index
) := 'b';
2162 Set_State
(Okay
); -- "<<>" is enough.
2168 when '$' |
'#' |
'9' |
'*' =>
2169 if State
/= Okay
then
2171 Pic
.Start_Float
:= Invalid_Position
;
2172 Pic
.End_Float
:= Invalid_Position
;
2180 when '.' |
'V' |
'v' =>
2181 if State
/= Okay
then
2183 Pic
.Start_Float
:= Invalid_Position
;
2184 Pic
.End_Float
:= Invalid_Position
;
2187 -- Don't assume that state is okay, haven't seen a digit
2194 raise Picture_Error
;
2197 end Picture_Bracket
;
2203 procedure Picture_Minus
is
2205 Pic
.Sign_Position
:= Index
;
2207 -- Treat as a floating sign, and unwind otherwise
2210 Pic
.Start_Float
:= Index
;
2211 Pic
.End_Float
:= Index
;
2213 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
2216 Skip
; -- Known Minus
2220 when '_' |
'0' |
'/' =>
2221 Pic
.End_Float
:= Index
;
2225 Pic
.End_Float
:= Index
;
2226 Pic
.Picture
.Expanded
(Index
) := 'b';
2230 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2231 Pic
.End_Float
:= Index
;
2233 Set_State
(Okay
); -- "-- " is enough.
2238 when '$' |
'#' |
'9' |
'*' =>
2239 if State
/= Okay
then
2241 Pic
.Start_Float
:= Invalid_Position
;
2242 Pic
.End_Float
:= Invalid_Position
;
2251 -- Can't have Z and a floating sign
2253 if State
= Okay
then
2257 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2263 when '.' |
'V' |
'v' =>
2264 if State
/= Okay
then
2266 Pic
.Start_Float
:= Invalid_Position
;
2267 Pic
.End_Float
:= Invalid_Position
;
2270 -- Don't assume that state is okay, haven't seen a digit
2285 procedure Picture_Plus
is
2287 Pic
.Sign_Position
:= Index
;
2289 -- Treat as a floating sign, and unwind otherwise
2292 Pic
.Start_Float
:= Index
;
2293 Pic
.End_Float
:= Index
;
2295 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
2302 when '_' |
'0' |
'/' =>
2303 Pic
.End_Float
:= Index
;
2307 Pic
.End_Float
:= Index
;
2308 Pic
.Picture
.Expanded
(Index
) := 'b';
2312 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2313 Pic
.End_Float
:= Index
;
2315 Set_State
(Okay
); -- "++" is enough
2320 when '$' |
'#' |
'9' |
'*' =>
2321 if State
/= Okay
then
2323 Pic
.Start_Float
:= Invalid_Position
;
2324 Pic
.End_Float
:= Invalid_Position
;
2332 if State
= Okay
then
2336 -- Can't have Z and a floating sign
2338 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2340 -- '+Z' is acceptable
2349 when '.' |
'V' |
'v' =>
2350 if State
/= Okay
then
2352 Pic
.Start_Float
:= Invalid_Position
;
2353 Pic
.End_Float
:= Invalid_Position
;
2356 -- Don't assume that state is okay, haven't seen a digit
2367 --------------------
2368 -- Picture_String --
2369 --------------------
2371 procedure Picture_String
is
2373 while Is_Insert
loop
2392 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2402 when '9' |
'.' |
'V' |
'v' =>
2408 raise Picture_Error
;
2411 -- Blank when zero either if the PIC does not contain a '9' or if
2412 -- requested by the user and no '*'.
2414 Pic
.Blank_When_Zero
:=
2415 (Computed_BWZ
or else Pic
.Blank_When_Zero
)
2416 and then not Pic
.Star_Fill
;
2418 -- Star fill if '*' and no '9'
2420 Pic
.Star_Fill
:= Pic
.Star_Fill
and then Computed_BWZ
;
2431 procedure Set_State
(L
: Legality
) is
2445 ----------------------
2446 -- Star_Suppression --
2447 ----------------------
2449 procedure Star_Suppression
is
2452 Pic
.Start_Float
:= Index
;
2453 Pic
.End_Float
:= Index
;
2454 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2457 -- Even a single * is a valid picture
2459 Pic
.Star_Fill
:= True;
2468 when '_' |
'0' |
'/' =>
2469 Pic
.End_Float
:= Index
;
2473 Pic
.End_Float
:= Index
;
2474 Pic
.Picture
.Expanded
(Index
) := 'b';
2478 Pic
.End_Float
:= Index
;
2479 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2480 Set_State
(Okay
); Skip
;
2487 when '.' |
'V' |
'v' =>
2488 Pic
.Radix_Position
:= Index
;
2490 Number_Fraction_Or_Star_Fill
;
2499 raise Picture_Error
;
2502 end Star_Suppression
;
2504 ----------------------
2505 -- Trailing_Bracket --
2506 ----------------------
2508 procedure Trailing_Bracket
is
2511 Pic
.Second_Sign
:= Index
;
2514 raise Picture_Error
;
2516 end Trailing_Bracket
;
2518 -----------------------
2519 -- Trailing_Currency --
2520 -----------------------
2522 procedure Trailing_Currency
is
2529 Pic
.Start_Currency
:= Index
;
2530 Pic
.End_Currency
:= Index
;
2534 while not At_End
and then Look
= '#' loop
2535 if Pic
.Start_Currency
= Invalid_Position
then
2536 Pic
.Start_Currency
:= Index
;
2539 Pic
.End_Currency
:= Index
;
2550 when '_' |
'0' |
'/' =>
2554 Pic
.Picture
.Expanded
(Index
) := 'b';
2561 end Trailing_Currency
;
2563 ----------------------
2564 -- Zero_Suppression --
2565 ----------------------
2567 procedure Zero_Suppression
is
2570 Pic
.Start_Float
:= Index
;
2571 Pic
.End_Float
:= Index
;
2572 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2573 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2578 -- Even a single Z is a valid picture
2586 when '_' |
'0' |
'/' =>
2587 Pic
.End_Float
:= Index
;
2591 Pic
.End_Float
:= Index
;
2592 Pic
.Picture
.Expanded
(Index
) := 'b';
2596 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2598 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2599 Pic
.End_Float
:= Index
;
2608 when '.' |
'V' |
'v' =>
2609 Pic
.Radix_Position
:= Index
;
2611 Number_Fraction_Or_Z_Fill
;
2623 end Zero_Suppression
;
2625 -- Start of processing for Precalculate
2630 if State
= Reject
then
2631 raise Picture_Error
;
2636 when Constraint_Error
=>
2638 -- To deal with special cases like null strings
2640 raise Picture_Error
;
2649 (Pic_String
: String;
2650 Blank_When_Zero
: Boolean := False) return Picture
2656 Item
: constant String := Expand
(Pic_String
);
2659 Result
.Contents
.Picture
:= (Item
'Length, Item
);
2660 Result
.Contents
.Original_BWZ
:= Blank_When_Zero
;
2661 Result
.Contents
.Blank_When_Zero
:= Blank_When_Zero
;
2662 Precalculate
(Result
.Contents
);
2668 raise Picture_Error
;
2676 function To_Wide
(C
: Character) return Wide_Wide_Character
is
2678 return Wide_Wide_Character
'Val (Character'Pos (C
));
2686 (Pic_String
: String;
2687 Blank_When_Zero
: Boolean := False) return Boolean
2691 Expanded_Pic
: constant String := Expand
(Pic_String
);
2692 -- Raises Picture_Error if Item not well-formed
2694 Format_Rec
: Format_Record
;
2697 Format_Rec
.Picture
:= (Expanded_Pic
'Length, Expanded_Pic
);
2698 Format_Rec
.Blank_When_Zero
:= Blank_When_Zero
;
2699 Format_Rec
.Original_BWZ
:= Blank_When_Zero
;
2700 Precalculate
(Format_Rec
);
2702 -- False only if Blank_When_0 is True but the pic string has a '*'
2704 return not Blank_When_Zero
2705 or else Strings_Fixed
.Index
(Expanded_Pic
, "*") = 0;
2709 when others => return False;
2712 end Ada
.Wide_Wide_Text_IO
.Editing
;