Subject: Re: bin/8880: Output from pac not always formatted correctly.
To: None <dolecek@ics.muni.cz>
From: Giles Lean <giles@nemeton.com.au>
List: tech-userlevel
Date: 12/03/1999 08:23:48
On Sat, 27 Nov 1999 12:39:23 +0100 Jaromir Dolecek wrote:
> seems like ANSI C and POSIX doesn't aggree on usage of "width" for
> %s type for printf(3).
> ...
> Am I seriously confused or the POSIX and ANSI C really don't treat
> this the same way ? If so, it's rather unfortunate ...
Since POSIX references the C standard for this, there isn't an
inconsistency. I can't tell if you're confused or not. :-)
[From the O'Reilly POSIX Programmer's Guide]
> Description Meaning of width Meaning of precision
> s Argument is assumed to be Specifies the maximum UNDEFINED
> char *. Characters up to (but number of characters
> not including) a terminating to be written.
> null are written.
Answer: the book is wrong. The width is the minimum width of the
field. The precision is the maximum number of characters to use from
the argument.
In preference to this book, I recommend using the "Single Unix
Standard" which is freely accessible at http://www.opengroup.org.
(This isn't the only error I have found in the O'Reilly POSIX book,
but since I haven't used it much (I now have the real standards) I
don't really know if I've found the only errors, or if it is just
inaccurate. Maybe there is an errata page at www.oreilly.com?)
Regards,
Giles