]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Recognize comment tag prefix
authorDaiki Ueno <ueno@gnu.org>
Mon, 21 Apr 2014 04:32:00 +0000 (13:32 +0900)
committerDaiki Ueno <ueno@gnu.org>
Sat, 3 May 2014 02:09:53 +0000 (11:09 +0900)
Reported by Jiang Xin in
<http://article.gmane.org/gmane.comp.version-control.git/246462>.
* xgettext.c (remember_a_message): Discard a string prefixed to the comment
tag from all remaining comment lines.

gettext-tools/src/ChangeLog
gettext-tools/src/xgettext.c

index c0098209ba84eb51f6ccecc4f3027efb6f4f7987..a220e2c4fcf121a699cb956be1f29d3a77131024 100644 (file)
@@ -1,3 +1,11 @@
+2014-05-03  Daiki Ueno  <ueno@gnu.org>
+
+       xgettext: Recognize prefixed comment tag
+       Reported by Jiang Xin in
+       <http://article.gmane.org/gmane.comp.version-control.git/246462>.
+       * xgettext.c (remember_a_message): Discard a string prefixed to
+       the comment tag from all remaining comment lines.
+
 2014-05-03  Daiki Ueno  <ueno@gnu.org>
 
        c: Support C99-style Unicode character escapes
index c30139e712cdce30dd4ed3f579096569a37a2ebb..339afcf11c3eadbcaf7de41411f4e6e3ed416042 100644 (file)
@@ -2295,6 +2295,11 @@ meta information, not the empty string.\n")));
     size_t nitems_after;
     int j;
     bool add_all_remaining_comments;
+    /* The string before the comment tag.  For example, If "** TRANSLATORS:"
+       is seen and the comment tag is "TRANSLATORS:",
+       then comment_tag_prefix is set to "** ".  */
+    const char *comment_tag_prefix = NULL;
+    size_t comment_tag_prefix_length = 0;
 
     nitems_before = (mp->comment_dot != NULL ? mp->comment_dot->nitems : 0);
 
@@ -2373,13 +2378,25 @@ meta information, not the empty string.\n")));
             if (interesting)
               continue;
           }
-        /* When the comment tag is seen, it drags in not only the line
-           which it starts, but all remaining comment lines.  */
-        if (add_all_remaining_comments
-            || (add_all_remaining_comments =
-                  (comment_tag != NULL
-                   && strncmp (s, comment_tag, strlen (comment_tag)) == 0)))
-          message_comment_dot_append (mp, s);
+
+        if (!add_all_remaining_comments && comment_tag != NULL)
+          {
+            /* When the comment tag is seen, it drags in not only the line
+               which it starts, but all remaining comment lines.  */
+            if ((t = c_strstr (s, comment_tag)) != NULL)
+              {
+                add_all_remaining_comments = true;
+                comment_tag_prefix = s;
+                comment_tag_prefix_length = t - s;
+              }
+          }
+
+        if (add_all_remaining_comments)
+          {
+            if (strncmp (s, comment_tag_prefix, comment_tag_prefix_length) == 0)
+              s += comment_tag_prefix_length;
+            message_comment_dot_append (mp, s);
+          }
       }
 
     nitems_after = (mp->comment_dot != NULL ? mp->comment_dot->nitems : 0);