From 52bdfd3dca744bbf16acdc40591022a3c48c918d Mon Sep 17 00:00:00 2001 From: Sascha Schumann Date: Sat, 28 Jun 2003 12:29:07 +0000 Subject: [PATCH] Fix snprintf test. C99 allows for the Single Unix Spec semantics which prescribe a return value of -1 for n == 0 which is treated as an encoding error. This reenables use of snprintf on Solaris at least. Relevant excerpts from ection 7.19.6.5: Description [..] If n is zero, nothing is written, and s may be a null pointer. [..] Returns The snprintf function returns the number of characters that would have been written had n been sufficiently large, not counting the terminating null character, or a negative value if an encoding error occurred. Single Unix Spec: http://www.opengroup.org/onlinepubs/007908799/xsh/fprintf.html --- acinclude.m4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index 356fe1e441..68590a0e9d 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1186,7 +1186,9 @@ main() { int res = 0; res = res || (snprintf(buf, 2, "marcus") != 6); res = res || (buf[1] != '\0'); - res = res || (snprintf(buf, 0, "boerger") != 7); + /* Implementations may consider this as an encoding error */ + snprintf(buf, 0, "boerger"); + /* However, they MUST ignore the pointer */ res = res || (buf[0] != 'm'); res = res || (snprintf(NULL, 0, "boerger") != 7); res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8); -- 2.50.1