MSGFILTER_MSGID, MSGFILTER_LOCATION.
* msgcmp has a new option -N/--no-fuzzy-matching, like msgmerge has since
version 0.12.
+* msgfilter now sets environment variables during the invocation of the
+ filter, indicating the msgid and location of the messge being processed.
+
* Updated the meaning of 'gcc-internal-format' to match GCC 4.3.
\f
Version 0.17 - November 2007
+2008-11-14 Bruno Haible <bruno@clisp.org>
+
+ * msgfilter.texi: Document the environment variables MSGFILTER_MSGCTXT,
+ MSGFILTER_MSGID, MSGFILTER_LOCATION.
+
2008-10-10 Noritada Kobayashi <noritadak@gmail.com>
* gettext.texi (PO Mode): Update remaining obsolete key bindings used
The @code{msgfilter} program applies a filter to all translations of a
translation catalog.
+@vindex MSGFILTER_MSGCTXT@r{, environment variable}
+@vindex MSGFILTER_MSGID@r{, environment variable}
+@vindex MSGFILTER_LOCATION@r{, environment variable}
+During each @var{filter} invocation, the environment variable
+@code{MSGFILTER_MSGID} is bound to the message's msgid, and the environment
+variable @code{MSGFILTER_LOCATION} is bound to the location in the PO file
+of the message. If the message has a context, the environment variable
+@code{MSGFILTER_MSGCTXT} is bound to the message's msgctxt, otherwise it is
+unbound.
+
@subsection Input file location
@table @samp
+2008-11-14 Bruno Haible <bruno@clisp.org>
+
+ * msgfilter.c: Include xvasprintf.h, xsetenv.h.
+ (process_message): Set the environment variables MSGFILTER_MSGCTXT,
+ MSGFILTER_MSGID, MSGFILTER_LOCATION.
+
2008-10-28 Bruno Haible <bruno@clisp.org>
* msgmerge.c (match_domain): Remove space between '#' and 'pragma' for
#include "closeout.h"
#include "dir-list.h"
#include "error.h"
+#include "xvasprintf.h"
#include "error-progname.h"
#include "progname.h"
#include "relocatable.h"
#include "findprog.h"
#include "pipe.h"
#include "wait-process.h"
+#include "xsetenv.h"
#include "filters.h"
#include "msgl-iconv.h"
#include "po-charset.h"
{
const char *msgstr = mp->msgstr;
size_t msgstr_len = mp->msgstr_len;
+ char *location;
size_t nsubstrings;
char **substrings;
size_t total_len;
if (is_header (mp) && keep_header)
return;
+ /* Set environment variables for the subprocess. */
+ if (mp->msgctxt != NULL)
+ xsetenv ("MSGFILTER_MSGCTXT", mp->msgctxt, 1);
+ else
+ unsetenv ("MSGFILTER_MSGCTXT");
+ xsetenv ("MSGFILTER_MSGID", mp->msgid, 1);
+ location = xasprintf ("%s:%ld", mp->pos.file_name,
+ (long) mp->pos.line_number);
+ xsetenv ("MSGFILTER_LOCATION", location, 1);
+ free (location);
+
/* Count NUL delimited substrings. */
for (p = msgstr, nsubstrings = 0;
p < msgstr + msgstr_len;