@example
@var{white-space}
# @var{translator-comments}
-#. @var{automatic-comments}
+#. @var{extracted-comments}
#: @var{reference}@dots{}
#, @var{flag}@dots{}
msgid @var{untranslated-string}
msgstr "Error desconegut del sistema"
@end example
+@cindex comments, translator
+@cindex comments, automatic
+@cindex comments, extracted
Entries begin with some optional white space. Usually, when generated
through GNU @code{gettext} tools, there is exactly one blank line
between entries. Then comments follow, on lines all starting with the
character @code{#}. There are two kinds of comments: those which have
-some white space immediately following the @code{#}, which comments are
-created and maintained exclusively by the translator, and those which
-have some non-white character just after the @code{#}, which comments
-are created and maintained automatically by GNU @code{gettext} tools.
+some white space immediately following the @code{#} - the @var{translator
+comments} -, which comments are created and maintained exclusively by the
+translator, and those which have some non-white character just after the
+@code{#} - the @var{automatic comments} -, which comments are created and
+maintained automatically by GNU @code{gettext} tools. Comment lines
+starting with @code{#.} contain comments given by the programmer, directed
+at the translator; these comments are called @var{extracted comments}
+because the @code{xgettext} program extracts them from the program's
+source code. Comment lines starting with @code{#:} contain references to
+the program's source code. Comment lines starting with @code{#,} contain
+flags; more about these below.
All comments, of either kind, are optional.
@kwindex msgid
@example
@var{white-space}
# @var{translator-comments}
-#. @var{automatic-comments}
+#. @var{extracted-comments}
#: @var{reference}@dots{}
#, @var{flag}@dots{}
msgctxt @var{context}
@example
@var{white-space}
# @var{translator-comments}
-#. @var{automatic-comments}
+#. @var{extracted-comments}
#: @var{reference}@dots{}
#, @var{flag}@dots{}
msgid @var{untranslated-string-singular}
+2006-03-16 Bruno Haible <bruno@clisp.org>
+
+ * msggrep.c (grep_task): Increment size.
+ (long_options): Add --extracted-comment option.
+ (main): Handle --extracted-comment option.
+ (no_pass, usage): Update.
+ (is_message_selected_no_invert): Implement matching on extracted
+ comments.
+ Suggested by Behdad Esfahbod <behdad@cs.toronto.edu>.
+
2006-03-16 Bruno Haible <bruno@clisp.org>
Handle GNOME glib context syntax.
(arglist_parser_done): When suffix 'g' was specified, split off the
context from the msgid and/or msgid_plural.
* x-perl.c (extract_variable): Update.
+ Suggested by Danilo Ĺ egan <danilo@gnome.org>.
2006-03-16 Bruno Haible <bruno@clisp.org>
(msgl-fsearch.obj): New rule.
* Makefile.vms (msgmerge_OBJECTS): Add msgl-fsearch.obj.
(msgl-fsearch.obj): New rule.
+ Reported by Clytie Siddall <clytie@riverland.net.au>.
2006-03-09 Bruno Haible <bruno@clisp.org>
bool case_insensitive;
void *compiled_patterns;
};
-static struct grep_task grep_task[4];
+static struct grep_task grep_task[5];
/* Long options. */
static const struct option long_options[] =
{ "domain", required_argument, NULL, 'M' },
{ "escape", no_argument, NULL, CHAR_MAX + 1 },
{ "extended-regexp", no_argument, NULL, 'E' },
+ { "extracted-comment", no_argument, NULL, 'X' },
{ "file", required_argument, NULL, 'f' },
{ "fixed-strings", no_argument, NULL, 'F' },
{ "force-po", no_argument, &force_po, 1 },
location_files = string_list_alloc ();
domain_names = string_list_alloc ();
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 5; i++)
{
struct grep_task *gt = &grep_task[i];
gt->case_insensitive = false;
}
- while ((opt = getopt_long (argc, argv, "CD:e:Ef:FhiJKM:N:o:pPTvVw:",
+ while ((opt = getopt_long (argc, argv, "CD:e:Ef:FhiJKM:N:o:pPTvVw:X",
long_options, NULL))
!= EOF)
switch (opt)
}
break;
+ case 'X':
+ grep_pass = 4;
+ break;
+
case CHAR_MAX + 1:
message_print_style_escape (true);
break;
"--sort-output", "--sort-by-file");
/* Compile the patterns. */
- for (grep_pass = 0; grep_pass < 4; grep_pass++)
+ for (grep_pass = 0; grep_pass < 5; grep_pass++)
{
struct grep_task *gt = &grep_task[grep_pass];
if (grep_task[0].pattern_count > 0
|| grep_task[1].pattern_count > 0
|| grep_task[2].pattern_count > 0
- || grep_task[3].pattern_count > 0)
+ || grep_task[3].pattern_count > 0
+ || grep_task[4].pattern_count > 0)
{
/* Warn if the current locale is not suitable for this PO file. */
compare_po_locale_charsets (result);
no_pass (int opt)
{
error (EXIT_SUCCESS, 0,
- _("option '%c' cannot be used before 'J' or 'K' or 'T' or 'C' has been specified"),
+ _("option '%c' cannot be used before 'J' or 'K' or 'T' or 'C' or 'X' has been specified"),
opt);
usage (EXIT_FAILURE);
}
Message selection:\n\
[-N SOURCEFILE]... [-M DOMAINNAME]...\n\
[-J MSGCTXT-PATTERN] [-K MSGID-PATTERN] [-T MSGSTR-PATTERN]\n\
- [-C COMMENT-PATTERN]\n\
+ [-C COMMENT-PATTERN] [-X EXTRACTED-COMMENT-PATTERN]\n\
A message is selected if it comes from one of the specified source files,\n\
or if it comes from one of the specified domains,\n\
or if -J is given and its context (msgctxt) matches MSGCTXT-PATTERN,\n\
or if -K is given and its key (msgid or msgid_plural) matches MSGID-PATTERN,\n\
or if -T is given and its translation (msgstr) matches MSGSTR-PATTERN,\n\
-or if -C is given and the translator's comment matches COMMENT-PATTERN.\n\
+or if -C is given and the translator's comment matches COMMENT-PATTERN,\n\
+or if -X is given and the extracted comment matches EXTRACTED-COMMENT-PATTERN.\n\
\n\
When more than one selection criterion is specified, the set of selected\n\
messages is the union of the selected messages of each criterion.\n\
\n\
-MSGCTXT-PATTERN or MSGID-PATTERN or MSGSTR-PATTERN or COMMENT-PATTERN syntax:\n\
+MSGCTXT-PATTERN or MSGID-PATTERN or MSGSTR-PATTERN or COMMENT-PATTERN or\n\
+EXTRACTED-COMMENT-PATTERN syntax:\n\
[-E | -F] [-e PATTERN | -f FILE]...\n\
PATTERNs are basic regular expressions by default, or extended regular\n\
expressions if -E is given, or fixed strings if -F is given.\n\
-K, --msgid start of patterns for the msgid\n\
-T, --msgstr start of patterns for the msgstr\n\
-C, --comment start of patterns for the translator's comment\n\
+ -X, --extracted-comment start of patterns for the extracted comment\n\
-E, --extended-regexp PATTERN is an extended regular expression\n\
-F, --fixed-strings PATTERN is a set of newline-separated strings\n\
-e, --regexp=PATTERN use PATTERN as a regular expression\n\
return true;
}
+ /* Test extracted comments using the --extracted-comment arguments. */
+ if (grep_task[4].pattern_count > 0
+ && mp->comment_dot != NULL && mp->comment_dot->nitems > 0)
+ {
+ size_t length;
+ char *total_comment;
+ char *q;
+ size_t j;
+ bool selected;
+
+ length = 0;
+ for (j = 0; j < mp->comment_dot->nitems; j++)
+ length += strlen (mp->comment_dot->item[j]) + 1;
+ total_comment = (char *) xallocsa (length);
+
+ q = total_comment;
+ for (j = 0; j < mp->comment_dot->nitems; j++)
+ {
+ size_t l = strlen (mp->comment_dot->item[j]);
+
+ memcpy (q, mp->comment_dot->item[j], l);
+ q += l;
+ *q++ = '\n';
+ }
+ if (q != total_comment + length)
+ abort ();
+
+ selected = is_string_selected (4, total_comment, length);
+
+ freesa (total_comment);
+
+ if (selected)
+ return true;
+ }
+
return false;
}