This is the mail archive of the gcc@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]

Re: snprintfv 1.1 pre-release


"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==


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