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: RFA [PR objc/29200][diagnostic] Make diagnostics translation friendly


Am Freitag, den 03.04.2009, 02:41 +0200 schrieb David Ayers:
> Am Freitag, den 03.04.2009, 02:30 +0200 schrieb David Ayers:
> > here is some more low hanging fruit:
> > "In gcc/objc/objc-act.c there is this code:
> > 
> >           warning (0, "multiple %s named %<%c%s%> found",
> >                    methods ? "methods" : "selectors",
> > 
> > The strings substituted for the first %s are not available for translation, so
> > this can not be properly translated.  Even if they were, composing a sentence
> > like this is not in general possible to do for an arbitrary language."
> > 
> > [quoted from: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29200 ]
> > 
> > This patch fixes it in straight forward, boring way.
> 
> Actually there are a few more places around here that need cleaning
> up... so ignore this patch for now.

Here's what I'm bootstrapping now.

I've verified that currently all calls of warn_with_method supply a
constant string as the message parameter so that the translation can be
called from within warn_with_method. (That's the function at bottom of
the patch which will look like:

static void
warn_with_method (const char *message, int mtype, tree method)
{
  /* Add a readable method name to the warning.  */
  warning (0, "%J%s %<%c%s%>", method,
           _(message), mtype, gen_method_decl (method));
}

If it's preferred that the translation be done at the call sites, I can
update the patch accordingly.

OK for the trunk?

Cheers,
David

2009-00-00  David Ayers  <ayers@fsfe.org>

	PR objc/29200
	* objc/objc-act.c (check_duplicates): Make warning translation
	friendly.
	(warn_with_method): Translate the message.

Index: gcc/objc/objc-act.c
===================================================================
--- gcc/objc/objc-act.c	(Revision 145477)
+++ gcc/objc/objc-act.c	(Arbeitskopie)
@@ -6103,16 +6103,29 @@
 	    }
 
 	issue_warning:
-	  warning (0, "multiple %s named %<%c%s%> found",
-		   methods ? "methods" : "selectors",
-		   (is_class ? '+' : '-'),
-		   IDENTIFIER_POINTER (METHOD_SEL_NAME (meth)));
+	  if (methods)
+	    {
+	      warning (0, "multiple methods named %<%c%s%> found",
+		       (is_class ? '+' : '-'),
+		       IDENTIFIER_POINTER (METHOD_SEL_NAME (meth)));
+	      warn_with_method ("using"
+				((TREE_CODE (meth) == INSTANCE_METHOD_DECL)
+				 ? '-'
+				 : '+'),
+				meth);
+	    }
+	  else
+	    {
+	      warning (0, "multiple selectors named %<%c%s%> found",
+		       (is_class ? '+' : '-'),
+		       IDENTIFIER_POINTER (METHOD_SEL_NAME (meth)));
+	      warn_with_method ("found",
+				((TREE_CODE (meth) == INSTANCE_METHOD_DECL)
+				 ? '-'
+				 : '+'),
+				meth);
+	    }
 
-	  warn_with_method (methods ? "using" : "found",
-			    ((TREE_CODE (meth) == INSTANCE_METHOD_DECL)
-			     ? '-'
-			     : '+'),
-			    meth);
 	  for (loop = hsh->list; loop; loop = loop->next)
 	    warn_with_method ("also found",
 			      ((TREE_CODE (loop->value) == INSTANCE_METHOD_DECL)
@@ -8432,7 +8445,7 @@
 {
   /* Add a readable method name to the warning.  */
   warning (0, "%J%s %<%c%s%>", method,
-           message, mtype, gen_method_decl (method));
+           _(message), mtype, gen_method_decl (method));
 }
 
 /* Return 1 if TYPE1 is equivalent to TYPE2

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