Date: Mon, 17 Sep 2007 15:32:30 +1000 (EST) From: Bruce Evans <brde@optusnet.com.au> To: "Sean C. Farley" <scf@FreeBSD.org> Cc: Xin LI <delphij@FreeBSD.org>, freebsd-standards@FreeBSD.org Subject: Re: vfprintf() string precision type Message-ID: <20070917152627.V29498@delplex.bde.org> In-Reply-To: <alpine.BSF.0.9999.0709161922560.29967@thor.farley.org> References: <alpine.BSF.0.9999.0709161922560.29967@thor.farley.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 16 Sep 2007, Sean C. Farley wrote: > Xin LI noticed a warning in the code I wrote for setenv() where a > precision was provided with a string argument to warnx() (really > vfprintf()). The warning appearing on amd64 and not i386 showed that > precisions are always 32-bit. > > Would it be better to change the precision handling to expect size_t? No. This would be a large standards violation. > My reasoning is that strlen() and sizeof both return size_t. It makes a > cast unnecessary for passing a value returned by either call as the > precision. Unfortunately, I could find nothing from SUSv3 that > specified what type the precision could be. >From n869.txt: [#5] As noted above, a field width, or precision, or both, may be indicated by an asterisk. In this case, an int argument supplies the field width or precision. The >From POSIX-2001 draft7.txt: 13174 A field width, or precision, or both, may be indicated by an asterisk ('*'). In this case an 13175 argument of type int supplies the field width or precision. Applications shall ensure that >From printf.3: A field width or precision, or both, may be indicated by an asterisk .Ql * or an asterisk followed by one or more decimal digits and a .Ql $ instead of a digit string. In this case, an .Vt int argument supplies the field width or precision. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070917152627.V29498>