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-2013, 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
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;
281 exit when Picture_Index
> Picture
'Last;
284 return Result
(1 .. Result_Index
- 1);
295 function Format_Number
296 (Pic
: Format_Record
;
298 Currency_Symbol
: Wide_String;
299 Fill_Character
: Wide_Character;
300 Separator_Character
: Wide_Character;
301 Radix_Point
: Wide_Character) return Wide_String
303 Attrs
: Number_Attributes
:= Parse_Number_String
(Number
);
305 Rounded
: String := Number
;
307 Sign_Position
: Integer := Pic
.Sign_Position
; -- may float.
309 Answer
: Wide_String (1 .. Pic
.Picture
.Length
);
311 Currency_Pos
: Integer := Pic
.Start_Currency
;
313 Dollar
: Boolean := False;
314 -- Overridden immediately if necessary
316 Zero
: Boolean := True;
317 -- Set to False when a non-zero digit is output
321 -- If the picture has fewer decimal places than the number, the image
322 -- must be rounded according to the usual rules.
324 if Attrs
.Has_Fraction
then
326 R
: constant Integer :=
327 (Attrs
.End_Of_Fraction
- Attrs
.Start_Of_Fraction
+ 1)
328 - Pic
.Max_Trailing_Digits
;
333 R_Pos
:= Rounded
'Length - R
;
335 if Rounded
(R_Pos
+ 1) > '4' then
337 if Rounded
(R_Pos
) = '.' then
341 if Rounded
(R_Pos
) /= '9' then
342 Rounded
(R_Pos
) := Character'Succ (Rounded
(R_Pos
));
344 Rounded
(R_Pos
) := '0';
348 if Rounded
(R_Pos
) = '.' then
352 if Rounded
(R_Pos
) /= '9' then
353 Rounded
(R_Pos
) := Character'Succ (Rounded
(R_Pos
));
356 Rounded
(R_Pos
) := '0';
361 -- The rounding may add a digit in front. Either the
362 -- leading blank or the sign (already captured) can be
366 Rounded
(R_Pos
) := '1';
367 Attrs
.Start_Of_Int
:= Attrs
.Start_Of_Int
- 1;
375 for J
in Answer
'Range loop
376 Answer
(J
) := To_Wide
(Pic
.Picture
.Expanded
(J
));
379 if Pic
.Start_Currency
/= Invalid_Position
then
380 Dollar
:= Answer
(Pic
.Start_Currency
) = '$';
383 -- Fix up "direct inserts" outside the playing field. Set up as one
384 -- loop to do the beginning, one (reverse) loop to do the end.
388 exit when Last
= Pic
.Start_Float
;
389 exit when Last
= Pic
.Radix_Position
;
390 exit when Answer
(Last
) = '9';
392 case Answer
(Last
) is
395 Answer
(Last
) := Separator_Character
;
398 Answer
(Last
) := ' ';
405 exit when Last
= Answer
'Last;
410 -- Now for the end...
412 for J
in reverse Last
.. Answer
'Last loop
413 exit when J
= Pic
.Radix_Position
;
415 -- Do this test First, Separator_Character can equal Pic.Floater
417 if Answer
(J
) = Pic
.Floater
then
424 Answer
(J
) := Separator_Character
;
440 if Pic
.Start_Currency
/= -1
441 and then Answer
(Pic
.Start_Currency
) = '#'
442 and then Pic
.Floater
/= '#'
444 if Currency_Symbol
'Length >
445 Pic
.End_Currency
- Pic
.Start_Currency
+ 1
449 elsif Currency_Symbol
'Length =
450 Pic
.End_Currency
- Pic
.Start_Currency
+ 1
452 Answer
(Pic
.Start_Currency
.. Pic
.End_Currency
) :=
455 elsif Pic
.Radix_Position
= Invalid_Position
456 or else Pic
.Start_Currency
< Pic
.Radix_Position
458 Answer
(Pic
.Start_Currency
.. Pic
.End_Currency
) :=
460 Answer
(Pic
.End_Currency
- Currency_Symbol
'Length + 1 ..
461 Pic
.End_Currency
) := Currency_Symbol
;
464 Answer
(Pic
.Start_Currency
.. Pic
.End_Currency
) :=
466 Answer
(Pic
.Start_Currency
..
467 Pic
.Start_Currency
+ Currency_Symbol
'Length - 1) :=
472 -- Fill in leading digits
474 if Attrs
.End_Of_Int
- Attrs
.Start_Of_Int
+ 1 >
475 Pic
.Max_Leading_Digits
481 (if Pic
.Radix_Position
= Invalid_Position
then Answer
'Last
482 else Pic
.Radix_Position
- 1);
484 for J
in reverse Attrs
.Start_Of_Int
.. Attrs
.End_Of_Int
loop
485 while Answer
(Position
) /= '9'
487 Answer
(Position
) /= Pic
.Floater
489 if Answer
(Position
) = '_' then
490 Answer
(Position
) := Separator_Character
;
491 elsif Answer
(Position
) = 'b' then
492 Answer
(Position
) := ' ';
495 Position
:= Position
- 1;
498 Answer
(Position
) := To_Wide
(Rounded
(J
));
500 if Rounded
(J
) /= '0' then
504 Position
:= Position
- 1;
509 if Pic
.Start_Float
= Invalid_Position
then
511 -- No leading floats, but need to change '9' to '0', '_' to
512 -- Separator_Character and 'b' to ' '.
514 for J
in Last
.. Position
loop
516 -- Last set when fixing the "uninteresting" leaders above.
517 -- Don't duplicate the work.
519 if Answer
(J
) = '9' then
522 elsif Answer
(J
) = '_' then
523 Answer
(J
) := Separator_Character
;
525 elsif Answer
(J
) = 'b' then
532 elsif Pic
.Floater
= '<'
538 for J
in Pic
.End_Float
.. Position
loop -- May be null range
539 if Answer
(J
) = '9' then
542 elsif Answer
(J
) = '_' then
543 Answer
(J
) := Separator_Character
;
545 elsif Answer
(J
) = 'b' then
551 if Position
> Pic
.End_Float
then
552 Position
:= Pic
.End_Float
;
555 for J
in Pic
.Start_Float
.. Position
- 1 loop
559 Answer
(Position
) := Pic
.Floater
;
560 Sign_Position
:= Position
;
562 elsif Pic
.Floater
= '$' then
564 for J
in Pic
.End_Float
.. Position
loop -- May be null range
565 if Answer
(J
) = '9' then
568 elsif Answer
(J
) = '_' then
569 Answer
(J
) := ' '; -- no separator before leftmost digit
571 elsif Answer
(J
) = 'b' then
576 if Position
> Pic
.End_Float
then
577 Position
:= Pic
.End_Float
;
580 for J
in Pic
.Start_Float
.. Position
- 1 loop
584 Answer
(Position
) := Pic
.Floater
;
585 Currency_Pos
:= Position
;
587 elsif Pic
.Floater
= '*' then
589 for J
in Pic
.End_Float
.. Position
loop -- May be null range
590 if Answer
(J
) = '9' then
593 elsif Answer
(J
) = '_' then
594 Answer
(J
) := Separator_Character
;
596 elsif Answer
(J
) = 'b' then
601 if Position
> Pic
.End_Float
then
602 Position
:= Pic
.End_Float
;
605 for J
in Pic
.Start_Float
.. Position
loop
610 if Pic
.Floater
= '#' then
611 Currency_Pos
:= Currency_Symbol
'Length;
614 for J
in reverse Pic
.Start_Float
.. Position
loop
618 Answer
(J
) := Fill_Character
;
620 when 'Z' |
'b' |
'/' |
'0' =>
626 when '.' |
'V' |
'v' |
'<' |
'$' |
'+' |
'-' =>
630 if Currency_Pos
= 0 then
633 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
634 Currency_Pos
:= Currency_Pos
- 1;
642 Answer
(J
) := Fill_Character
;
648 if Currency_Pos
= 0 then
652 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
653 Currency_Pos
:= Currency_Pos
- 1;
667 if Pic
.Floater
= '#' and then Currency_Pos
/= 0 then
674 if Sign_Position
= Invalid_Position
then
675 if Attrs
.Negative
then
680 if Attrs
.Negative
then
681 case Answer
(Sign_Position
) is
682 when 'C' |
'D' |
'-' =>
686 Answer
(Sign_Position
) := '-';
689 Answer
(Sign_Position
) := '(';
690 Answer
(Pic
.Second_Sign
) := ')';
699 case Answer
(Sign_Position
) is
702 Answer
(Sign_Position
) := ' ';
704 when '<' |
'C' |
'D' =>
705 Answer
(Sign_Position
) := ' ';
706 Answer
(Pic
.Second_Sign
) := ' ';
718 -- Fill in trailing digits
720 if Pic
.Max_Trailing_Digits
> 0 then
722 if Attrs
.Has_Fraction
then
723 Position
:= Attrs
.Start_Of_Fraction
;
724 Last
:= Pic
.Radix_Position
+ 1;
726 for J
in Last
.. Answer
'Last loop
728 if Answer
(J
) = '9' or else Answer
(J
) = Pic
.Floater
then
729 Answer
(J
) := To_Wide
(Rounded
(Position
));
731 if Rounded
(Position
) /= '0' then
735 Position
:= Position
+ 1;
738 -- Used up fraction but remember place in Answer
740 exit when Position
> Attrs
.End_Of_Fraction
;
742 elsif Answer
(J
) = 'b' then
745 elsif Answer
(J
) = '_' then
746 Answer
(J
) := Separator_Character
;
756 Position
:= Pic
.Radix_Position
+ 1;
759 -- Now fill remaining 9's with zeros and _ with separators
763 for J
in Position
.. Last
loop
764 if Answer
(J
) = '9' then
767 elsif Answer
(J
) = Pic
.Floater
then
770 elsif Answer
(J
) = '_' then
771 Answer
(J
) := Separator_Character
;
773 elsif Answer
(J
) = 'b' then
779 Position
:= Last
+ 1;
782 if Pic
.Floater
= '#' and then Currency_Pos
/= 0 then
786 -- No trailing digits, but now J may need to stick in a currency
790 (if Pic
.Start_Currency
= Invalid_Position
then Answer
'Last + 1
791 else Pic
.Start_Currency
);
794 for J
in Position
.. Answer
'Last loop
795 if Pic
.Start_Currency
/= Invalid_Position
796 and then Answer
(Pic
.Start_Currency
) = '#'
801 -- Note: There are some weird cases J can imagine with 'b' or '#' in
802 -- currency strings where the following code will cause glitches. The
803 -- trick is to tell when the character in the answer should be
804 -- checked, and when to look at the original string. Some other time.
809 Answer
(J
) := Fill_Character
;
815 if Currency_Pos
> Currency_Symbol
'Length then
819 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
820 Currency_Pos
:= Currency_Pos
+ 1;
828 Answer
(J
) := Fill_Character
;
834 if Currency_Pos
> Currency_Symbol
'Length then
837 Answer
(J
) := Currency_Symbol
(Currency_Pos
);
838 Currency_Pos
:= Currency_Pos
+ 1;
852 -- Now get rid of Blank_when_Zero and complete Star fill
854 if Zero
and then Pic
.Blank_When_Zero
then
856 -- Value is zero, and blank it
861 Last
:= Last
- 1 + Currency_Symbol
'Length;
864 if Pic
.Radix_Position
/= Invalid_Position
865 and then Answer
(Pic
.Radix_Position
) = 'V'
870 return Wide_String'(1 .. Last => ' ');
872 elsif Zero and then Pic.Star_Fill then
876 Last := Last - 1 + Currency_Symbol'Length;
879 if Pic.Radix_Position /= Invalid_Position then
881 if Answer (Pic.Radix_Position) = 'V
' then
885 if Pic.Radix_Position > Pic.Start_Currency then
886 return Wide_String'(1 .. Pic
.Radix_Position
- 1 => '*') &
888 Wide_String'(Pic.Radix_Position + 1 .. Last => '*');
894 Pic
.Radix_Position
+ Currency_Symbol
'Length - 2
898 (Pic.Radix_Position + Currency_Symbol'Length .. Last
904 Wide_String'(1 .. Pic
.Radix_Position
- 1 => '*') &
906 Wide_String'(Pic.Radix_Position + 1 .. Last => '*');
910 return Wide_String'(1 .. Last
=> '*');
913 -- This was once a simple return statement, now there are nine
914 -- different return cases. Not to mention the five above to deal
915 -- with zeros. Why not split things out?
917 -- Processing the radix and sign expansion separately would require
918 -- lots of copying--the string and some of its indexes--without
919 -- really simplifying the logic. The cases are:
921 -- 1) Expand $, replace '.' with Radix_Point
922 -- 2) No currency expansion, replace '.' with Radix_Point
923 -- 3) Expand $, radix blanked
924 -- 4) No currency expansion, radix blanked
926 -- 6) Expand $, Elide V
927 -- 7) Elide V, Expand $ (Two cases depending on order.)
928 -- 8) No radix, expand $
929 -- 9) No radix, no currency expansion
931 if Pic
.Radix_Position
/= Invalid_Position
then
933 if Answer
(Pic
.Radix_Position
) = '.' then
934 Answer
(Pic
.Radix_Position
) := Radix_Point
;
938 -- 1) Expand $, replace '.' with Radix_Point
941 Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
942 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
945 -- 2) No currency expansion, replace '.' with Radix_Point
950 elsif Answer
(Pic
.Radix_Position
) = ' ' then -- blanked radix.
953 -- 3) Expand $, radix blanked
955 return Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
956 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
959 -- 4) No expansion, radix blanked
971 return Answer
(1 .. Pic
.Radix_Position
- 1) &
972 Answer
(Pic
.Radix_Position
+ 1 .. Answer
'Last);
974 elsif Currency_Pos
< Pic
.Radix_Position
then
976 -- 6) Expand $, Elide V
978 return Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
979 Answer
(Currency_Pos
+ 1 .. Pic
.Radix_Position
- 1) &
980 Answer
(Pic
.Radix_Position
+ 1 .. Answer
'Last);
983 -- 7) Elide V, Expand $
985 return Answer
(1 .. Pic
.Radix_Position
- 1) &
986 Answer
(Pic
.Radix_Position
+ 1 .. Currency_Pos
- 1) &
988 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
994 -- 8) No radix, expand $
996 return Answer
(1 .. Currency_Pos
- 1) & Currency_Symbol
&
997 Answer
(Currency_Pos
+ 1 .. Answer
'Last);
1000 -- 9) No radix, no currency expansion
1006 -------------------------
1007 -- Parse_Number_String --
1008 -------------------------
1010 function Parse_Number_String
(Str
: String) return Number_Attributes
is
1011 Answer
: Number_Attributes
;
1014 for J
in Str
'Range loop
1022 -- Decide if this is the start of a number.
1023 -- If so, figure out which one...
1025 if Answer
.Has_Fraction
then
1026 Answer
.End_Of_Fraction
:= J
;
1028 if Answer
.Start_Of_Int
= Invalid_Position
then
1030 Answer
.Start_Of_Int
:= J
;
1032 Answer
.End_Of_Int
:= J
;
1037 -- Only count a zero before the decimal point if it follows a
1038 -- non-zero digit. After the decimal point, zeros will be
1039 -- counted if followed by a non-zero digit.
1041 if not Answer
.Has_Fraction
then
1042 if Answer
.Start_Of_Int
/= Invalid_Position
then
1043 Answer
.End_Of_Int
:= J
;
1051 Answer
.Negative
:= True;
1055 -- Close integer, start fraction
1057 if Answer
.Has_Fraction
then
1058 raise Picture_Error
;
1061 -- Two decimal points is a no-no
1063 Answer
.Has_Fraction
:= True;
1064 Answer
.End_Of_Fraction
:= J
;
1066 -- Could leave this at Invalid_Position, but this seems the
1067 -- right way to indicate a null range...
1069 Answer
.Start_Of_Fraction
:= J
+ 1;
1070 Answer
.End_Of_Int
:= J
- 1;
1073 raise Picture_Error
; -- can this happen? probably not
1077 if Answer
.Start_Of_Int
= Invalid_Position
then
1078 Answer
.Start_Of_Int
:= Answer
.End_Of_Int
+ 1;
1081 -- No significant (intger) digits needs a null range
1084 end Parse_Number_String
;
1090 -- The following ensures that we return B and not b being careful not
1091 -- to break things which expect lower case b for blank. See CXF3A02.
1093 function Pic_String
(Pic
: Picture
) return String is
1094 Temp
: String (1 .. Pic
.Contents
.Picture
.Length
) :=
1095 Pic
.Contents
.Picture
.Expanded
;
1097 for J
in Temp
'Range loop
1098 if Temp
(J
) = 'b' then
1110 procedure Precalculate
(Pic
: in out Format_Record
) is
1112 Computed_BWZ
: Boolean := True;
1114 type Legality
is (Okay
, Reject
);
1115 State
: Legality
:= Reject
;
1116 -- Start in reject, which will reject null strings
1118 Index
: Pic_Index
:= Pic
.Picture
.Expanded
'First;
1120 function At_End
return Boolean;
1121 pragma Inline
(At_End
);
1123 procedure Set_State
(L
: Legality
);
1124 pragma Inline
(Set_State
);
1126 function Look
return Character;
1127 pragma Inline
(Look
);
1129 function Is_Insert
return Boolean;
1130 pragma Inline
(Is_Insert
);
1133 pragma Inline
(Skip
);
1135 procedure Trailing_Currency
;
1136 procedure Trailing_Bracket
;
1137 procedure Number_Fraction
;
1138 procedure Number_Completion
;
1139 procedure Number_Fraction_Or_Bracket
;
1140 procedure Number_Fraction_Or_Z_Fill
;
1141 procedure Zero_Suppression
;
1142 procedure Floating_Bracket
;
1143 procedure Number_Fraction_Or_Star_Fill
;
1144 procedure Star_Suppression
;
1145 procedure Number_Fraction_Or_Dollar
;
1146 procedure Leading_Dollar
;
1147 procedure Number_Fraction_Or_Pound
;
1148 procedure Leading_Pound
;
1150 procedure Floating_Plus
;
1151 procedure Floating_Minus
;
1152 procedure Picture_Plus
;
1153 procedure Picture_Minus
;
1154 procedure Picture_Bracket
;
1156 procedure Optional_RHS_Sign
;
1157 procedure Picture_String
;
1163 function At_End
return Boolean is
1165 return Index
> Pic
.Picture
.Length
;
1168 ----------------------
1169 -- Floating_Bracket --
1170 ----------------------
1172 -- Note that Floating_Bracket is only called with an acceptable
1173 -- prefix. But we don't set Okay, because we must end with a '>'.
1175 procedure Floating_Bracket
is
1178 Pic
.End_Float
:= Index
;
1179 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1181 -- First bracket wasn't counted...
1192 when '_' |
'0' |
'/' =>
1193 Pic
.End_Float
:= Index
;
1197 Pic
.End_Float
:= Index
;
1198 Pic
.Picture
.Expanded
(Index
) := 'b';
1202 Pic
.End_Float
:= Index
;
1203 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1215 when 'V' |
'v' |
'.' =>
1216 Pic
.Radix_Position
:= Index
;
1218 Number_Fraction_Or_Bracket
;
1225 end Floating_Bracket
;
1227 --------------------
1228 -- Floating_Minus --
1229 --------------------
1231 procedure Floating_Minus
is
1239 when '_' |
'0' |
'/' =>
1240 Pic
.End_Float
:= Index
;
1244 Pic
.End_Float
:= Index
;
1245 Pic
.Picture
.Expanded
(Index
) := 'b';
1249 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1250 Pic
.End_Float
:= Index
;
1257 when '.' |
'V' |
'v' =>
1258 Pic
.Radix_Position
:= Index
;
1261 while Is_Insert
loop
1278 Pic
.Max_Trailing_Digits
:=
1279 Pic
.Max_Trailing_Digits
+ 1;
1280 Pic
.End_Float
:= Index
;
1283 when '_' |
'0' |
'/' =>
1287 Pic
.Picture
.Expanded
(Index
) := 'b';
1312 procedure Floating_Plus
is
1320 when '_' |
'0' |
'/' =>
1321 Pic
.End_Float
:= Index
;
1325 Pic
.End_Float
:= Index
;
1326 Pic
.Picture
.Expanded
(Index
) := 'b';
1330 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1331 Pic
.End_Float
:= Index
;
1338 when '.' |
'V' |
'v' =>
1339 Pic
.Radix_Position
:= Index
;
1342 while Is_Insert
loop
1359 Pic
.Max_Trailing_Digits
:=
1360 Pic
.Max_Trailing_Digits
+ 1;
1361 Pic
.End_Float
:= Index
;
1364 when '_' |
'0' |
'/' =>
1368 Pic
.Picture
.Expanded
(Index
) := 'b';
1394 function Is_Insert
return Boolean is
1400 case Pic
.Picture
.Expanded
(Index
) is
1402 when '_' |
'0' |
'/' => return True;
1405 Pic
.Picture
.Expanded
(Index
) := 'b'; -- canonical
1408 when others => return False;
1412 --------------------
1413 -- Leading_Dollar --
1414 --------------------
1416 -- Note that Leading_Dollar can be called in either State.
1417 -- It will set state to Okay only if a 9 or (second) $ is encountered.
1419 -- Also notice the tricky bit with State and Zero_Suppression.
1420 -- Zero_Suppression is Picture_Error if a '$' or a '9' has been
1421 -- encountered, exactly the cases where State has been set.
1423 procedure Leading_Dollar
is
1425 -- Treat as a floating dollar, and unwind otherwise
1428 Pic
.Start_Currency
:= Index
;
1429 Pic
.End_Currency
:= Index
;
1430 Pic
.Start_Float
:= Index
;
1431 Pic
.End_Float
:= Index
;
1433 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
1445 when '_' |
'0' |
'/' =>
1446 Pic
.End_Float
:= Index
;
1449 -- A trailing insertion character is not part of the
1450 -- floating currency, so need to look ahead.
1453 Pic
.End_Float
:= Pic
.End_Float
- 1;
1457 Pic
.End_Float
:= Index
;
1458 Pic
.Picture
.Expanded
(Index
) := 'b';
1462 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
1464 if State
= Okay
then
1465 raise Picture_Error
;
1467 -- Will overwrite Floater and Start_Float
1473 if State
= Okay
then
1474 raise Picture_Error
;
1476 -- Will overwrite Floater and Start_Float
1482 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1483 Pic
.End_Float
:= Index
;
1484 Pic
.End_Currency
:= Index
;
1485 Set_State
(Okay
); Skip
;
1488 if State
/= Okay
then
1490 Pic
.Start_Float
:= Invalid_Position
;
1491 Pic
.End_Float
:= Invalid_Position
;
1494 -- A single dollar does not a floating make
1499 when 'V' |
'v' |
'.' =>
1500 if State
/= Okay
then
1502 Pic
.Start_Float
:= Invalid_Position
;
1503 Pic
.End_Float
:= Invalid_Position
;
1506 -- Only one dollar before the sign is okay, but doesn't
1509 Pic
.Radix_Position
:= Index
;
1511 Number_Fraction_Or_Dollar
;
1525 -- This one is complex. A Leading_Pound can be fixed or floating,
1526 -- but in some cases the decision has to be deferred until we leave
1527 -- this procedure. Also note that Leading_Pound can be called in
1530 -- It will set state to Okay only if a 9 or (second) # is
1533 -- One Last note: In ambiguous cases, the currency is treated as
1534 -- floating unless there is only one '#'.
1536 procedure Leading_Pound
is
1538 Inserts
: Boolean := False;
1539 -- Set to True if a '_', '0', '/', 'B', or 'b' is encountered
1541 Must_Float
: Boolean := False;
1542 -- Set to true if a '#' occurs after an insert
1545 -- Treat as a floating currency. If it isn't, this will be
1546 -- overwritten later.
1550 Pic
.Start_Currency
:= Index
;
1551 Pic
.End_Currency
:= Index
;
1552 Pic
.Start_Float
:= Index
;
1553 Pic
.End_Float
:= Index
;
1555 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
1558 Pic
.Max_Currency_Digits
:= 1; -- we've seen one.
1569 when '_' |
'0' |
'/' =>
1570 Pic
.End_Float
:= Index
;
1575 Pic
.Picture
.Expanded
(Index
) := 'b';
1576 Pic
.End_Float
:= Index
;
1581 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
1584 raise Picture_Error
;
1586 Pic
.Max_Leading_Digits
:= 0;
1588 -- Will overwrite Floater and Start_Float
1595 raise Picture_Error
;
1597 Pic
.Max_Leading_Digits
:= 0;
1599 -- Will overwrite Floater and Start_Float
1609 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1610 Pic
.End_Float
:= Index
;
1611 Pic
.End_Currency
:= Index
;
1616 if State
/= Okay
then
1618 -- A single '#' doesn't float
1621 Pic
.Start_Float
:= Invalid_Position
;
1622 Pic
.End_Float
:= Invalid_Position
;
1628 when 'V' |
'v' |
'.' =>
1629 if State
/= Okay
then
1631 Pic
.Start_Float
:= Invalid_Position
;
1632 Pic
.End_Float
:= Invalid_Position
;
1635 -- Only one pound before the sign is okay, but doesn't
1638 Pic
.Radix_Position
:= Index
;
1640 Number_Fraction_Or_Pound
;
1653 function Look
return Character is
1656 raise Picture_Error
;
1659 return Pic
.Picture
.Expanded
(Index
);
1671 when '_' |
'0' |
'/' =>
1675 Pic
.Picture
.Expanded
(Index
) := 'b';
1679 Computed_BWZ
:= False;
1680 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1684 when '.' |
'V' |
'v' =>
1685 Pic
.Radix_Position
:= Index
;
1699 -- Will return in Okay state if a '9' was seen
1704 -----------------------
1705 -- Number_Completion --
1706 -----------------------
1708 procedure Number_Completion
is
1710 while not At_End
loop
1713 when '_' |
'0' |
'/' =>
1717 Pic
.Picture
.Expanded
(Index
) := 'b';
1721 Computed_BWZ
:= False;
1722 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
1726 when 'V' |
'v' |
'.' =>
1727 Pic
.Radix_Position
:= Index
;
1736 end Number_Completion
;
1738 ---------------------
1739 -- Number_Fraction --
1740 ---------------------
1742 procedure Number_Fraction
is
1744 -- Note that number fraction can be called in either State.
1745 -- It will set state to Valid only if a 9 is encountered.
1753 when '_' |
'0' |
'/' =>
1757 Pic
.Picture
.Expanded
(Index
) := 'b';
1761 Computed_BWZ
:= False;
1762 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1763 Set_State
(Okay
); Skip
;
1769 end Number_Fraction
;
1771 --------------------------------
1772 -- Number_Fraction_Or_Bracket --
1773 --------------------------------
1775 procedure Number_Fraction_Or_Bracket
is
1784 when '_' |
'0' |
'/' => Skip
;
1787 Pic
.Picture
.Expanded
(Index
) := 'b';
1791 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1792 Pic
.End_Float
:= Index
;
1801 when '_' |
'0' |
'/' =>
1805 Pic
.Picture
.Expanded
(Index
) := 'b';
1809 Pic
.Max_Trailing_Digits
:=
1810 Pic
.Max_Trailing_Digits
+ 1;
1811 Pic
.End_Float
:= Index
;
1824 end Number_Fraction_Or_Bracket
;
1826 -------------------------------
1827 -- Number_Fraction_Or_Dollar --
1828 -------------------------------
1830 procedure Number_Fraction_Or_Dollar
is
1838 when '_' |
'0' |
'/' =>
1842 Pic
.Picture
.Expanded
(Index
) := 'b';
1846 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1847 Pic
.End_Float
:= Index
;
1856 when '_' |
'0' |
'/' =>
1860 Pic
.Picture
.Expanded
(Index
) := 'b';
1864 Pic
.Max_Trailing_Digits
:=
1865 Pic
.Max_Trailing_Digits
+ 1;
1866 Pic
.End_Float
:= Index
;
1879 end Number_Fraction_Or_Dollar
;
1881 ------------------------------
1882 -- Number_Fraction_Or_Pound --
1883 ------------------------------
1885 procedure Number_Fraction_Or_Pound
is
1894 when '_' |
'0' |
'/' =>
1898 Pic
.Picture
.Expanded
(Index
) := 'b';
1902 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1903 Pic
.End_Float
:= Index
;
1913 when '_' |
'0' |
'/' =>
1917 Pic
.Picture
.Expanded
(Index
) := 'b';
1921 Pic
.Max_Trailing_Digits
:=
1922 Pic
.Max_Trailing_Digits
+ 1;
1923 Pic
.End_Float
:= Index
;
1938 end Number_Fraction_Or_Pound
;
1940 ----------------------------------
1941 -- Number_Fraction_Or_Star_Fill --
1942 ----------------------------------
1944 procedure Number_Fraction_Or_Star_Fill
is
1953 when '_' |
'0' |
'/' =>
1957 Pic
.Picture
.Expanded
(Index
) := 'b';
1961 Pic
.Star_Fill
:= True;
1962 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
1963 Pic
.End_Float
:= Index
;
1973 when '_' |
'0' |
'/' =>
1977 Pic
.Picture
.Expanded
(Index
) := 'b';
1981 Pic
.Star_Fill
:= True;
1982 Pic
.Max_Trailing_Digits
:=
1983 Pic
.Max_Trailing_Digits
+ 1;
1984 Pic
.End_Float
:= Index
;
1998 end Number_Fraction_Or_Star_Fill
;
2000 -------------------------------
2001 -- Number_Fraction_Or_Z_Fill --
2002 -------------------------------
2004 procedure Number_Fraction_Or_Z_Fill
is
2013 when '_' |
'0' |
'/' =>
2017 Pic
.Picture
.Expanded
(Index
) := 'b';
2021 Pic
.Max_Trailing_Digits
:= Pic
.Max_Trailing_Digits
+ 1;
2022 Pic
.End_Float
:= Index
;
2023 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2034 when '_' |
'0' |
'/' =>
2038 Pic
.Picture
.Expanded
(Index
) := 'b';
2042 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2044 Pic
.Max_Trailing_Digits
:=
2045 Pic
.Max_Trailing_Digits
+ 1;
2046 Pic
.End_Float
:= Index
;
2059 end Number_Fraction_Or_Z_Fill
;
2061 -----------------------
2062 -- Optional_RHS_Sign --
2063 -----------------------
2065 procedure Optional_RHS_Sign
is
2074 Pic
.Sign_Position
:= Index
;
2079 Pic
.Sign_Position
:= Index
;
2080 Pic
.Picture
.Expanded
(Index
) := 'C';
2083 if Look
= 'R' or else Look
= 'r' then
2084 Pic
.Second_Sign
:= Index
;
2085 Pic
.Picture
.Expanded
(Index
) := 'R';
2089 raise Picture_Error
;
2095 Pic
.Sign_Position
:= Index
;
2096 Pic
.Picture
.Expanded
(Index
) := 'D';
2099 if Look
= 'B' or else Look
= 'b' then
2100 Pic
.Second_Sign
:= Index
;
2101 Pic
.Picture
.Expanded
(Index
) := 'B';
2105 raise Picture_Error
;
2111 if Pic
.Picture
.Expanded
(Pic
.Sign_Position
) = '<' then
2112 Pic
.Second_Sign
:= Index
;
2116 raise Picture_Error
;
2123 end Optional_RHS_Sign
;
2129 -- Note that Picture can be called in either State
2131 -- It will set state to Valid only if a 9 is encountered or floating
2132 -- currency is called.
2134 procedure Picture
is
2143 when '_' |
'0' |
'/' =>
2147 Pic
.Picture
.Expanded
(Index
) := 'b';
2159 Computed_BWZ
:= False;
2161 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2164 when 'V' |
'v' |
'.' =>
2165 Pic
.Radix_Position
:= Index
;
2178 ---------------------
2179 -- Picture_Bracket --
2180 ---------------------
2182 procedure Picture_Bracket
is
2184 Pic
.Sign_Position
:= Index
;
2185 Pic
.Sign_Position
:= Index
;
2187 -- Treat as a floating sign, and unwind otherwise
2190 Pic
.Start_Float
:= Index
;
2191 Pic
.End_Float
:= Index
;
2193 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
2196 Skip
; -- Known Bracket
2201 when '_' |
'0' |
'/' =>
2202 Pic
.End_Float
:= Index
;
2206 Pic
.End_Float
:= Index
;
2207 Pic
.Picture
.Expanded
(Index
) := 'b';
2211 Set_State
(Okay
); -- "<<>" is enough.
2217 when '$' |
'#' |
'9' |
'*' =>
2218 if State
/= Okay
then
2220 Pic
.Start_Float
:= Invalid_Position
;
2221 Pic
.End_Float
:= Invalid_Position
;
2229 when '.' |
'V' |
'v' =>
2230 if State
/= Okay
then
2232 Pic
.Start_Float
:= Invalid_Position
;
2233 Pic
.End_Float
:= Invalid_Position
;
2236 -- Don't assume that state is okay, haven't seen a digit
2243 raise Picture_Error
;
2247 end Picture_Bracket
;
2253 procedure Picture_Minus
is
2255 Pic
.Sign_Position
:= Index
;
2257 -- Treat as a floating sign, and unwind otherwise
2260 Pic
.Start_Float
:= Index
;
2261 Pic
.End_Float
:= Index
;
2263 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
2266 Skip
; -- Known Minus
2271 when '_' |
'0' |
'/' =>
2272 Pic
.End_Float
:= Index
;
2276 Pic
.End_Float
:= Index
;
2277 Pic
.Picture
.Expanded
(Index
) := 'b';
2281 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2282 Pic
.End_Float
:= Index
;
2284 Set_State
(Okay
); -- "-- " is enough
2289 when '$' |
'#' |
'9' |
'*' =>
2290 if State
/= Okay
then
2292 Pic
.Start_Float
:= Invalid_Position
;
2293 Pic
.End_Float
:= Invalid_Position
;
2302 -- Can't have Z and a floating sign
2304 if State
= Okay
then
2308 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2314 when '.' |
'V' |
'v' =>
2315 if State
/= Okay
then
2317 Pic
.Start_Float
:= Invalid_Position
;
2318 Pic
.End_Float
:= Invalid_Position
;
2321 -- Don't assume that state is okay, haven't seen a digit
2337 procedure Picture_Plus
is
2339 Pic
.Sign_Position
:= Index
;
2341 -- Treat as a floating sign, and unwind otherwise
2344 Pic
.Start_Float
:= Index
;
2345 Pic
.End_Float
:= Index
;
2347 -- Don't increment Pic.Max_Leading_Digits, we need one "real"
2355 when '_' |
'0' |
'/' =>
2356 Pic
.End_Float
:= Index
;
2360 Pic
.End_Float
:= Index
;
2361 Pic
.Picture
.Expanded
(Index
) := 'b';
2365 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2366 Pic
.End_Float
:= Index
;
2368 Set_State
(Okay
); -- "++" is enough
2373 when '$' |
'#' |
'9' |
'*' =>
2374 if State
/= Okay
then
2376 Pic
.Start_Float
:= Invalid_Position
;
2377 Pic
.End_Float
:= Invalid_Position
;
2385 if State
= Okay
then
2389 -- Can't have Z and a floating sign
2391 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2393 -- '+Z' is acceptable
2402 when '.' |
'V' |
'v' =>
2403 if State
/= Okay
then
2405 Pic
.Start_Float
:= Invalid_Position
;
2406 Pic
.End_Float
:= Invalid_Position
;
2409 -- Don't assume that state is okay, haven't seen a digit
2421 --------------------
2422 -- Picture_String --
2423 --------------------
2425 procedure Picture_String
is
2427 while Is_Insert
loop
2447 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2457 when '9' |
'.' |
'V' |
'v' =>
2463 raise Picture_Error
;
2467 -- Blank when zero either if the PIC does not contain a '9' or if
2468 -- requested by the user and no '*'.
2470 Pic
.Blank_When_Zero
:=
2471 (Computed_BWZ
or else Pic
.Blank_When_Zero
)
2472 and then not Pic
.Star_Fill
;
2474 -- Star fill if '*' and no '9'
2476 Pic
.Star_Fill
:= Pic
.Star_Fill
and then Computed_BWZ
;
2488 procedure Set_State
(L
: Legality
) is
2502 ----------------------
2503 -- Star_Suppression --
2504 ----------------------
2506 procedure Star_Suppression
is
2509 Pic
.Start_Float
:= Index
;
2510 Pic
.End_Float
:= Index
;
2511 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2514 -- Even a single * is a valid picture
2516 Pic
.Star_Fill
:= True;
2526 when '_' |
'0' |
'/' =>
2527 Pic
.End_Float
:= Index
;
2531 Pic
.End_Float
:= Index
;
2532 Pic
.Picture
.Expanded
(Index
) := 'b';
2536 Pic
.End_Float
:= Index
;
2537 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2538 Set_State
(Okay
); Skip
;
2545 when '.' |
'V' |
'v' =>
2546 Pic
.Radix_Position
:= Index
;
2548 Number_Fraction_Or_Star_Fill
;
2556 when others => raise Picture_Error
;
2559 end Star_Suppression
;
2561 ----------------------
2562 -- Trailing_Bracket --
2563 ----------------------
2565 procedure Trailing_Bracket
is
2568 Pic
.Second_Sign
:= Index
;
2571 raise Picture_Error
;
2573 end Trailing_Bracket
;
2575 -----------------------
2576 -- Trailing_Currency --
2577 -----------------------
2579 procedure Trailing_Currency
is
2586 Pic
.Start_Currency
:= Index
;
2587 Pic
.End_Currency
:= Index
;
2591 while not At_End
and then Look
= '#' loop
2592 if Pic
.Start_Currency
= Invalid_Position
then
2593 Pic
.Start_Currency
:= Index
;
2596 Pic
.End_Currency
:= Index
;
2607 when '_' |
'0' |
'/' => Skip
;
2610 Pic
.Picture
.Expanded
(Index
) := 'b';
2613 when others => return;
2616 end Trailing_Currency
;
2618 ----------------------
2619 -- Zero_Suppression --
2620 ----------------------
2622 procedure Zero_Suppression
is
2625 Pic
.Start_Float
:= Index
;
2626 Pic
.End_Float
:= Index
;
2627 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2628 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2633 -- Even a single Z is a valid picture
2641 when '_' |
'0' |
'/' =>
2642 Pic
.End_Float
:= Index
;
2646 Pic
.End_Float
:= Index
;
2647 Pic
.Picture
.Expanded
(Index
) := 'b';
2651 Pic
.Picture
.Expanded
(Index
) := 'Z'; -- consistency
2653 Pic
.Max_Leading_Digits
:= Pic
.Max_Leading_Digits
+ 1;
2654 Pic
.End_Float
:= Index
;
2663 when '.' |
'V' |
'v' =>
2664 Pic
.Radix_Position
:= Index
;
2666 Number_Fraction_Or_Z_Fill
;
2678 end Zero_Suppression
;
2680 -- Start of processing for Precalculate
2685 if State
= Reject
then
2686 raise Picture_Error
;
2691 when Constraint_Error
=>
2693 -- To deal with special cases like null strings
2695 raise Picture_Error
;
2704 (Pic_String
: String;
2705 Blank_When_Zero
: Boolean := False) return Picture
2711 Item
: constant String := Expand
(Pic_String
);
2714 Result
.Contents
.Picture
:= (Item
'Length, Item
);
2715 Result
.Contents
.Original_BWZ
:= Blank_When_Zero
;
2716 Result
.Contents
.Blank_When_Zero
:= Blank_When_Zero
;
2717 Precalculate
(Result
.Contents
);
2723 raise Picture_Error
;
2731 function To_Wide
(C
: Character) return Wide_Character is
2733 return Wide_Character'Val (Character'Pos (C
));
2741 (Pic_String
: String;
2742 Blank_When_Zero
: Boolean := False) return Boolean
2746 Expanded_Pic
: constant String := Expand
(Pic_String
);
2747 -- Raises Picture_Error if Item not well-formed
2749 Format_Rec
: Format_Record
;
2752 Format_Rec
.Picture
:= (Expanded_Pic
'Length, Expanded_Pic
);
2753 Format_Rec
.Blank_When_Zero
:= Blank_When_Zero
;
2754 Format_Rec
.Original_BWZ
:= Blank_When_Zero
;
2755 Precalculate
(Format_Rec
);
2757 -- False only if Blank_When_0 is True but the pic string has a '*'
2759 return not Blank_When_Zero
2760 or else Strings_Fixed
.Index
(Expanded_Pic
, "*") = 0;
2764 when others => return False;
2767 end Ada
.Wide_Text_IO
.Editing
;