• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Test checking of KDE KUIT format strings.
5
6cat <<\EOF > f-kd-invalid.po
7#, kde-kuit-format
8msgid "foo"
9msgstr "<"
10EOF
11
12: ${MSGFMT=msgfmt}
13
14LC_ALL=C ${MSGFMT} --check-format -o /dev/null f-kd-invalid.po 2>&1 | grep 'not a valid KDE KUIT format' > /dev/null 2>&1
15test $? = 0 || {
16  echo "Skipping test: msgfmt was built without KDE KUIT format support"
17  Exit 77
18}
19
20cat <<\EOF > f-kd-2.data
21# Valid: one argument
22msgid "<filename>%1</filename>"
23msgstr "<filename>%1</filename>"
24# Invalid: missing argument
25msgid "<filename>%1</filename>"
26msgstr "<filename>foo</filename>"
27# Valid: change the text
28msgid "<filename>foo</filename>"
29msgstr "<filename>bar</filename>"
30# Invalid: unbalanced tag
31msgid "<filename>foo</filename>"
32msgstr "<filename>bar"
33# Invalid: unbalanced tag
34msgid "<filename>foo</filename>"
35msgstr "<filename>bar</xfilename>"
36# Valid: replaced tag
37msgid "<filename>foo</filename>"
38msgstr "<foo>foo</foo>"
39# Valid: accelerator
40msgid "<filename>&foo</filename>"
41msgstr "<foo>&foo</foo>"
42# Valid: entity reference
43msgid "<filename>foo</filename>"
44msgstr "<foo>&amp;</foo>"
45EOF
46
47n=0
48while read comment; do
49  read msgid_line
50  read msgstr_line
51  n=`expr $n + 1`
52  cat <<EOF > f-kd-2-$n.po
53#, kde-kuit-format
54${msgid_line}
55${msgstr_line}
56EOF
57  fail=
58  if echo "$comment" | grep 'Valid:' > /dev/null; then
59    if ${MSGFMT} --check-format -o f-kd-2-$n.mo f-kd-2-$n.po; then
60      :
61    else
62      fail=yes
63    fi
64  else
65    ${MSGFMT} --check-format -o f-kd-2-$n.mo f-kd-2-$n.po 2> /dev/null
66    if test $? = 1; then
67      :
68    else
69      fail=yes
70    fi
71  fi
72  if test -n "$fail"; then
73    echo "Format string checking error:" 1>&2
74    cat f-kd-2-$n.po 1>&2
75    Exit 1
76  fi
77  rm -f f-kd-2-$n.po f-kd-2-$n.mo
78done < f-kd-2.data
79
80Exit 0
81