snprintfv 1.1 pre-release
Bruce Korb
bkorb@veritas.com
Thu Jul 24 17:29:00 GMT 2003
"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==
More information about the Gcc
mailing list