This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Correct handling of fill character in Text_IO.Editing


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

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]