Re: g_snprintf() implementation



On Sun, 18 Apr 1999, Havoc Pennington wrote:

> 
> Hi,
> 
> g_snprintf() has two possible implementations, one which uses vsnprintf()
> and one which doesn't. Only the one which doesn't does this:
> str[n-1] = '\0';
> 
> According to the man page, vsnprintf() does *not* do this, since it
> behaves just like regular snprintf(). The other problem is that
> vsnprintf() potentially returns -1, but the other implementation does not.
> 
> I think the vsnprintf() version should be changed to null-terminate and
> never return -1.

        * gutils.c (g_snprintf): When using the vsnprintf()
        implementation, '\0'-terminate the resulting string
        and return its length rather than -1.

> Am I missing something?

yes, g_vsnprintf() should be modified appropriatedly as well ;)


> 
> Havoc
> 

---
ciaoTJ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]