Re: [HACKERS] %2$, %1$ gettext placeholder replacement is not working under Win32

From: Nicolai Tufar <ntufar(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org
Subject: Re: [HACKERS] %2$, %1$ gettext placeholder replacement is not working under Win32
Date: 2005-01-17 20:16:31
Message-ID: d809293905011712162e0d34fc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-hackers-win32

On Mon, 17 Jan 2005 14:54:44 -0500, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Also, it looks like src/port/snprintf.c is not %n$ capable either.
> I'm not sure which platforms that affects.
>
> A possible route to a solution is to upgrade snprintf.c and then use
> it on platforms that don't have this support. This only fixes those
> cases where we go through snprintf, which is probably not all of the
> affected messages, but it might be enough. It's not happening for
> 8.0.0 though.

Bad news for the Turks. Turkish language syntax
is lake Latin: the verb is always at the end. Because
of that almost all messages that have two or more
placeholders are broken under Windows.

The solution you propose seem to be a trivial exercise:
1. write a replacement function, say, pg_snprintf() that
would shuffle input arguments, replace %x$ with %
and then call libc's snprintf();
2. replace snprintf() in all source files with pg_snprintf();
3. Update Makefiles to use our custom function on broken
platforms or default to snprinf(). (Or maybe pg_snprintf()
should be a #define);
4. Tell everyone to use pg_snprintf() instead of snprintf()
from now on.

I would like volunteer to implement this for 8.1 and
would be honoured if I get a chance to contribute.

> regards, tom lane

Best regards,
Nicolai Tufar

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Sullivan 2005-01-17 20:16:49 Re: ARC patent
Previous Message Devrim GUNDUZ 2005-01-17 20:16:07 Re: [pgsql-hackers-win32] %2$, %1$ gettext placeholder

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Magnus Hagander 2005-01-17 20:18:34 Re: [HACKERS] %2$, %1$ gettext placeholder replacement is not working under Win32
Previous Message Devrim GUNDUZ 2005-01-17 20:16:07 Re: [pgsql-hackers-win32] %2$, %1$ gettext placeholder