]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
msgexec: Pass previous msgid to the child process
authorDaiki Ueno <ueno@gnu.org>
Sat, 31 May 2014 06:44:17 +0000 (15:44 +0900)
committerDaiki Ueno <ueno@gnu.org>
Sat, 31 May 2014 06:44:17 +0000 (15:44 +0900)
Suggested by Pavel Kharitonov in:
<http://lists.gnu.org/archive/html/bug-gettext/2014-05/msg00022.html>.
* msgexec.c (process_string): Set MSGEXEC_PREV_* envvar.

gettext-tools/doc/ChangeLog
gettext-tools/doc/msgexec.texi
gettext-tools/src/ChangeLog
gettext-tools/src/msgexec.c
gettext-tools/tests/ChangeLog
gettext-tools/tests/msgexec-5

index 257b46da1ac8129a4266510516600a7a512c30aa..78009db8ca3b64e55b5a13ed36a6d8e45e356696 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-31  Daiki Ueno  <ueno@gnu.org>
+
+       * msgexec.texi: Document the environment variable
+       MSGEXEC_PREV_MSGCTXT, MSGEXEC_PREV_MSGID, and
+       MSGEXEC_PREV_MSGID_PLURAL.
+
 2014-05-31  Daiki Ueno  <ueno@gnu.org>
 
        * msgfilter.texi: Document the environment variable
index 5ef640c866f3d101cb17931c3e9027ca1bf96a02..a190072c280c5aa6bfdb0d50052140630e34de54 100644 (file)
@@ -22,6 +22,9 @@ by a null byte.  The output of @samp{msgexec 0} is suitable as input for
 @vindex MSGEXEC_MSGID_PLURAL@r{, environment variable}
 @vindex MSGEXEC_LOCATION@r{, environment variable}
 @vindex MSGEXEC_PLURAL_FORM@r{, environment variable}
+@vindex MSGEXEC_PREV_MSGCTXT@r{, environment variable}
+@vindex MSGEXEC_PREV_MSGID@r{, environment variable}
+@vindex MSGEXEC_PREV_MSGID_PLURAL@r{, environment variable}
 During each @var{command} invocation, the environment variable
 @code{MSGEXEC_MSGID} is bound to the message's msgid, and the environment
 variable @code{MSGEXEC_LOCATION} is bound to the location in the PO file
@@ -31,6 +34,11 @@ unbound.  If the message has a plural form, environment variable
 @code{MSGEXEC_MSGID_PLURAL} is bound to the message's msgid_plural and
 @code{MSGEXEC_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{MSGEXEC_PREV_MSGCTXT} is bound to the
+message's previous msgctxt, @code{MSGEXEC_PREV_MSGID} is bound to
+the previous msgid, and @code{MSGEXEC_PREV_MSGID_PLURAL} is bound to
+the previous msgid_plural.
 
 @cindex catalog encoding and @code{msgexec} output
 Note: It is your responsibility to ensure that the @var{command} can cope
index 8247050e64e8c7890c4ec17b5038dff26b57774a..19641dcc100f00e5d5590742af639353c2196cc8 100644 (file)
@@ -1,3 +1,10 @@
+2014-05-31  Daiki Ueno  <ueno@gnu.org>
+
+       msgexec: Pass previous msgid to the child process
+       Suggested by Pavel Kharitonov in:
+       <http://lists.gnu.org/archive/html/bug-gettext/2014-05/msg00022.html>.
+       * msgexec.c (process_string): Set MSGEXEC_PREV_* envvar.
+
 2014-05-31  Daiki Ueno  <ueno@gnu.org>
 
        msgfilter: Pass previous msgid to the child process
index c3af66a8fbd1ec1b1892f9d1e4facf24632b3a4d..7a5d550cfaea1f49640278c2dfcc0ce50fb45cd5 100644 (file)
@@ -378,6 +378,18 @@ process_string (const message_ty *mp, const char *str, size_t len)
                             (long) mp->pos.line_number);
       xsetenv ("MSGEXEC_LOCATION", location, 1);
       free (location);
+      if (mp->prev_msgctxt != NULL)
+        xsetenv ("MSGEXEC_PREV_MSGCTXT", mp->prev_msgctxt, 1);
+      else
+        unsetenv ("MSGEXEC_PREV_MSGCTXT");
+      if (mp->prev_msgid != NULL)
+        xsetenv ("MSGEXEC_PREV_MSGID", mp->prev_msgid, 1);
+      else
+        unsetenv ("MSGEXEC_PREV_MSGID");
+      if (mp->prev_msgid_plural != NULL)
+        xsetenv ("MSGEXEC_PREV_MSGID_PLURAL", mp->prev_msgid_plural, 1);
+      else
+        unsetenv ("MSGEXEC_PREV_MSGID_PLURAL");
 
       /* Open a pipe to a subprocess.  */
       child = create_pipe_out (sub_name, sub_path, sub_argv, NULL, false, true,
index 1b421f56746f014338baf239ab5068e29d950532..aa1d3f0fe35cd2c6e340a4620e06f18bf8c6358d 100644 (file)
@@ -1,3 +1,7 @@
+2014-05-31  Daiki Ueno  <ueno@gnu.org>
+
+       * msgexec-5: Test MSGEXEC_PREV_MSGID and MSGEXEC_PREV_MSGID_PLURAL.
+
 2014-05-31  Daiki Ueno  <ueno@gnu.org>
 
        * msgfilter-6: Test MSGFILTER_PREV_MSGID and
index 1b9dac646ddbef36f8adab707207ec20fc54cca7..a2c13cd20235f01806bde430d08ee668c2572f4a 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"
@@ -36,6 +38,8 @@ cat <<MEOF
 $MSGEXEC_MSGID
 $MSGEXEC_MSGID_PLURAL
 $MSGEXEC_PLURAL_FORM
+$MSGEXEC_PREV_MSGID
+$MSGEXEC_PREV_MSGID_PLURAL
 ---
 MEOF
 cat
@@ -56,6 +60,8 @@ cat <<\EOF > mex-test5.ok
 
 
 
+
+
 ---
 Content-Type: text/plain; charset=ASCII
 Plural-Forms: nplurals=2; plural=(n > 1);
@@ -64,24 +70,32 @@ Plural-Forms: nplurals=2; plural=(n > 1);
 'Your command, please?', asked the waiter.
 
 
+
+
 ---
 'Votre commande, s'il vous plait', dit le garcon.
-========================= mex-test5.po:14 =========================
+========================= mex-test5.po:16 =========================
 a piece of cake
 %d pieces of cake
 0
+a piece of bread
+%d pieces of bread
 ---
 un morceau de gateau
-========================= mex-test5.po:14 =========================
+========================= mex-test5.po:16 =========================
 a piece of cake
 %d pieces of cake
 1
+a piece of bread
+%d pieces of bread
 ---
 %d morceaux de gateau
-========================= mex-test5.po:20 =========================
+========================= mex-test5.po:22 =========================
 %s is replaced by %s.
 
 
+
+
 ---
 %2$s remplace %1$s.
 EOF