Re: A couple of gripes about the gettext plurals patch

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: A couple of gripes about the gettext plurals patch
Дата
Msg-id 200905261345.00783.peter_e@gmx.net
обсуждение исходный текст
Ответ на Re: A couple of gripes about the gettext plurals patch  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: A couple of gripes about the gettext plurals patch  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: problem with plural-forms
Следующее
От: Andres Freund
Дата:
Сообщение: Re: [PATCH] cleanup hashindex for pg_migrator hashindex compat mode (for 8.4)