#! /bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test --sort-by-file option, when no file positions are present.

cat <<\EOF > mm-test15.po
msgid "a"
msgstr "a"

#~ msgid "c"
#~ msgstr "c"

#~ msgid "d"
#~ msgstr "d"

#~ msgid "b"
#~ msgstr "b"
EOF

cat <<\EOF > mm-test15.pot
msgid "a"
msgstr ""
EOF

: ${MSGMERGE=msgmerge}
${MSGMERGE} -q --sort-by-file -o mm-test15.tmp mm-test15.po mm-test15.pot || Exit 1
LC_ALL=C tr -d '\r' < mm-test15.tmp > mm-test15.po2 || Exit 1
${MSGMERGE} -q --sort-by-file -o mm-test15.tmp mm-test15.po2 mm-test15.pot || Exit 1
LC_ALL=C tr -d '\r' < mm-test15.tmp > mm-test15.po3 || Exit 1

cat <<\EOF > mm-test15.ok
msgid "a"
msgstr "a"

#~ msgid "b"
#~ msgstr "b"

#~ msgid "c"
#~ msgstr "c"

#~ msgid "d"
#~ msgstr "d"
EOF

: ${DIFF=diff}
${DIFF} mm-test15.ok mm-test15.po2 || Exit 1
${DIFF} mm-test15.ok mm-test15.po3 || Exit 1

Exit 0
