[Ada] Correct handling of fill character in Text_IO.Editing
Arnaud Charlet
charlet@adacore.com
Wed Mar 26 08:07:00 GMT 2008
Tested on i686-linux, committed on trunk
This patch corrects two bugs which canceled one another out
well enough that this bug has not been noticed till now. First,
the default fill character was defined as space, instead of
'*'. Second in the body, '*' was used explicitly to fill out
the result instead of Fill_Character.
The result was that '*' appeared correctly in the default
case but overriding this did not work.
The following is a test program:
with Ada.Text_IO.Editing; use Ada.Text_IO.Editing;
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Fill is
type Dec is delta 0.01 digits 8;
package Dout1 is new Decimal_Output (Dec);
package Dout2 is new Decimal_Output (Dec, Default_Fill => 'x');
Dval : Dec := 3.45;
Pic : Picture := To_Picture ("****9.99");
begin
Put_Line (Dout1.Image (Dval, Pic));
Put_Line (Dout1.Image (Dval, Pic, Fill => '+'));
Put_Line (Dout2.Image (Dval, Pic));
Put_Line (Dout2.Image (Dval, Pic, Fill => '%'));
end Test_Fill;
The output should be:
****3.45
++++3.45
xxxx3.45
%%3.45
Before the patch, all lines were ****3.45
2008-03-26 Robert Dewar <dewar@adacore.com>
* a-teioed.ads: Correct value of Default_Fill
* a-teioed.adb (Image): Use Fill_Character instead of '*' to fill
-------------- next part --------------
Index: a-teioed.ads
===================================================================
--- a-teioed.ads (revision 133430)
+++ a-teioed.ads (working copy)
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
@@ -55,7 +55,7 @@ package Ada.Text_IO.Editing is
Picture_Error : exception;
Default_Currency : constant String := "$";
- Default_Fill : constant Character := ' ';
+ Default_Fill : constant Character := '*';
Default_Separator : constant Character := ',';
Default_Radix_Mark : constant Character := '.';
Index: a-teioed.adb
===================================================================
--- a-teioed.adb (revision 133430)
+++ a-teioed.adb (working copy)
@@ -417,7 +417,7 @@ package body Ada.Text_IO.Editing is
Answer (J) := Separator_Character;
elsif Answer (J) = 'b' then
- Answer (J) := '*';
+ Answer (J) := Fill_Character;
end if;
end loop;
@@ -426,7 +426,7 @@ package body Ada.Text_IO.Editing is
end if;
for J in Pic.Start_Float .. Position loop
- Answer (J) := '*';
+ Answer (J) := Fill_Character;
end loop;
else
More information about the Gcc-patches
mailing list