This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: snprintfv 1.1 pre-release
- From: Bruce Korb <bkorb at veritas dot com>
- To: "Joseph S. Myers" <jsm at polyomino dot org dot uk>, austin-group-l at opengroup dot org
- Cc: Paolo Bonzini <bonzini at gnu dot org>, jlquinn at optonline dot net, Paolo Carlini <pcarlini at unitus dot it>, GCC Development <gcc at gcc dot gnu dot org>
- Date: Thu, 24 Jul 2003 09:57:29 -0700
- Subject: Re: snprintfv 1.1 pre-release
- References: <001101c351f8$a10144a0$0315623e@philo> <Pine.LNX.4.56.0307241732500.24238@kern.srcf.societies.cam.ac.uk>
- Reply-to: bkorb at veritas dot com
"Joseph S. Myers" wrote:
>
> On Thu, 24 Jul 2003, Paolo Bonzini wrote:
>
> > * there is support for width/precision positional parameters (%NNN$s was
> > supported in 1.0 too), like
> >
> > printf ("%2$*1$s", "fubar", -10);
>
> This, of course, being an erroneous example, taking "fubar" as the width
> and -10 as the string to be formatted.
Well, I confess I don't know what is right. What you say, Joseph, corresponds
to my reading of the standard. However, in experiments with Sun's libc and
Linux's glibc:
> $ cat xx.c
> #include <stdio.h>
>
> int
> main( int argc, char** argv )
> {
> printf( "%%2$*1$d: ==%2$*1$d==\n", 11, 22 );
> printf( "%%1$*2$d: ==%2$*1$d==\n", 11, 22 );
> printf( "%%*d: ==%2$*1$d==\n", 11, 22 );
> return 0;
> }
> $ cc -o xx xx.c
> $ ./xx
> %2$*1$d: == 22==
> %1$*2$d: == 22==
> %*d: == 22==
> $ gcc -o yy xx.c
> $ ./yy
> %2$*1$d: == 22==
> %1$*2$d: == 22==
> %*d: == 22==
I'm pretty sure that something has to be wrong. What? Can we say
that both are in non-compliance and the results should be this?
> %2$*1$d: == 22==
> %1$*2$d: == 11==
> %*d: == 22==