#! /bin/sh

# Test handling of header entry.

tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15

tmpfiles="$tmpfiles mm-test5.in1.po mm-test5.in2.po"
cat <<EOF > mm-test5.in1.po
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Free Software Foundation, Inc.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Content-Transfer-Encoding: ENCODING\n"
"MIME-Version: 1.0\n"
"Test: bla bla\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Project-Id-Version: PACKAGE VERSION\n"

msgid ""
"whatever, doesn't matter\n"
msgstr ""
"blah blah blah blah blah blah blah blah blah blah blah blah blah bla bla bla\n"
EOF

cat <<EOF > mm-test5.in2.po
msgid ""
msgstr ""

msgid ""
"whatever, doesn't matter\n"
msgstr ""
"blah blah blah blah blah blah blah blah blah blah blah blah blah bla bla bla\n"
EOF

tmpfiles="$tmpfiles mm-test5.out mm-test5.err"
: ${MSGMERGE=msgmerge}
LC_MESSAGES=C LC_ALL= \
${MSGMERGE} -q mm-test5.in1.po mm-test5.in2.po -o mm-test5.out >mm-test5.err 2>&1
result=$?
cat mm-test5.err | grep -v 'warning: Charset' | grep -v '^ '
test $result = 0 || { rm -fr $tmpfiles; exit 1; }

tmpfiles="$tmpfiles mm-test5.ok"
cat <<EOF > mm-test5.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Free Software Foundation, Inc.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
"Test: bla bla\n"

msgid "whatever, doesn't matter\n"
msgstr ""
"blah blah blah blah blah blah blah blah blah blah blah blah blah bla bla "
"bla\n"
EOF

: ${DIFF=diff}
${DIFF} mm-test5.ok mm-test5.out
result=$?

rm -fr $tmpfiles

exit $result
