Re: [PATCH] Add compat/vsnprintf.c for systems that returns -1 on maxsize reached
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Mar 5, 2008, 09:18 UTC
- Message-ID
- <47CE6552.60308@viscovery.net>
- In-Reply-To
- <200803050937.40345.michal.rokos@nextsoft.cz>
Michal Rokos schrieb:
Show 14 quoted lines
> 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.
It's not the same on Windows, which returns:
case1: -1 case2: 5 case3: 5 case4: 5
IOW, HPUX et.al. take the *size* of the buffer, whereas Windows takes the maximal number of characters to write excluding NUL.
Which means that we need another configuration variable on Windows:
-DSNPRINTF_SIZE_CORR=1
and
#ifndef SNPRINTF_SIZE_CORR #define SNPRINTF_SIZE_CORR 0 #endif
in the replacement implementation. But I can do this myself in the course of the MinGW port.
BTW, this is not only an issue of vsnprintf, but also of snprintf!
-- Hannes