Roland Mainz writes: > James Carlson wrote: > [snip] > > As for strMANYcat, the operation seems sort of obvious and somewhat > > useful, but I wonder how often in real, well-written code this > > situation actually comes up _and_ snprintf isn't a better answer. > > Umpf. See my original posting. My intention was to improve performance > and usuability. |snprintf()| would make it slower. MUCH slower.
I don't believe it makes any noticable difference for any plausible usage model. In other words, prove it. > And: snprintf() may be evil - see Mozilla.org Bug 332006 > (https://bugzilla.mozilla.org/show_bug.cgi?id=332006 - "Avoid raw calls > to snprintf"). That bug report is either just a Linux library flaw or pure bunkum. It is most emphatically not the case that snprintf can ever return a non-terminated buffer. This is actually set by standard -- snprintf is part of SUSv3. Here's the relevant section of the Solaris man page: The snprintf() function is identical to sprintf() with the addition of the argument n, which specifies the size of the buffer referred to by s. If n is 0, nothing is written and s can be a null pointer. Otherwise, output bytes beyond the n-1st are discarded instead of being written to the array and a null byte is written at the end of the bytes actually written into the array. And here's the relevant section of SUSv3 from opengroup.org: The snprintf() function shall be equivalent to sprintf(), with the addition of the n argument which states the size of the buffer referred to by s. If n is zero, nothing shall be written and s may be a null pointer. Otherwise, output bytes beyond the n-1st shall be discarded instead of being written to the array, and a null byte is written at the end of the bytes actually written into the array. In other words, the person who filed that bug report seems to have been confused. Maybe he was thinking of strncpy and strncat. -- James Carlson, KISS Network <[EMAIL PROTECTED]> Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084 MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677 _______________________________________________ opensolaris-discuss mailing list [email protected]
