develooper Front page | perl.perl5.porters | Postings from January 2003

Re: [perl #20339] Possible sprintf problem in perl5.8.0

Thread Previous | Thread Next
From:
sthoenna
Date:
January 16, 2003 11:48
Subject:
Re: [perl #20339] Possible sprintf problem in perl5.8.0
Message ID:
pgwJ+gzkgWea092yn@efn.org
On Thu, 16 Jan 2003 16:55:06 +0000, hv@crypt.org wrote:
>Jason Lee (via RT) <perlbug-followup@perl.org> wrote:
>:After compiling and installing perl 5.8.0 without any problems I have
>:encountered some weird behaviour with sprintf.
>:
>:This was highlighted by a failing "make test" of Text-Autoformt-1.04 module
>:and later by some simple sprintf examples which can all be found as detailed
>:below.
>[...]
>:Simple example
>:
>:# perl -e 'print sprintf "%6.2lf\n", 1;'
>:%6.2lf
>:# perl -e 'print sprintf "%6.2f\n", 1;'
>:  1.00
>
>One of the side-effects of improvements to the sprintf code for 5.8.0
>was stricter checking of size modifiers.
>
>The docs for my local C library sprintf suggest that the "l" modifier
>is relevant only for integer conversions and the "s" and "n" formats;
>long doubles should be requested using "L", "q" or "ll". Do you have
>reason to believe that "l" should also be supported? If not, I'd
>suggest that Text-Autoformat may be wrong here.

C99 says:
  l (ell)      Specifies that a following d, i, o, u, x, or  X
               conversion  specifier  applies to a long int or
               unsigned long int argument; that a following  n
               conversion  specifier applies to a pointer to a
               long  int  argument;   that   a   following   c
               conversion   specifier   applies  to  a  wint_t
               argument;  that  a   following   s   conversion
               specifier  applies  to  a  pointer to a wchar_t
               argument; or has no effect on a following a, A,
               e, E, f, F, g, or G conversion specifier.

so I think %lf should be silently treated as %f.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About