>From 7bcc89670a667fae5ad8e73cb627d4602d1cf064 Mon Sep 17 00:00:00 2001 From: Tommy Date: Fri, 16 Aug 2013 01:40:53 +1200 Subject: [PATCH] xgettext: new option --no-linenumbers omits line numbers. Unlike --no-location, the name of the originating file is retained. --- gettext-tools/doc/xgettext.texi | 5 +++++ gettext-tools/src/read-catalog.h | 5 +++-- gettext-tools/src/xgettext.c | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gettext-tools/doc/xgettext.texi b/gettext-tools/doc/xgettext.texi index 1089e9c..1fad111 100644 --- a/gettext-tools/doc/xgettext.texi +++ b/gettext-tools/doc/xgettext.texi @@ -400,6 +400,11 @@ each message's context. @opindex address@hidden, @code{xgettext} option} Generate @samp{#: @var{filename}:@var{line}} lines (default). address@hidden --no-linenumbers address@hidden address@hidden, @code{xgettext} option} +Omit the line numbers from @samp{#: @var{filename}:@var{line}} lines, +including only the name(s) of the originating file(s). + @item --strict @opindex address@hidden, @code{xgettext} option} Write out a strict Uniforum conforming PO file. Note that this diff --git a/gettext-tools/src/read-catalog.h b/gettext-tools/src/read-catalog.h index 8b77014..e22c612 100644 --- a/gettext-tools/src/read-catalog.h +++ b/gettext-tools/src/read-catalog.h @@ -167,8 +167,9 @@ extern default_catalog_reader_ty * default_catalog_reader_alloc (default_catalog_reader_class_ty *method_table); -/* If nonzero, remember comments for file name and line number for each - msgid, if present in the reference input. Defaults to true. */ +/* If nonzero, remember comments for file name and/or line number for each + msgid, if present in the reference input. If 1, record both file name + and line number. If 2, record file name only. Defaults to 1. */ extern DLL_VARIABLE int line_comment; /* If false, duplicate msgids in the same domain and file generate an error. diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index c6b8b0e..c8c1eaa 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -225,6 +225,7 @@ static const struct option long_options[] = { "msgstr-prefix", optional_argument, NULL, 'm' }, { "msgstr-suffix", optional_argument, NULL, 'M' }, { "no-escape", no_argument, NULL, 'e' }, + { "no-linenumbers", no_argument, &line_comment, 2 }, { "no-location", no_argument, &line_comment, 0 }, { "no-wrap", no_argument, NULL, CHAR_MAX + 4 }, { "omit-header", no_argument, &xgettext_omit_header, 1 }, @@ -2452,8 +2453,10 @@ meta information, not the empty string.\n"))); warn_format_string (is_format, mp->msgid, pos, "msgid"); /* Remember where we saw this msgid. */ - if (line_comment) + if (line_comment == 1) message_comment_filepos (mp, pos->file_name, pos->line_number); + else if (line_comment == 2) + message_comment_filepos (mp, pos->file_name, (size_t)(-1)); /* Tell the lexer to reset its comment buffer, so that the next message gets the correct comments. */ -- 1.8.1.2