Subject: Re: [PATCH] Add compat/vsnprintf.c for systems that returns -1 on maxsize reached

From: Johannes Sixt <[email-masked]>
Date: Wed, 05 Mar 2008 10:18:10 +0100

Michal Rokos schrieb:
> 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