Hello,
On Tuesday 04 March 2008 17:28:57 Johannes Sixt wrote:
Heh. My first one was VSNPRINTF_RETURNS_MINUS_1...
I did my homework and prepared this:
#include "stdio.h"
#include "stdarg.h"
int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
{
int ret;
va_list ap;
va_start(ap, format);
ret = vsnprintf(str, maxsize, format, ap);
va_end(ap);
return ret;
}
int main(void)
{
char buf[10];
int ret;
ret = test_vsnprintf(buf, 1, "%s", "12345");
printf("case1: %d\n", ret);
ret = test_vsnprintf(buf, 5, "%s", "12345");
printf("case2: %d\n", ret);
ret = test_vsnprintf(buf, 6, "%s", "12345");
printf("case3: %d\n", ret);
ret = test_vsnprintf(buf, 10, "%s", "12345");
printf("case4: %d\n", ret);
return 0;
}
which returns:
Linux 2.6.25-rc3-mr i686
case1: 5
case2: 5
case3: 5
case4: 5
HP-UX B.11.11 9000/800
case1: -1
case2: -1
case3: 5
case4: 5
HP-UX B.11.23 ia64
case1: -1
case2: -1
case3: 5
case4: 5
So HPUX impl is the same as a Windows one. So we can share the replacement.
Please note that there's no va_copy() on HPUX.
I think that Tru64 has the same issue, but I have no HW to test it on now.
Could somebody else try to run testcase above on some other OSes?
Thanks
Michal
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html