avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] [bugs #9345] Zero-Padding on vfprintf


From: Joerg Wunsch
Subject: Re: [avr-libc-dev] [bugs #9345] Zero-Padding on vfprintf
Date: Tue, 28 Dec 2004 20:31:34 +0100
User-agent: Mutt/1.4.2.1i

As anonymous wrote:

> Summary:  Zero-Padding on vfprintf

> Original Submission: Any zero padding when using %f in vfprintf is
> removed as soon as any precision is used.

> double x = 12.34;
> %10f gives result: 012.340000
> %08.2f gives result: 12.34 (Space padded)

> The latter output should be:
> 00012.34

I just committed the attached patch to CVS.  It is supposed to fix
this problem.  If someone wants to review it, a few hints about the
logic:

. if a percent sign had been seen, the first part of the larg
  `if' statement inside the format string scan loop is entered

. if a digit has been found, it will be accumulated in `prec' unless
  it is a `0' *and* the very first digit of the current format (prec
  will later be copied to width)

. if later a dot is found, it will be recorded that we do have a
  precision present, and the `prec' calculation starts anew; this
  is where the logico happened: the zero-pad flag had been cleaned
  in order to re-enter the number calculation above; this was
  incorrect

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)

Attachment: vfprintf.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]