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]

printf and glibc extensions


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

Is there any interest in the following glibc extensions to printf?  I ask
for two reasons - one, making it easier to port glibc programs that use
non-standard formats, and two, since gcc's __format__ attribute already
covers these extensions.

printf("%m", ENOENT) short for printf("%s", strerror(ENOENT))
printf("%Zu", (size_t)1) alias for printf("%zu", (size_t)1)
printf("%Ld", (long long)1) alias for printf("%lld", (long long)1)

Also, %p is implementation defined, but it would be nice if we followed glibc:
printf("%p", NULL) prints "(nil)" rather than "0x0".

This goes along other extensions to C99/POSIX already in newlib printf:

printf("%s", NULL) behaves like printf("(null)")
printf("%qd", (long long)1) alias for printf("%lld", (long long)1)
printf("%D", (long long)1) alias for printf("%lld", (long long)1)
printf("%O", (long long)1) alias for printf("%llo", (long long)1)
printf("%U", (long long)1) alias for printf("%llu", (long long)1)

Obviously, the new extensions would need to be controlled by a configure
time switch (and perhaps some of the old ones grouped into that switch, so
that a strict environment has smaller code size).  I'm thinking
- --enablie-newlib-io-extensions, similar to the existing
- --enable-newlib-io-pos-args, --enable-newlib-io-long-long, and
- --enable-newlib-io-long-double.

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

iD8DBQFGHvsq84KuGfSFAYARAtPQAJwJKwjPltJVJURBxSdLrIG25MjHwQCZAfah
d2LwOwli8s/6moUb7fFgQGI=
=Pky5
-----END PGP SIGNATURE-----


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