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: [PATCH PR translation/39521] Fix specs diagnostics translation


On 01/11/2010 11:13 PM, Joseph S. Myers wrote:

It is tested on i686-pc-linux-gnu enabled languages c,c++,objc and fortran, run "make gcc.pot" and diff the gcc.pot with the previous one to check the added extracted messages.

Ok for trunk?

This is OK, in that it causes more messages to be extracted without breaking anything. But it isn't complete. See the issues I've filed as PR 42689. Messages are extracted with a trailing newline in some cases, but gcc.c is removing that newline before passing them for translation. In general if you remove those newlines in the sources then you avoid exgettext needing to process them. (Probably for robustness do both - remove newlines in the sources as unnecessary and so potentially confusing, while making exgettext handle them correctly - i.e. not put the trailing newlines in the messages in gcc.pot.)


I don't know what you mean by "It is handled specially at exgettext" - as far as I can see, you end up extracting such messages as two lines, and each line gets passed for translation separately. For sensible translation, there should be a single (possibly long) diagnostic.

Ok, since the diagnostic that is end with "\n" is illegal, I fixed this patch again. Most changes of the function spec_error_string at the old patch was to handle the the diagnostics that are end with "\n". In fact, they are only the lines of "Warning: consider linking with `-static' as system libraries with\n", that is also what "specially" means at the my last email :). How about to leave that messages not be extracted, so exgettext needn't changed again in the future?
Run "make gcc.pot" and diff the gcc.pot. The only changed is the message "Warning: consider linking with `-static' as system libraries with\n" is removed.


Ok for trunk?



po/
2010-01-12  Shujing Zhao  <pearly.zhao@oracle.com>

	PR translation/39521
	* exgettext: Extracted all specs %n strings and the %e strings that %e
	is at the start of a line.

2010-01-11  Shujing Zhao  <pearly.zhao@oracle.com>

	PR translation/39521
	* gcc.c (do_spec_1): Wrapped the error and notice messages of specs
	strings with _().

Index: gcc.c
===================================================================
--- gcc.c	(revision 155801)
+++ gcc.c	(working copy)
@@ -5248,7 +5248,7 @@ do_spec_1 (const char *spec, int inswitc
 	      buf = (char *) alloca (p - q + 1);
 	      strncpy (buf, q, p - q);
 	      buf[p - q] = 0;
-	      error ("%s", buf);
+	      error ("%s", _(buf));
 	      return -1;
 	    }
 	    break;
@@ -5262,7 +5262,7 @@ do_spec_1 (const char *spec, int inswitc
 	      buf = (char *) alloca (p - q + 1);
 	      strncpy (buf, q, p - q);
 	      buf[p - q] = 0;
-	      notice ("%s\n", buf);
+	      notice ("%s\n", _(buf));
 	      if (*p)
 		p++;
 	    }
Index: po/exgettext
===================================================================
--- po/exgettext	(revision 155801)
+++ po/exgettext	(working copy)
@@ -75,12 +75,12 @@ pottmp=$pwd/$T/tmp.pot
 # Then generate keyword options for xgettext, by scanning for declarations
 # of functions whose parameter names end in "msgid".
 #
-# Finally, generate a source file containing all %e strings from
+# Finally, generate a source file containing all %e and %n strings from
 # driver specs, so those can be translated too.
 #
 # All in one huge awk script.
 
-echo "scanning for keywords and %e strings..." >&2
+echo "scanning for keywords, %e and %n strings..." >&2
 
 ( cd $srcdir
   lang_subdirs=`echo */config-lang.in */*/config-lang.in | sed -e 's|config-lang\.in||g'`
@@ -132,10 +132,11 @@ function keyword_option(line) {
 }
 
 function spec_error_string (line) {
-    while ((percent_index = index(line, "%e")) != 0) {
+    if (index(line, "%e") != 0 && index(line, "%n") != 0) return
+    while ((percent_index = index(line, "%e")) != 0 || 
+	   (percent_index = index(line, "%n")) != 0) {
 	escape = substr(line, percent_index - 1, 1)
 	line = substr(line, percent_index + 2)
-	if (escape == "%") continue
 
 	bracket_index = index(line, "}")
 	quote_index = index(line, "\"")
@@ -174,7 +175,7 @@ END {
 	while (getline < file) {
 	    if (/^(#[ 	]*define[ 	]*)?[A-Za-z_].*\(.*msgid[,\)]/) {
 		keyword_option($0)
-	    } else if (/%e/) {
+	    } else if (/%e/ || /%n/) {
 		spec_error_string($0)
 	    }
 	    lineno++

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