+2010-12-23 Paul Eggert <eggert@cs.ucla.edu>
+
+ vsnprintf: make more consistent with snprintf; doc fixes
+
+ * doc/posix-functions/snprintf.texi (snprintf): The workaround for
+ the byte count return problem was promoted from the snprintf-posix
+ to the snprintf module.
+ * doc/posix-functions/vsnprintf.texi (vsnprintf): Likewise.
+ * m4/vsnprintf.m4 (gl_FUNC_VSNPRINTF): Also check
+ gl_SNPRINTF_RETVAL_C99, for consistency with gl_FUNC_SNPRINTF.
+ * tests/test-snprintf.c (main): Check the byte count returned.
+ * tests/test-vsnprintf.c (main): Likewise.
+
2010-12-23 Eric Blake <eblake@redhat.com>
sigpipe: relax to LGPLv2+, since it did not have any LGPLv3+ parts
This function is missing on some platforms:
IRIX 5.3, OSF/1 4.0, Solaris 2.5.1.
@item
+This function does not return a byte count as specified in C99 on some platforms:
+HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, mingw.
+@item
This function overwrites memory even when a size argument of 1 is passed on some
platforms:
Linux libc5.
This function does not truncate the result as specified in C99 on some platforms:
mingw.
@item
-This function does not return a byte count as specified in C99 on some platforms:
-HP-UX 11, IRIX 6.5, OSF/1 5.1, mingw.
-@item
This function does not fully support the @samp{n} directive on some platforms:
HP-UX 11, mingw.
@item
This function overwrites memory even when a size argument of 1 is passed on some
platforms:
Linux libc5.
+@item
+This function does not return a byte count as specified in C99 on some platforms:
+HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, mingw.
@end itemize
Portability problems fixed by Gnulib module @code{vsnprintf-posix}:
This function does not truncate the result as specified in C99 on some platforms:
mingw.
@item
-This function does not return a byte count as specified in C99 on some platforms:
-HP-UX 11, IRIX 6.5, OSF/1 5.1, mingw.
-@item
This function does not fully support the @samp{n} directive on some platforms:
HP-UX 11, mingw.
@item
gl_SNPRINTF_SIZE1
case "$gl_cv_func_snprintf_size1" in
*yes)
- gl_cv_func_vsnprintf_usable=yes
+ gl_SNPRINTF_RETVAL_C99
+ case "$gl_cv_func_snprintf_retval_c99" in
+ *yes)
+ gl_cv_func_vsnprintf_usable=yes
+ ;;
+ esac
;;
esac
fi
int size;
int retval;
+ retval = snprintf (NULL, 0, "%d", 12345);
+ ASSERT (retval == 5);
+
for (size = 0; size <= 8; size++)
{
memcpy (buf, "DEADBEEF", 8);
retval = snprintf (buf, size, "%d", 12345);
+ ASSERT (retval == 5);
if (size < 6)
{
-#if CHECK_SNPRINTF_POSIX
- ASSERT (retval < 0 || retval >= size);
-#endif
if (size > 0)
{
ASSERT (memcmp (buf, "12345", size - 1) == 0);
}
else
{
- ASSERT (retval == 5);
ASSERT (memcmp (buf, "12345\0EF", 8) == 0);
}
}
int size;
int retval;
+ retval = my_snprintf (NULL, 0, "%d", 12345);
+ ASSERT (retval == 5);
+
for (size = 0; size <= 8; size++)
{
memcpy (buf, "DEADBEEF", 8);
retval = my_snprintf (buf, size, "%d", 12345);
+ ASSERT (retval == 5);
if (size < 6)
{
-#if CHECK_VSNPRINTF_POSIX
- ASSERT (retval < 0 || retval >= size);
-#endif
if (size > 0)
{
ASSERT (memcmp (buf, "12345", size - 1) == 0);
}
else
{
- ASSERT (retval == 5);
ASSERT (memcmp (buf, "12345\0EF", 8) == 0);
}
}