autoconf
[Top][All Lists]
Advanced

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

Re: Question regarding sscanf() vs. off_t and similar


From: Eric Blake
Subject: Re: Question regarding sscanf() vs. off_t and similar
Date: Thu, 14 Sep 2006 19:55:46 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Thunderbird/1.5.0.5 Mnenhy/0.7.4.666

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

According to Ben Pfaff on 9/14/2006 10:19 AM:
> Philipp Marek <address@hidden> writes:
> 
>> On Thursday 14 September 2006 14:49 Eric Blake wrote:
>>> Gnulib provides umaxtostr.c, which is a convenient way of printing any
>>> integer of unknown width:
>>>
>>> char buf[INT_BUFSIZE_BOUND (uintmax_t)];
>>> sprintf("%s %s", umaxtostr(ino, buf), name);
>> But then I'd need a few of these buffers in a sprintf() call with 15 
>> arguments, and if umaxtostr() is not available on solaris etc. I can't use 
>> it ...
> 
> If you use Gnulib, then umaxtostr will be available everywhere.

Gnulib also provides a portable PRIuMAX, so that you could do this, if you
don't want to commit to providing multiple buffers to umaxtostr:
sprintf("%"PRIuMAX" %s", (uintmax_t) ino, name);

And gettext 0.15 understands PRIuMAX, converting it as needed on various
platforms, if you intend to internationalize your program.

- --
Life is short - so eat dessert first!

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

iD8DBQFFCggi84KuGfSFAYARAumnAJ0cEEVIYckQQwED4475/6fpLGvBbQCgv6qS
F09pOALdKeSaa0YWx9q8CVk=
=wdFV
-----END PGP SIGNATURE-----




reply via email to

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