]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
msgfilter: Pass previous msgid to the child process
authorDaiki Ueno <ueno@gnu.org>
Sat, 31 May 2014 02:28:39 +0000 (11:28 +0900)
committerDaiki Ueno <ueno@gnu.org>
Sat, 31 May 2014 05:56:52 +0000 (14:56 +0900)
Suggested by Pavel Kharitonov in:
<http://lists.gnu.org/archive/html/bug-gettext/2014-05/msg00022.html>.
* msgfilter.c (process_message): Set MSGFILTER_PREV_* envvar.

gettext-tools/doc/ChangeLog
gettext-tools/doc/msgfilter.texi
gettext-tools/src/ChangeLog
gettext-tools/src/msgfilter.c
gettext-tools/tests/ChangeLog
gettext-tools/tests/msgfilter-6

index 5f236dd916bf539677cde1828f568905417e0e17..257b46da1ac8129a4266510516600a7a512c30aa 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-31  Daiki Ueno  <ueno@gnu.org>
+
+       * msgfilter.texi: Document the environment variable
+       MSGFILTER_PREV_MSGCTXT, MSGFILTER_PREV_MSGID, and
+       MSGFILTER_PREV_MSGID_PLURAL.
+
 2014-05-15  Stanislav Brabec  <sbrabec@suse.cz>  (tiny change)
 
        * msgfilter.texi: Document the environment variable
index 22fbab759eee2e1cb464a6a4b05875d96d8e121a..1fae2514b984e5ca60b0db0e812cbd9b5c4521fe 100644 (file)
@@ -13,6 +13,9 @@ translation catalog.
 @vindex MSGFILTER_MSGID_PLURAL@r{, environment variable}
 @vindex MSGFILTER_LOCATION@r{, environment variable}
 @vindex MSGFILTER_PLURAL_FORM@r{, environment variable}
+@vindex MSGFILTER_PREV_MSGCTXT@r{, environment variable}
+@vindex MSGFILTER_PREV_MSGID@r{, environment variable}
+@vindex MSGFILTER_PREV_MSGID_PLURAL@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
@@ -22,6 +25,11 @@ unbound.  If the message has a plural form, environment variable
 @code{MSGFILTER_MSGID_PLURAL} is bound to the message's msgid_plural and
 @code{MSGFILTER_PLURAL_FORM} is bound to the order number of the plural
 actually processed (starting with 0), otherwise both are unbound.
+If the message has a previous msgid (added by @code{msgmerge}),
+environment variable @code{MSGFILTER_PREV_MSGCTXT} is bound to the
+message's previous msgctxt, @code{MSGFILTER_PREV_MSGID} is bound to
+the previous msgid, and @code{MSGFILTER_PREV_MSGID_PLURAL} is bound to
+the previous msgid_plural.
 
 @subsection Input file location
 
index 596e3a53abe03472b5953faa6d8616bb5bdfc984..8247050e64e8c7890c4ec17b5038dff26b57774a 100644 (file)
@@ -1,3 +1,10 @@
+2014-05-31  Daiki Ueno  <ueno@gnu.org>
+
+       msgfilter: Pass previous msgid to the child process
+       Suggested by Pavel Kharitonov in:
+       <http://lists.gnu.org/archive/html/bug-gettext/2014-05/msg00022.html>.
+       * msgfilter.c (process_message): Set MSGFILTER_PREV_* envvar.
+
 2014-05-19  Daiki Ueno  <ueno@gnu.org>
 
        * Makefile.am (po-gram-gen2.h): Adjust the directory to which
index f172a4585936dc83d6942801bb6b189af7c66254..961b1f11537e82793eb35144330431ce52a73ba2 100644 (file)
@@ -671,6 +671,18 @@ process_message (message_ty *mp)
                         (long) mp->pos.line_number);
   xsetenv ("MSGFILTER_LOCATION", location, 1);
   free (location);
+  if (mp->prev_msgctxt != NULL)
+    xsetenv ("MSGFILTER_PREV_MSGCTXT", mp->prev_msgctxt, 1);
+  else
+    unsetenv ("MSGFILTER_PREV_MSGCTXT");
+  if (mp->prev_msgid != NULL)
+    xsetenv ("MSGFILTER_PREV_MSGID", mp->prev_msgid, 1);
+  else
+    unsetenv ("MSGFILTER_PREV_MSGID");
+  if (mp->prev_msgid_plural != NULL)
+    xsetenv ("MSGFILTER_PREV_MSGID_PLURAL", mp->prev_msgid_plural, 1);
+  else
+    unsetenv ("MSGFILTER_PREV_MSGID_PLURAL");
 
   /* Count NUL delimited substrings.  */
   for (p = msgstr, nsubstrings = 0;
index 4eb30b334cccfb76c161688011b13d7b67954e74..1b421f56746f014338baf239ab5068e29d950532 100644 (file)
@@ -1,3 +1,8 @@
+2014-05-31  Daiki Ueno  <ueno@gnu.org>
+
+       * msgfilter-6: Test MSGFILTER_PREV_MSGID and
+       MSGFILTER_PREV_MSGID_PLURAL.
+
 2014-05-15  Daiki Ueno  <ueno@gnu.org>
 
        tests: Add test for msgfilter plural handling
index 81ef3185d0581bcf70a8939cb6dee390bf56e59c..ddf78696e9a097a021c638b2eaaa99e8ce7feb60 100755 (executable)
@@ -15,6 +15,8 @@ msgstr "'Votre commande, s'il vous plait', dit le garcon."
 
 # Les gateaux allemands sont les meilleurs du monde.
 #, c-format
+#| msgid "a piece of bread"
+#| msgid_plural "%d pieces of bread"
 msgid "a piece of cake"
 msgid_plural "%d pieces of cake"
 msgstr[0] "un morceau de gateau"
@@ -38,6 +40,8 @@ cat >> mf-test6.tmp <<MEOF
 $MSGFILTER_MSGID
 $MSGFILTER_MSGID_PLURAL
 $MSGFILTER_PLURAL_FORM
+$MSGFILTER_PREV_MSGID
+$MSGFILTER_PREV_MSGID_PLURAL
 MEOF
 cat
 EOF
@@ -58,22 +62,32 @@ cat <<\EOF > mf-test6.ok
 
 
 
+
+
 ========================= mf-test6.po:8 =========================
 'Your command, please?', asked the waiter.
 
 
-========================= mf-test6.po:14 =========================
+
+
+========================= mf-test6.po:16 =========================
 a piece of cake
 %d pieces of cake
 0
-========================= mf-test6.po:14 =========================
+a piece of bread
+%d pieces of bread
+========================= mf-test6.po:16 =========================
 a piece of cake
 %d pieces of cake
 1
-========================= mf-test6.po:20 =========================
+a piece of bread
+%d pieces of bread
+========================= mf-test6.po:22 =========================
 %s is replaced by %s.
 
 
+
+
 EOF
 
 : ${DIFF=diff}