+2007-09-30 Bruno Haible <bruno@clisp.org>
+
+ Add support for KDE 4 format strings.
+ * format-kde-1: New file.
+ * format-kde-2: New file.
+ * Makefile.am (TESTS): Add them.
+ Based on input by by Chusslove Illich <caslav.ilic@gmx.net>.
+
2007-09-09 Bruno Haible <bruno@clisp.org>
Add support for Qt 4 format strings.
format-elisp-1 format-elisp-2 \
format-gcc-internal-1 format-gcc-internal-2 \
format-java-1 format-java-2 \
+ format-kde-1 format-kde-2 \
format-librep-1 format-librep-2 \
format-lisp-1 format-lisp-2 \
format-php-1 format-php-2 \
--- /dev/null
+#! /bin/sh
+
+# Test recognition of KDE format strings.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles f-kd-1.data"
+cat <<\EOF > f-kd-1.data
+# Unrecognized: no argument
+"abc%%def"
+# Valid: one argument
+"abc%1def"
+# Unrecognized: no argument (digit sequence starting with a zero)
+"abc%09def"
+# Valid: one argument, digit sequence starting with a zero
+"abc%1def%0"
+# Valid: one argument, digit sequence starting with a zero
+"abc%1def%00"
+# Valid: 9 arguments
+"abc%1%2%3%4%9%7%8%5%6def"
+# Valid: 9 arguments, missing one of them
+"abc%1%2%3%4%9%7%5%6def"
+# Invalid: one argument but missing arguments %1 ... %8
+"abc%9def"
+# Valid: more than ten arguments, missing one of them
+"abc%1%2%3%4%9%7%5%6%12%10%11def"
+# Invalid: one argument specified by two digits but missing arguments %1 ... %98
+"abc%99def"
+# Valid: unterminated
+"abc%1def%"
+# Valid: unterminated
+"abc%1def%L"
+# Valid: non-digit
+"abc%1def%x"
+# Valid: permutation
+"abc%2def%1"
+# Valid: multiple uses of same argument
+"abc%2def%1ghi%2"
+# Unrecognized: no argument
+"abc%L1def"
+# Unrecognized: no argument
+"abc%L12def"
+EOF
+
+: ${XGETTEXT=xgettext}
+n=0
+while read comment; do
+ read string
+ n=`expr $n + 1`
+ tmpfiles="$tmpfiles f-kd-1-$n.in f-kd-1-$n.po"
+ cat <<EOF > f-kd-1-$n.in
+_(${string});
+EOF
+ ${XGETTEXT} -L C++ --kde -k_ -o f-kd-1-$n.po f-kd-1-$n.in || exit 1
+ test -f f-kd-1-$n.po || exit 1
+ fail=
+ if echo "$comment" | grep 'Valid:' > /dev/null; then
+ if grep kde-format f-kd-1-$n.po > /dev/null; then
+ :
+ else
+ fail=yes
+ fi
+ else
+ if grep kde-format f-kd-1-$n.po > /dev/null; then
+ fail=yes
+ else
+ :
+ fi
+ fi
+ if test -n "$fail"; then
+ echo "Format string recognition error:" 1>&2
+ cat f-kd-1-$n.in 1>&2
+ echo "Got:" 1>&2
+ cat f-kd-1-$n.po 1>&2
+ exit 1
+ fi
+ rm -f f-kd-1-$n.in f-kd-1-$n.po
+done < f-kd-1.data
+
+rm -fr $tmpfiles
+
+exit 0
--- /dev/null
+#! /bin/sh
+
+# Test checking of KDE format strings.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles f-kd-2.data"
+cat <<\EOF > f-kd-2.data
+# Valid: %% doesn't count
+msgid "abc%%def"
+msgstr "xyz"
+# Valid: digit sequence starting with 0 doesn't count
+msgid "abc%09def"
+msgstr "xyz"
+# Valid: digit sequence starting with 0 doesn't count
+msgid "abc%0"
+msgstr "xyz"
+# Valid: digit sequence starting with 0 doesn't count
+msgid "abc%00"
+msgstr "xyz"
+# Valid: L is not a recognized flag
+msgid "abc%L1def"
+msgstr "xyz"
+# Valid: same arguments
+msgid "abc%2def"
+msgstr "xyz%2"
+# Invalid: different arguments
+msgid "abc%2def"
+msgstr "xyz%1"
+# Invalid: different arguments
+msgid "abc%1def"
+msgstr "xyz%2"
+# Valid: repetition of an argument in the translation
+msgid "abc%2def"
+msgstr "xyz%2uvw%2"
+# Valid: removing repeated argument in the translation
+msgid "abc%2def%2"
+msgstr "xyz%2uvw"
+# Valid: permutation
+msgid "abc%3%1%2def"
+msgstr "xyz%2%1%3"
+# Invalid: too few arguments
+msgid "abc%2def%1ghi%3"
+msgstr "xyz%1"
+# Invalid: only one argument removed (valid only in singular form)
+msgid "abc%2def%1ghi%3"
+msgstr "xyz%1uvw%2"
+# Invalid: only one argument removed (valid only in singular form)
+msgid "abc%2def%1ghi%3"
+msgstr "xyz%1uvw%3"
+# Invalid: only one argument removed (valid only in singular form)
+msgid "abc%2def%1ghi%3"
+msgstr "xyz%3uvw%2"
+# Invalid: only one argument removed (valid only in singular form)
+msgid "abc%1def%3"
+msgstr "xyz%1"
+# Invalid: wrong argument removed
+msgid "abc%1def%3"
+msgstr "xyz%3"
+# Invalid: too many arguments
+msgid "abc%1def"
+msgstr "xyz%1uvw%2"
+# Invalid: missing non-final argument (valid only in singular form)
+msgid "abc%2def%1"
+msgstr "xyz%2"
+# Invalid: added non-final argument
+msgid "abc%2def"
+msgstr "xyz%1%2"
+EOF
+
+: ${MSGFMT=msgfmt}
+n=0
+while read comment; do
+ read msgid_line
+ read msgstr_line
+ n=`expr $n + 1`
+ tmpfiles="$tmpfiles f-kd-2-$n.po f-kd-2-$n.mo"
+ cat <<EOF > f-kd-2-$n.po
+#, kde-format
+${msgid_line}
+${msgstr_line}
+EOF
+ fail=
+ if echo "$comment" | grep 'Valid:' > /dev/null; then
+ if ${MSGFMT} --check-format -o f-kd-2-$n.mo f-kd-2-$n.po; then
+ :
+ else
+ fail=yes
+ fi
+ else
+ ${MSGFMT} --check-format -o f-kd-2-$n.mo f-kd-2-$n.po 2> /dev/null
+ if test $? = 1; then
+ :
+ else
+ fail=yes
+ fi
+ fi
+ if test -n "$fail"; then
+ echo "Format string checking error:" 1>&2
+ cat f-kd-2-$n.po 1>&2
+ exit 1
+ fi
+ rm -f f-kd-2-$n.po f-kd-2-$n.mo
+done < f-kd-2.data
+
+rm -fr $tmpfiles
+
+exit 0