Re: A couple of gripes about the gettext plurals patch

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: A couple of gripes about the gettext plurals patch
Date: 2009-05-26 10:45:00
Message-ID: 200905261345.00783.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Monday 25 May 2009 22:02:47 Tom Lane wrote:
> The issue of double translation is really a minor point; what is
> bothering me is that we've got such an ad-hoc,
> non-compile-time-checkable approach here. Zdenek's discovery
> today that some of the format strings are flat-out wrong
> http://archives.postgresql.org/pgsql-hackers/2009-05/msg00946.php
> surprises me not in the least.

See response there why this is the way it is.

Note also that gcc's format argument checking can see through ngettext() quite
well, so as far as I can tell, we are not exposed to accidental format string
mismatches.

Example code:

#include <stdarg.h>
#include <stdio.h>
#include <libintl.h>

extern void errmsg(const char *fmt, ...) __attribute__((format(printf,1,2)));

void
errmsg(const char *fmt, ...)
{
va_list ap;

va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
}

int
main(int argc, char *argv[])
{
errmsg(ngettext("got %d argument, namely %s\n",
"got %d arguments, first ist %s\n", argc),
argc, argv[0]);
return 0;
}

I tried throwing various kinds of subtle garbage into the errmsg/ngettext
line, but it was all discovered by gcc -Wall.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2009-05-26 11:06:24 Re: [PATCH] cleanup hashindex for pg_migrator hashindex compat mode (for 8.4)
Previous Message Peter Eisentraut 2009-05-26 10:39:08 Re: problem with plural-forms