This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc/cp/pt.c: use ngettext() when needed


On 02/17/2010 06:06 PM, Gabriel Dos Reis wrote:
On Wed, Feb 17, 2010 at 9:23 AM, Marco Poletti <poletti.marco@gmail.com> wrote:
In the file pt.c, there were translatable strings like "redeclared
with %d template parameter(s)" that are hard to translate. Instead,
it should use the ngettext() function to allow more flexible
translations. I've added two functions inform_translated() and
error_translated() to diagnostic.c, that are called by pt.c. This
is my second patch to GCC, I could have done something wrong.
Critics are very appreciated.

I'm uncomfortable with adding these two functions. It is possible to just call a preprocessor ngettext() first and give the result to error() or inform()?

Marco, why don't you instead add warning_n/inform_n/error_n, like


   error_n (TREE_VEC_LENGTH (parms),
            "redeclared with %d template parameter",
            "redeclared with %d template parameters",
            TREE_VEC_LENGTH (parms));

(compared to ngettext I'm moving the number argument before the strings, to make sure it's not confused with the first positional parameter of printf). This can be taught to exgettext with something like this:

Index: exgettext
===================================================================
--- exgettext	(revision 156795)
+++ exgettext	(working copy)
@@ -112,6 +112,8 @@ function keyword_option(line) {
     else if (args ~ /c$/)
     	format="c-format"

+    if (name ~ /_n$/) n = n "," (n + 1)
+
     if (n == 1) { keyword = "--keyword=" name }
     else { keyword = "--keyword=" name ":" n }
     if (format) {

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]