Re: g_printf_string_upper_bound and positional parameters



On Mon, 1 Oct 2001, Thomas Schultz wrote:

> Hi,

> int printf_string_length (const char *format, va_list args)
> {
>    static FILE *null;
> 
>    if (!null)
>    {
>       null = fopen ("/dev/null", "w");
>       if (!null)
>          return -1; /* Add some error handling */
>    }
>    return vfprintf (null, format, args);
>    /* Leave null open. */
> }
> 
> To me, this sounds like a workable solution, but I guess there must be a
> reason why it isn't done this way in glib.  Any hints?

printf() does not return the number of written characters on all systems.
i.e. evaluating its return code is essentially non-portable.

> 
> Kind regards,
>     Thomas Schultz
> 

---
ciaoTJ





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