#! /bin/sh

# Test that on glibc systems, the gettext() results come out in the correct
# encoding for locales that differ only in their encoding.

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

# This test works only on glibc systems.
grep '@GLIBC2@.*yes' ../config.status >/dev/null || {
  echo "Skipping test: not a glibc system"
  exit 77
}

# This test works only on systems that have a de_DE.ISO-8859-1 and
# de_DE.UTF-8 locale installed.
LC_ALL=de_DE.ISO-8859-1 ./testlocale || {
  if test -f /usr/bin/localedef; then
    echo "Skipping test: locale de_DE.ISO-8859-1 not installed"
  else
    echo "Skipping test: locale de_DE.ISO-8859-1 not supported"
  fi
  exit 77
}
LC_ALL=de_DE.UTF-8 ./testlocale || {
  if test -f /usr/bin/localedef; then
    echo "Skipping test: locale de_DE.UTF-8 not installed"
  else
    echo "Skipping test: locale de_DE.UTF-8 not supported"
  fi
  exit 77
}

tmpfiles="$tmpfiles de_DE"
test -d de_DE || mkdir de_DE
test -d de_DE/LC_MESSAGES || mkdir de_DE/LC_MESSAGES

: ${MSGFMT=msgfmt}
${MSGFMT} -o de_DE/LC_MESSAGES/codeset.mo ${top_srcdir}/tests/gettext-5.po

./gettext-5-prg || exit 1

rm -fr $tmpfiles

exit 0
