#!/bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
# Test Python support: --from-code option and encoding recognition.
-tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
-
-tmpfiles="$tmpfiles xg-py-3a.py"
cat <<\EOF > xg-py-3a.py
#!/usr/bin/env python
# TRANSLATORS: Fran\8f«®ois Pinard is a hero.
print gettext.gettext("ÆüËܸì");
EOF
-tmpfiles="$tmpfiles xg-py-3b.py"
cat <<\EOF > xg-py-3b.py
#!/usr/bin/env python
# Hey Emacs! -*- coding: euc-jp -*-
print gettext.gettext("ÆüËܸì");
EOF
-tmpfiles="$tmpfiles xg-py-3.ok"
cat <<\EOF > xg-py-3.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# Verify that if the source file has no magic coding comment, xgettext fails
# if no --from-code option is given but succeeds if it is given.
-tmpfiles="$tmpfiles xg-py-3a.tmp xg-py-3a.pot"
: ${XGETTEXT=xgettext}
${XGETTEXT} --add-comments=TRANSLATORS: --no-location \
-d xg-py-3a xg-py-3a.py > /dev/null 2>&1
-test $? = 1 || { rm -fr $tmpfiles; exit 1; }
+test $? = 1 || { exit 1; }
${XGETTEXT} --add-comments=TRANSLATORS: --no-location --from-code=euc-jp \
- -o xg-py-3a.tmp xg-py-3a.py
-test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+ -o xg-py-3a.tmp xg-py-3a.py || exit 1
# Don't simplify this to "grep ... < xg-py-3a.tmp", otherwise OpenBSD 4.0 grep
# only outputs "Binary file (standard input) matches".
cat xg-py-3a.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-py-3a.pot
: ${DIFF=diff}
-${DIFF} xg-py-3.ok xg-py-3a.pot
-test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+${DIFF} xg-py-3.ok xg-py-3a.pot || exit 1
# Verify that if the source file has a magic coding comment, xgettext succeeds.
-tmpfiles="$tmpfiles xg-py-3b.tmp xg-py-3b.pot"
${XGETTEXT} --add-comments=TRANSLATORS: --no-location \
- -o xg-py-3b.tmp xg-py-3b.py
-test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+ -o xg-py-3b.tmp xg-py-3b.py || exit 1
# Don't simplify this to "grep ... < xg-py-3b.tmp", otherwise OpenBSD 4.0 grep
# only outputs "Binary file (standard input) matches".
cat xg-py-3b.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-py-3b.pot
-${DIFF} xg-py-3.ok xg-py-3b.pot
-test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+${DIFF} xg-py-3.ok xg-py-3b.pot || exit 1
# Verify that if the source file has a magic coding comment and a --from-code
# option is given, the magic coding comment takes precedence over it.
-tmpfiles="$tmpfiles xg-py-3c.tmp xg-py-3c.pot"
${XGETTEXT} --add-comments=TRANSLATORS: --no-location --from-code=iso-8859-1 \
- -o xg-py-3c.tmp xg-py-3b.py
-test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+ -o xg-py-3c.tmp xg-py-3b.py || exit 1
# Don't simplify this to "grep ... < xg-py-3c.tmp", otherwise OpenBSD 4.0 grep
# only outputs "Binary file (standard input) matches".
cat xg-py-3c.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-py-3c.pot
-${DIFF} xg-py-3.ok xg-py-3c.pot
-test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+${DIFF} xg-py-3.ok xg-py-3c.pot || exit 1
# Verify that backslashes in and second bytes with value 0x5C are correctly
# distinguished in weird encodings like BIG5.
-tmpfiles="$tmpfiles xg-py-3d.py"
cat <<\EOF > xg-py-3d.py
#!/usr/bin/env python
# Hey Emacs! -*- coding: big5 -*-
print gettext.gettext(u"¬\\u0021");
EOF
-tmpfiles="$tmpfiles xg-py-3d.tmp xg-py-3d.pot"
${XGETTEXT} --add-comments=TRANSLATORS: \
- -o xg-py-3d.tmp xg-py-3d.py
-test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+ -o xg-py-3d.tmp xg-py-3d.py || exit 1
# Don't simplify this to "grep ... < xg-py-3d.tmp", otherwise OpenBSD 4.0 grep
# only outputs "Binary file (standard input) matches".
cat xg-py-3d.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-py-3d.pot
-tmpfiles="$tmpfiles xg-py-3d.ok"
cat <<\EOF > xg-py-3d.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
msgstr ""
EOF
-${DIFF} xg-py-3d.ok xg-py-3d.pot
-test $? = 0 || { rm -fr $tmpfiles; exit 1; }
-
-rm -fr $tmpfiles
+${DIFF} xg-py-3d.ok xg-py-3d.pot || exit 1
exit 0