Andreas Schwab wrote: > Greg Wooledge <wool...@eeg.ccf.org> writes: > >> It doesn't mention a null pointer. The OpenBSD man page does explicitly >> say the null pointer is allowed if size is zero. The GNU/Linux man page >> says that SUSv2 and C99 disagree, but that the implementation follows >> C99 (allowing the null pointer when size is 0). > > Note that there are more differences between SUSv2 and POSIX.1-2008/C99: > The SUSv2 version of snprintf returns the actual number of bytes written > (excluding the terminating NUL if any), whereas the C99 version returns > the number of bytes that would have been written (excluding the > terminating NUL) if the buffer would be big enough.
That is true. There is a note in the Posix.1-2008/SUSv3 description that explicitly states that the functionality is supposed to align with the C standard and defers to C99 in case of conflict. I try to write to the current (well, ten-year-old) standards. The replacement in lib/sh/snprintf.c behaves as C99 specifies; you might try using it by #undefing HAVE_VSNPRINTF and HAVE_SNPRINTF in config.h. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/