Paul Eggert <[email protected]> writes: > On 02/08/11 12:34, Ben Pfaff wrote: >> The INT_STRLEN_BOUND macro in Gnulib's intprops.h calculates the >> maximum number of bytes in a formatted integer, on the basis that >> the minus sign and each digit will occupy one byte. If *printf >> is used for formatting integers, is this a good assumption >> outside of the C locale? > > Yes and no. It's safe for %d, but it's not safe for arbitrary > formats. This is true even in the C locale; for example, %1000d > is not safe for INT_STRLEN_BOUND. Any code that uses > INT_STRLEN_BOUND with weird formats like %Id or %'d or %1000d > is busted and should get fixed.
Thanks. I was assuming a plain format such as %d. Does your answer come from experience with many implementations, or is it based on knowledge of some document or standard? I'd like to be able to know why the answer is true, if I can. -- Ben Pfaff http://benpfaff.org
