bug-gnulib
[Top][All Lists]
Advanced

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

Re: printf failure on HP/UX 10.20 with 6.9.92


From: Eric Blake
Subject: Re: printf failure on HP/UX 10.20 with 6.9.92
Date: Mon, 04 Feb 2008 21:14:08 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[adding bug-gnulib, since this affects more than just coreutils]

According to Peter Fales on 2/4/2008 4:00 PM:
| 2) I can see what's happening, though I'm not quite sure how it's supposed
|    to work.   When the gnulib vsnprintf("%*s",-3,"x") is called, it
|    ends up eventually calling the the system snprintf through the
SNPRINTF_BUF
|    macro as  snprint(result+length, maxlen, "%-*s%n", -3, "x", &count);
|
|    It looks like the system snprintf is buggy.  I suspect the '-' character
|    in the format specification is negating the value of the -3 argument.

Indeed, that seems like the bug.  Bruno, it looks like we need to add
another test to the printf replacement suite.

|
|    On the system in question, this test program
|
|       main()
|       {
|               int count;
|       
|               printf("1 %*s%n\n",-3,"x",&count);
|               printf("1 %-*s%n\n",-3,"x",&count);
|               printf("1 %-*s%n\n",3,"x",&count);
|       }
|
|     prints
|
|       1 x
|       1   x
|       1 x

And that violates C99/POSIX.  Duplication of the `-' flag should not
disable it.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHp+KQ84KuGfSFAYARAs1KAKCq2sTdm5WWGRg7RIs9afvptrSTOgCfX2Xz
UpKtEpi1VIpDkWPe+kGyiBY=
=9CNT
-----END PGP SIGNATURE-----




reply via email to

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