This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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: printf field width argument handling


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

According to Eric Blake on 11/24/2009 9:55 PM:
>> A suggestion for the error reaction is to stop conversion, return
>> an error, and set errno to EINVAL.  EINVAL seems the most appropriate,
>> as the format argument is invalid in the example case.
> 
> What does glibc print/return for the given example?

Actually, after testing printf("%**s",1,"a","b")

on Solaris 10, it treats the pointer for "a" as an integer, and prints "b"
with the corresponding field width, without setting errno, and returning
the number of bytes printed.  In other words, newlib behavior matches
Solaris behavior.

on an older glibc box, it prints "%1*s", and returns 4 without setting errno.

Do we even have precedence of any other implementation that rejects the
string with a negative return value?

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

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

iEYEARECAAYFAksMvQgACgkQ84KuGfSFAYB2+QCgtgUMv7BrZcZJv5U/za0JPRGh
PnsAnAzLIGVkWIh6HCbRKeYsUfYC7m59
=ILPi
-----END PGP SIGNATURE-----


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