summaryrefslogtreecommitdiffstats
path: root/gettext-tools/src
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2008-11-14 11:10:35 +0000
committerBruno Haible <bruno@clisp.org>2009-06-23 12:15:55 +0200
commit26278fe9dc80e51ab9d06573ff5a83deaccbf72a (patch)
treefc9a6b979e18f864a50feb51d606f8fdd4ed34e0 /gettext-tools/src
parentd21ccd0bded88ff2fe68d137286681a27a65874e (diff)
downloadexternal_gettext-26278fe9dc80e51ab9d06573ff5a83deaccbf72a.zip
external_gettext-26278fe9dc80e51ab9d06573ff5a83deaccbf72a.tar.gz
external_gettext-26278fe9dc80e51ab9d06573ff5a83deaccbf72a.tar.bz2
msgfilter now sets the environment variables MSGFILTER_MSGCTXT,
MSGFILTER_MSGID, MSGFILTER_LOCATION.
Diffstat (limited to 'gettext-tools/src')
-rw-r--r--gettext-tools/src/ChangeLog6
-rw-r--r--gettext-tools/src/msgfilter.c14
2 files changed, 20 insertions, 0 deletions
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 3ccaabd..4ac3abc 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gettext-tools/src/msgfilter.c b/gettext-tools/src/msgfilter.c
index 1177361..66e5ffb 100644
--- a/gettext-tools/src/msgfilter.c
+++ b/gettext-tools/src/msgfilter.c
@@ -43,6 +43,7 @@
#include "closeout.h"
#include "dir-list.h"
#include "error.h"
+#include "xvasprintf.h"
#include "error-progname.h"
#include "progname.h"
#include "relocatable.h"
@@ -61,6 +62,7 @@
#include "findprog.h"
#include "pipe.h"
#include "wait-process.h"
+#include "xsetenv.h"
#include "filters.h"
#include "msgl-iconv.h"
#include "po-charset.h"
@@ -758,6 +760,7 @@ process_message (message_ty *mp)
{
const char *msgstr = mp->msgstr;
size_t msgstr_len = mp->msgstr_len;
+ char *location;
size_t nsubstrings;
char **substrings;
size_t total_len;
@@ -770,6 +773,17 @@ process_message (message_ty *mp)
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;