Re: g_printf_string_upper_bound and positional parameters
- From: Havoc Pennington <hp redhat com>
- To: Thomas Schultz <tststs gmx de>
- Cc: gtk-devel-list gnome org
- Subject: Re: g_printf_string_upper_bound and positional parameters
- Date: 01 Oct 2001 13:07:24 -0400
Thomas Schultz <tststs gmx de> writes:
> However, I now added gettext support and one of the translators (Byrial
> Jensen <byrial image dk>) complained that the code could not handle
> positional parameters. He suggested finding out the length of a format
> string by writing it to the null device instead, like this:
>
> 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?
- slow
- not portable to non-UNIX
- does unexpected I/O
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]