]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
msgmerge: Fix behaviour of --for-msgfmt on PO files with no translations.
authorBruno Haible <bruno@clisp.org>
Sun, 19 May 2019 11:10:06 +0000 (13:10 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 13 Apr 2020 10:50:04 +0000 (12:50 +0200)
Reported by Don Lawrence <dlawrence@iecok.com>
in <https://lists.freedesktop.org/archives/p11-glue/2019-May/000700.html>
via Daiki Ueno
in <https://lists.gnu.org/archive/html/bug-gettext/2019-05/msg00124.html>.

* gettext-tools/src/msgmerge.c (main): Treat force_po like true if for_msgfmt
is true.
* gettext-tools/tests/msgmerge-26: Add test of PO file with no translations.

gettext-tools/src/msgmerge.c
gettext-tools/tests/msgmerge-26

index cd762c029b0ee4ce498606e5cd1dccd17e62ee66..92c9b7a8e71e50095b682b275f157b7ca5813ef4 100644 (file)
@@ -520,8 +520,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\
   else
     {
       /* Write the merged message list out.  */
-      msgdomain_list_print (result, output_file, output_syntax, force_po,
-                            false);
+      msgdomain_list_print (result, output_file, output_syntax,
+                            for_msgfmt || force_po, false);
     }
 
   exit (EXIT_SUCCESS);
index cd3862e332bcd444646e91d13fab806c499e02a1..b86f7a07326e5dd77e1df890b9b7f28002c74af2 100755 (executable)
@@ -73,7 +73,37 @@ msgstr "Papaya"
 EOF
 
 : ${DIFF=diff}
-${DIFF} mm-test26.ok mm-test26.out
-result=$?
+${DIFF} mm-test26.ok mm-test26.out || Exit 1
 
-exit $result
+# Test with a PO file that has no translated messages.
+
+cat <<\EOF > mm-test26a.in1
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+
+msgid "Hello world"
+msgstr "Hallo Welt"
+EOF
+
+cat <<\EOF > mm-test26a.in2
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=ASCII\n"
+
+msgid "Hello, world!"
+msgstr ""
+EOF
+
+: ${MSGMERGE=msgmerge}
+${MSGMERGE} --for-msgfmt -o mm-test26a.tmp mm-test26a.in1 mm-test26a.in2 \
+    || Exit 1
+LC_ALL=C tr -d '\r' < mm-test26a.tmp > mm-test26a.out || Exit 1
+
+cat <<\EOF > mm-test26a.ok
+msgid ""
+msgstr "Content-Type: text/plain; charset=UTF-8\n"
+EOF
+
+: ${DIFF=diff}
+${DIFF} mm-test26a.ok mm-test26a.out || Exit 1