pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: BUG #6066: [PATCH] Mark more strings as c-format
3+ messages / 3 participants
[nested] [flat]
* Re: BUG #6066: [PATCH] Mark more strings as c-format
@ 2011-06-17 11:10 Christoph Berg <cb@df7cb.de>
0 siblings, 2 replies; 3+ messages in thread
From: Christoph Berg @ 2011-06-17 11:10 UTC (permalink / raw)
To: pgsql-bugs
Re: To pgsql-bugs@postgresql.org 2011-06-17 <20110617091114.GC4130@msgid.df7cb.de>
> Unfortunately that doesn't help in this case, as the bad string isn't
> tagged as "#, c-format", but still gets used as such. This seems to be
> the case for many errhint() strings. Maybe xgettext should be taught
> to treat all errhint() et al arguments as c-strings.
Here's a patch to implement that, with backend/nls.mk updated.
msgfmt -c is already available in the "maintainer-check-po" target.
I'd assume this was called at least once during the release process.
inline patch 1: src/backend/nls.mk, src/nls-global.mk (+9/-2 lines) download inline-1.patch
diff --git a/src/backend/nls.mk b/src/backend/nls.mk
index 1894569..3c3f8ed 100644
*** a/src/backend/nls.mk
--- b/src/backend/nls.mk
*************** GETTEXT_TRIGGERS:= _ errmsg errmsg_plura
*** 6,11 ****
--- 6,15 ----
errdetail_plural:1,2 errhint errcontext \
GUC_check_errmsg GUC_check_errdetail GUC_check_errhint \
write_stderr yyerror parser_yyerror
+ GETTEXT_FLAGS := errmsg:1:c-format errmsg_plural:1:c-format \
+ errmsg_plural:2:c-format errhint:1:c-format errcontext:1:c-format \
+ GUC_check_errmsg:1:c-format GUC_check_errdetail:1:c-format \
+ GUC_check_errhint:1:c-format write_stderr:1:c-format
gettext-files: distprep
find $(srcdir)/ $(srcdir)/../port/ -name '*.c' -print >$@
diff --git a/src/nls-global.mk b/src/nls-global.mk
index 32b3c0f..3aa598f 100644
*** a/src/nls-global.mk
--- b/src/nls-global.mk
***************
*** 12,17 ****
--- 12,20 ----
# GETTEXT_FILES -- list of source files that contain message strings
# GETTEXT_TRIGGERS -- (optional) list of functions that contain
# translatable strings
+ # GETTEXT_FLAGS -- (optional) list of gettext --flag arguments to mark
+ # function arguments that contain C format strings
+ # (functions must be listed in TRIGGERS and FLAGS)
#
# That's all, the rest is done here, if --enable-nls was specified.
#
*************** all-po: $(MO_FILES)
*** 48,54 ****
ifeq ($(word 1,$(GETTEXT_FILES)),+)
po/$(CATALOG_NAME).pot: $(word 2, $(GETTEXT_FILES)) $(MAKEFILE_LIST)
ifdef XGETTEXT
! $(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) -f $<
else
@echo "You don't have 'xgettext'."; exit 1
endif
--- 51,57 ----
ifeq ($(word 1,$(GETTEXT_FILES)),+)
po/$(CATALOG_NAME).pot: $(word 2, $(GETTEXT_FILES)) $(MAKEFILE_LIST)
ifdef XGETTEXT
! $(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(addprefix --flag=, $(GETTEXT_FLAGS)) -f $<
else
@echo "You don't have 'xgettext'."; exit 1
endif
*************** po/$(CATALOG_NAME).pot: $(GETTEXT_FILES)
*** 57,63 ****
# Change to srcdir explicitly, don't rely on $^. That way we get
# consistent #: file references in the po files.
ifdef XGETTEXT
! $(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(GETTEXT_FILES)
else
@echo "You don't have 'xgettext'."; exit 1
endif
--- 60,66 ----
# Change to srcdir explicitly, don't rely on $^. That way we get
# consistent #: file references in the po files.
ifdef XGETTEXT
! $(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(addprefix --flag=, $(GETTEXT_FLAGS)) $(GETTEXT_FILES)
else
@echo "You don't have 'xgettext'."; exit 1
endif
Christoph
--
cb@df7cb.de | http://www.df7cb.de/
Attachments:
signature.asc (application/pgp-signature, 835B) download
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #6066: [PATCH] Mark more strings as c-format
@ 2011-06-17 14:21 Alvaro Herrera <alvherre@commandprompt.com>
parent: Christoph Berg <cb@df7cb.de>
1 sibling, 0 replies; 3+ messages in thread
From: Alvaro Herrera @ 2011-06-17 14:21 UTC (permalink / raw)
To: Christoph Berg <cb@df7cb.de>; +Cc: pgsql-bugs
Excerpts from Christoph Berg's message of vie jun 17 07:10:34 -0400 2011:
> Re: To pgsql-bugs@postgresql.org 2011-06-17 <20110617091114.GC4130@msgid.df7cb.de>
> > Unfortunately that doesn't help in this case, as the bad string isn't
> > tagged as "#, c-format", but still gets used as such. This seems to be
> > the case for many errhint() strings. Maybe xgettext should be taught
> > to treat all errhint() et al arguments as c-strings.
>
> Here's a patch to implement that, with backend/nls.mk updated.
>
> msgfmt -c is already available in the "maintainer-check-po" target.
> I'd assume this was called at least once during the release process.
Yeah, msgfmt -c is called pretty frequently on the translation service
http://babel.postgresql.org.
Thanks for the patch, I'll have a look at integrating it.
--
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #6066: [PATCH] Mark more strings as c-format
@ 2011-06-26 21:41 Peter Eisentraut <peter_e@gmx.net>
parent: Christoph Berg <cb@df7cb.de>
1 sibling, 0 replies; 3+ messages in thread
From: Peter Eisentraut @ 2011-06-26 21:41 UTC (permalink / raw)
To: Christoph Berg <cb@df7cb.de>; +Cc: pgsql-bugs
On fre, 2011-06-17 at 13:10 +0200, Christoph Berg wrote:
> Re: To pgsql-bugs@postgresql.org 2011-06-17 <20110617091114.GC4130@msgid.df7cb.de>
> > Unfortunately that doesn't help in this case, as the bad string isn't
> > tagged as "#, c-format", but still gets used as such. This seems to be
> > the case for many errhint() strings. Maybe xgettext should be taught
> > to treat all errhint() et al arguments as c-strings.
>
> Here's a patch to implement that, with backend/nls.mk updated.
I have committed a patch based on that, with the other nls.mk filled in
as well. Thanks for the idea.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2011-06-26 21:41 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-06-17 11:10 Re: BUG #6066: [PATCH] Mark more strings as c-format Christoph Berg <cb@df7cb.de>
2011-06-17 14:21 ` Alvaro Herrera <alvherre@commandprompt.com>
2011-06-26 21:41 ` Peter Eisentraut <peter_e@gmx.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox