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

# Test C support: mixing ANSI escapes, Unicode escapes, and bare
# multibyte characters.

cat <<\EOF > xg-c-19.in.c
/* 最初のコメント */
"最初の文字列";

/* 二番目のコメント */
gettext ("二番目の文字列");

/* 三番目のコメント */
pgettext ("\u30B3\u30F3\u30C6\u30AF\u30B9\u30C8", "\xBB\xB0\xC8\xD6\xCC\xDC\xA4\xCE\xCA\xB8\xBB\xFA\xCE\xF3");
EOF

: ${ICONV=iconv}
iconv --from UTF-8 --to EUC-JP < xg-c-19.in.c > xg-c-19.c \
  || { echo "Skipping test: iconv does not work for EUC-JP"; exit 77; }

: ${XGETTEXT=xgettext}
${XGETTEXT} --from-code=EUC-JP --add-comments --no-location \
	    -o - xg-c-19.c | grep -v 'POT-Creation-Date' > xg-c-19.tmp.po \
	    || exit 1
LC_ALL=C tr -d '\r' < xg-c-19.tmp.po > xg-c-19.po || exit 1

cat <<EOF > xg-c-19.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \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"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#. 二番目のコメント
msgid "二番目の文字列"
msgstr ""

#. 三番目のコメント
msgctxt "コンテクスト"
msgid "三番目の文字列"
msgstr ""
EOF

: ${DIFF=diff}
${DIFF} xg-c-19.ok xg-c-19.po
result=$?

exit $result
