fix-empty-po.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. From 2336451ed68d91ff4b5ae1acbc1eca30e47a86a9 Mon Sep 17 00:00:00 2001
  2. From: Bruno Haible <bruno@clisp.org>
  3. Date: Sun, 19 May 2019 13:10:06 +0200
  4. Subject: [PATCH] msgmerge: Fix behaviour of --for-msgfmt on PO files with no
  5. translations.
  6. Reported by Don Lawrence <dlawrence@iecok.com>
  7. in <https://lists.freedesktop.org/archives/p11-glue/2019-May/000700.html>
  8. via Daiki Ueno
  9. in <https://lists.gnu.org/archive/html/bug-gettext/2019-05/msg00124.html>.
  10. * gettext-tools/src/msgmerge.c (main): Treat force_po like true if for_msgfmt
  11. is true.
  12. * gettext-tools/tests/msgmerge-26: Add test of PO file with no translations.
  13. ---
  14. gettext-tools/src/msgmerge.c | 4 ++--
  15. gettext-tools/tests/msgmerge-26 | 36 +++++++++++++++++++++++++++++++++---
  16. 2 files changed, 35 insertions(+), 5 deletions(-)
  17. diff --git a/gettext-tools/src/msgmerge.c b/gettext-tools/src/msgmerge.c
  18. index cd762c0..92c9b7a 100644
  19. --- a/gettext-tools/src/msgmerge.c
  20. +++ b/gettext-tools/src/msgmerge.c
  21. @@ -520,8 +520,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\
  22. else
  23. {
  24. /* Write the merged message list out. */
  25. - msgdomain_list_print (result, output_file, output_syntax, force_po,
  26. - false);
  27. + msgdomain_list_print (result, output_file, output_syntax,
  28. + for_msgfmt || force_po, false);
  29. }
  30. exit (EXIT_SUCCESS);
  31. diff --git a/gettext-tools/tests/msgmerge-26 b/gettext-tools/tests/msgmerge-26
  32. index cd3862e..b86f7a0 100755
  33. --- a/gettext-tools/tests/msgmerge-26
  34. +++ b/gettext-tools/tests/msgmerge-26
  35. @@ -73,7 +73,37 @@ msgstr "Papaya"
  36. EOF
  37. : ${DIFF=diff}
  38. -${DIFF} mm-test26.ok mm-test26.out
  39. -result=$?
  40. +${DIFF} mm-test26.ok mm-test26.out || Exit 1
  41. -exit $result
  42. +# Test with a PO file that has no translated messages.
  43. +
  44. +cat <<\EOF > mm-test26a.in1
  45. +msgid ""
  46. +msgstr ""
  47. +"Content-Type: text/plain; charset=UTF-8\n"
  48. +
  49. +msgid "Hello world"
  50. +msgstr "Hallo Welt"
  51. +EOF
  52. +
  53. +cat <<\EOF > mm-test26a.in2
  54. +msgid ""
  55. +msgstr ""
  56. +"Content-Type: text/plain; charset=ASCII\n"
  57. +
  58. +msgid "Hello, world!"
  59. +msgstr ""
  60. +EOF
  61. +
  62. +: ${MSGMERGE=msgmerge}
  63. +${MSGMERGE} --for-msgfmt -o mm-test26a.tmp mm-test26a.in1 mm-test26a.in2 \
  64. + || Exit 1
  65. +LC_ALL=C tr -d '\r' < mm-test26a.tmp > mm-test26a.out || Exit 1
  66. +
  67. +cat <<\EOF > mm-test26a.ok
  68. +msgid ""
  69. +msgstr "Content-Type: text/plain; charset=UTF-8\n"
  70. +EOF
  71. +
  72. +: ${DIFF=diff}
  73. +${DIFF} mm-test26a.ok mm-test26a.out || Exit 1
  74. --
  75. 1.9.1
  76. fix-empty-po.patch