From: Daiki Ueno Date: Mon, 21 Apr 2014 04:32:00 +0000 (+0900) Subject: xgettext: Recognize comment tag prefix X-Git-Tag: v0.19~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10af7fe6bd8cc079e189d51e1ced5af184ca60f3;p=thirdparty%2Fgettext.git xgettext: Recognize comment tag prefix Reported by Jiang Xin in . * xgettext.c (remember_a_message): Discard a string prefixed to the comment tag from all remaining comment lines. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index c0098209b..a220e2c4f 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,11 @@ +2014-05-03 Daiki Ueno + + xgettext: Recognize prefixed comment tag + Reported by Jiang Xin in + . + * xgettext.c (remember_a_message): Discard a string prefixed to + the comment tag from all remaining comment lines. + 2014-05-03 Daiki Ueno c: Support C99-style Unicode character escapes diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index c30139e71..339afcf11 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);