1 1.1 christos #! /bin/sh 2 1.1 christos 3 1.1 christos # Test checking of Boost format strings. 4 1.1 christos 5 1.1 christos tmpfiles="" 6 1.1 christos trap 'rm -fr $tmpfiles' 1 2 3 15 7 1.1 christos 8 1.1 christos tmpfiles="$tmpfiles f-bo-2.data" 9 1.1 christos cat <<\EOF > f-bo-2.data 10 1.1 christos # Valid: %% doesn't count 11 1.1 christos msgid "abc%%def" 12 1.1 christos msgstr "xyz" 13 1.1 christos # Invalid: invalid msgstr 14 1.1 christos msgid "abc%%def" 15 1.1 christos msgstr "xyz%" 16 1.1 christos # Valid: same arguments 17 1.1 christos msgid "abc%s%gdef" 18 1.1 christos msgstr "xyz%s%g" 19 1.1 christos # Valid: same arguments, despite different syntax 20 1.1 christos msgid "abc%s%gdef" 21 1.1 christos msgstr "xyz%|s|%|g|" 22 1.1 christos # Valid: same arguments, with different widths 23 1.1 christos msgid "abc%2sdef" 24 1.1 christos msgstr "xyz%3s" 25 1.1 christos # Valid: same arguments but in numbered syntax 26 1.1 christos msgid "abc%s%gdef" 27 1.1 christos msgstr "xyz%1$s%2$g" 28 1.1 christos # Valid: same arguments but in numbered syntax 29 1.1 christos msgid "abc%s%gdef" 30 1.1 christos msgstr "xyz%1%%2$g" 31 1.1 christos # Valid: permutation 32 1.1 christos msgid "abc%s%g%cdef" 33 1.1 christos msgstr "xyz%3$c%2$g%1$s" 34 1.1 christos # Invalid: too few arguments 35 1.1 christos msgid "abc%2$udef%1$s" 36 1.1 christos msgstr "xyz%1$s" 37 1.1 christos # Invalid: too few arguments 38 1.1 christos msgid "abc%sdef%u" 39 1.1 christos msgstr "xyz%s" 40 1.1 christos # Invalid: too many arguments 41 1.1 christos msgid "abc%udef" 42 1.1 christos msgstr "xyz%uvw%c" 43 1.1 christos # Valid: same numbered arguments, with different widths 44 1.1 christos msgid "abc%2$5s%1$4s" 45 1.1 christos msgstr "xyz%2$4s%1$5s" 46 1.1 christos # Invalid: missing argument 47 1.1 christos msgid "abc%2$sdef%1$u" 48 1.1 christos msgstr "xyz%1$u" 49 1.1 christos # Invalid: missing argument 50 1.1 christos msgid "abc%1$sdef%2$u" 51 1.1 christos msgstr "xyz%2$u" 52 1.1 christos # Invalid: added argument 53 1.1 christos msgid "abc%1$udef" 54 1.1 christos msgstr "xyz%1$uvw%2$c" 55 1.1 christos # Valid: type compatibility 56 1.1 christos msgid "abc%i" 57 1.1 christos msgstr "xyz%d" 58 1.1 christos # Valid: type compatibility 59 1.1 christos msgid "abc%i" 60 1.1 christos msgstr "xyz%o" 61 1.1 christos # Valid: type compatibility 62 1.1 christos msgid "abc%i" 63 1.1 christos msgstr "xyz%u" 64 1.1 christos # Valid: type compatibility 65 1.1 christos msgid "abc%i" 66 1.1 christos msgstr "xyz%x" 67 1.1 christos # Valid: type compatibility 68 1.1 christos msgid "abc%i" 69 1.1 christos msgstr "xyz%X" 70 1.1 christos # Valid: type compatibility 71 1.1 christos msgid "abc%e" 72 1.1 christos msgstr "xyz%E" 73 1.1 christos # Valid: type compatibility 74 1.1 christos msgid "abc%e" 75 1.1 christos msgstr "xyz%f" 76 1.1 christos # Valid: type compatibility 77 1.1 christos msgid "abc%e" 78 1.1 christos msgstr "xyz%g" 79 1.1 christos # Valid: type compatibility 80 1.1 christos msgid "abc%e" 81 1.1 christos msgstr "xyz%G" 82 1.1 christos # Invalid: type incompatibility 83 1.1 christos msgid "abc%c" 84 1.1 christos msgstr "xyz%s" 85 1.1 christos # Invalid: type incompatibility 86 1.1 christos msgid "abc%c" 87 1.1 christos msgstr "xyz%i" 88 1.1 christos # Invalid: type incompatibility 89 1.1 christos msgid "abc%c" 90 1.1 christos msgstr "xyz%e" 91 1.1 christos # Invalid: type incompatibility 92 1.1 christos msgid "abc%c" 93 1.1 christos msgstr "xyz%p" 94 1.1 christos # Invalid: different argument count 95 1.1 christos msgid "abc%c" 96 1.1 christos msgstr "xyz%n" 97 1.1 christos # Invalid: type incompatibility 98 1.1 christos msgid "abc%s" 99 1.1 christos msgstr "xyz%i" 100 1.1 christos # Invalid: type incompatibility 101 1.1 christos msgid "abc%s" 102 1.1 christos msgstr "xyz%e" 103 1.1 christos # Invalid: type incompatibility 104 1.1 christos msgid "abc%s" 105 1.1 christos msgstr "xyz%p" 106 1.1 christos # Invalid: different argument count 107 1.1 christos msgid "abc%s" 108 1.1 christos msgstr "xyz%n" 109 1.1 christos # Invalid: type incompatibility 110 1.1 christos msgid "abc%i" 111 1.1 christos msgstr "xyz%e" 112 1.1 christos # Invalid: type incompatibility 113 1.1 christos msgid "abc%i" 114 1.1 christos msgstr "xyz%p" 115 1.1 christos # Invalid: different argument count 116 1.1 christos msgid "abc%i" 117 1.1 christos msgstr "xyz%n" 118 1.1 christos # Invalid: type incompatibility 119 1.1 christos msgid "abc%e" 120 1.1 christos msgstr "xyz%p" 121 1.1 christos # Invalid: different argument count 122 1.1 christos msgid "abc%e" 123 1.1 christos msgstr "xyz%n" 124 1.1 christos # Invalid: different argument count 125 1.1 christos msgid "abc%p" 126 1.1 christos msgstr "xyz%n" 127 1.1 christos # Valid: size is ignored 128 1.1 christos msgid "abc%i" 129 1.1 christos msgstr "xyz%hhi" 130 1.1 christos # Valid: size is ignored 131 1.1 christos msgid "abc%i" 132 1.1 christos msgstr "xyz%hi" 133 1.1 christos # Valid: size is ignored 134 1.1 christos msgid "abc%i" 135 1.1 christos msgstr "xyz%li" 136 1.1 christos # Valid: size is ignored 137 1.1 christos msgid "abc%i" 138 1.1 christos msgstr "xyz%lli" 139 1.1 christos # Valid: size is ignored 140 1.1 christos msgid "abc%i" 141 1.1 christos msgstr "xyz%Li" 142 1.1 christos # Valid: size is ignored 143 1.1 christos msgid "abc%hhi" 144 1.1 christos msgstr "xyz%hi" 145 1.1 christos # Valid: size is ignored 146 1.1 christos msgid "abc%hhi" 147 1.1 christos msgstr "xyz%li" 148 1.1 christos # Valid: size is ignored 149 1.1 christos msgid "abc%hhi" 150 1.1 christos msgstr "xyz%lli" 151 1.1 christos # Valid: size is ignored 152 1.1 christos msgid "abc%hhi" 153 1.1 christos msgstr "xyz%Li" 154 1.1 christos # Valid: size is ignored 155 1.1 christos msgid "abc%hi" 156 1.1 christos msgstr "xyz%li" 157 1.1 christos # Valid: size is ignored 158 1.1 christos msgid "abc%hi" 159 1.1 christos msgstr "xyz%lli" 160 1.1 christos # Valid: size is ignored 161 1.1 christos msgid "abc%hi" 162 1.1 christos msgstr "xyz%Li" 163 1.1 christos # Valid: size is ignored 164 1.1 christos msgid "abc%li" 165 1.1 christos msgstr "xyz%lli" 166 1.1 christos # Valid: size is ignored 167 1.1 christos msgid "abc%li" 168 1.1 christos msgstr "xyz%Li" 169 1.1 christos # Invalid: type incompatibility for width 170 1.1 christos msgid "abc%g%*g" 171 1.1 christos msgstr "xyz%*g%g" 172 1.1 christos EOF 173 1.1 christos 174 1.1 christos : ${MSGFMT=msgfmt} 175 1.1 christos n=0 176 1.1 christos while read comment; do 177 1.1 christos read msgid_line 178 1.1 christos read msgstr_line 179 1.1 christos n=`expr $n + 1` 180 1.1 christos tmpfiles="$tmpfiles f-bo-2-$n.po f-bo-2-$n.mo" 181 1.1 christos cat <<EOF > f-bo-2-$n.po 182 1.1 christos #, boost-format 183 1.1 christos ${msgid_line} 184 1.1 christos ${msgstr_line} 185 1.1 christos EOF 186 1.1 christos fail= 187 1.1 christos if echo "$comment" | grep 'Valid:' > /dev/null; then 188 1.1 christos if ${MSGFMT} --check-format -o f-bo-2-$n.mo f-bo-2-$n.po; then 189 1.1 christos : 190 1.1 christos else 191 1.1 christos fail=yes 192 1.1 christos fi 193 1.1 christos else 194 1.1 christos ${MSGFMT} --check-format -o f-bo-2-$n.mo f-bo-2-$n.po 2> /dev/null 195 1.1 christos if test $? = 1; then 196 1.1 christos : 197 1.1 christos else 198 1.1 christos fail=yes 199 1.1 christos fi 200 1.1 christos fi 201 1.1 christos if test -n "$fail"; then 202 1.1 christos echo "Format string checking error:" 1>&2 203 1.1 christos cat f-bo-2-$n.po 1>&2 204 1.1 christos exit 1 205 1.1 christos fi 206 1.1 christos rm -f f-bo-2-$n.po f-bo-2-$n.mo 207 1.1 christos done < f-bo-2.data 208 1.1 christos 209 1.1 christos rm -fr $tmpfiles 210 1.1 christos 211 1.1 christos exit 0 212