#! /bin/sh

# Test C support: extraction of contexts specified in GNOME glib syntax.

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

tmpfiles="$tmpfiles xg-c-15.c"
cat <<\EOF > xg-c-15.c
/* (glib) The 1-argument Q_ macro is a gettext with context. */
print (Q_ ("Printer|Open"));
/* (hypothetical) The 2-argument Q_ macro is an ngettext with contexts. */
print (Q_ ("Menu|Recent File", "Menu|Recent Files"));
EOF

tmpfiles="$tmpfiles xg-c-15.po"
: ${XGETTEXT=xgettext}
${XGETTEXT} --omit-header --no-location \
  --keyword=Q_:1g --keyword=Q_:1g,2g \
  -d xg-c-15 xg-c-15.c
test $? = 0 || { rm -fr $tmpfiles; exit 1; }

tmpfiles="$tmpfiles xg-c-15.ok"
cat <<EOF > xg-c-15.ok
msgctxt "Printer"
msgid "Open"
msgstr ""

msgctxt "Menu"
msgid "Recent File"
msgid_plural "Recent Files"
msgstr[0] ""
msgstr[1] ""
EOF

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

rm -fr $tmpfiles

exit $result
