summaryrefslogtreecommitdiffstats
path: root/gettext-tools/src/xgettext.c
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2014-04-21 13:32:00 +0900
committerDaiki Ueno <ueno@gnu.org>2014-05-03 11:09:53 +0900
commit10af7fe6bd8cc079e189d51e1ced5af184ca60f3 (patch)
treee71ef5792359cffcd7629163c0192e2c2bbe4037 /gettext-tools/src/xgettext.c
parenta31750e73308a161de9d56504cf9d039b312926e (diff)
downloadexternal_gettext-10af7fe6bd8cc079e189d51e1ced5af184ca60f3.zip
external_gettext-10af7fe6bd8cc079e189d51e1ced5af184ca60f3.tar.gz
external_gettext-10af7fe6bd8cc079e189d51e1ced5af184ca60f3.tar.bz2
xgettext: Recognize comment tag prefix
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.
Diffstat (limited to 'gettext-tools/src/xgettext.c')
-rw-r--r--gettext-tools/src/xgettext.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c
index c30139e..339afcf 100644
--- a/gettext-tools/src/xgettext.c
+++ b/gettext-tools/src/xgettext.c
@@ -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);