bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] xgettext does not preserve the translator comment.


From: Sergey Poznyakoff
Subject: [PATCH] xgettext does not preserve the translator comment.
Date: Fri, 26 Dec 2003 01:10:29 +0200

Hello,

Xgettext in versions 0.13 and 0.13.1 does not preserve the
translators' comment in the following context:

/* TRANSLATORS: Please, preserve the vertical tabulation (^K character)
   in this message */
static char doc[] = N_("GNU MH forw\v"
"Options marked with `*' are not yet implemented.\n"
"Use -help to obtain the list of traditional MH options.");

However, if the msgstr is rewritten as a single string, the comment
is processed correctly. Previous versions of xgettext worked OK in
both cases.

This is because phase8b_get() resets the recently saved comment
when it encounters a newline, even if next token is a string.

Attached is a patch that fixes this.

Regards,
Sergey

Index: gettext-tools/src/x-c.c
--- orig/x-c.c  Fri Dec 26 00:14:28 2003
+++ x-c.c       Fri Dec 26 00:50:51 2003
@@ -1392,19 +1392,10 @@ phase8b_get (token_ty *tp)
        continue;
       if (tp->type == token_type_eoln)
        {
-         /* We have to track the last occurrence of a string.  One
-            mode of xgettext allows to group an extracted message
-            with a comment for documentation.  The rule which states
-            which comment is assumed to be grouped with the message
-            says it should immediately precede it.  Our
-            interpretation: between the last line of the comment and
-            the line in which the keyword is found must be no line
-            with non-white space tokens.  */
          ++newline_count;
-         if (last_non_comment_line > last_comment_line)
-           xgettext_comment_reset ();
          continue;
        }
+
       break;
     }
 }
@@ -1415,6 +1406,21 @@ phase8b_unget (token_ty *tp)
   phase8a_unget (tp);
 }
 
+static void
+phase8_comment_reset (int nl)
+{
+  /* We have to track the last occurrence of a string.  One
+     mode of xgettext allows to group an extracted message
+     with a comment for documentation.  The rule which states
+     which comment is assumed to be grouped with the message
+     says it should immediately precede it.  Our
+     interpretation: between the last line of the comment and
+     the line in which the keyword is found must be no line
+     with non-white space tokens.  */
+  if (newline_count > nl
+      && last_non_comment_line > last_comment_line)
+    xgettext_comment_reset ();
+}
 
 /* 8c. In ObjectiveC mode, drop '@' before a literal string.  We need to
    do this before performing concatenation of adjacent string literals.  */
@@ -1450,17 +1456,25 @@ phase8c_unget (token_ty *tp)
 static void
 phase8_get (token_ty *tp)
 {
+  int nl = newline_count;
   phase8c_get (tp);
   if (tp->type != token_type_string_literal)
-    return;
+    {
+      phase8_comment_reset (nl);
+      return;
+    }
   for (;;)
     {
       token_ty tmp;
       size_t len;
 
+      nl = newline_count;
       phase8c_get (&tmp);
       if (tmp.type != token_type_string_literal)
        {
+         if (tmp.type != token_type_rparen) /* Allow for newlines before right
+                                               parenthesis */
+           phase8_comment_reset (nl);
          phase8c_unget (&tmp);
          return;
        }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]