implement scanf("%2$i", &int1, &int2)

Eric Blake ebb9@byu.net
Mon May 21 13:25:00 GMT 2007


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

OK to apply?  I used printf as a model, but positional args in scanf
turned out to be a lot easier than positional arguments in printf :)

Also, I noticed that printf (and thus my scanf patch) goes to great
lengths to ensure it does not overflow the internal array of MAX_POS_ARGS
stored arguments, as well as trying to support mixed positional and
non-positional arguments; however, POSIX is clear that behavior is
undefined if positional and non-positional arguments are mixed in the same
format string, or if more than NL_ARGMAX indices are requested.  Is it
worth trying to simplify the code here by allowing array overflow on
non-compliant format strings, rather than trying to be accommodating?

2007-05-21  Eric Blake  <ebb9@byu.net>

	* libc/stdio/vfscanf.c (__SVFSCANF_R): Support scanf(%1$s).
	Avoid warning when !FLOATING_POINT.
	* libc/stdio/vfprintf.c (_VFPRINTF_R): Simplify _NO_POS_ARGS
	slightly.

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

Eric Blake             ebb9@byu.net
-----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

iD8DBQFGUZW+84KuGfSFAYARAtz/AJ4oN5pKXJYeKvidIzcmHECfq5wcnACcD+D8
xNL/2XMaNg7H0gDzPFDKBcI=
=Hda6
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: newlib.patch18
URL: <http://sourceware.org/pipermail/newlib/attachments/20070521/2b9dba15/attachment.ksh>


More information about the Newlib mailing list