1 1.1 christos #! /bin/sh 2 1.1 christos 3 1.1 christos # Test checking of Emacs Lisp 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-el-2.data" 9 1.1 christos cat <<\EOF > f-el-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%xdef" 18 1.1 christos msgstr "xyz%s%x" 19 1.1 christos # Valid: same arguments, with different widths 20 1.1 christos msgid "abc%2sdef" 21 1.1 christos msgstr "xyz%3s" 22 1.1 christos # Valid: same arguments but in numbered syntax 23 1.1 christos msgid "abc%s%xdef" 24 1.1 christos msgstr "xyz%1$s%2$x" 25 1.1 christos # Valid: permutation 26 1.1 christos msgid "abc%s%x%cdef" 27 1.1 christos msgstr "xyz%3$c%2$x%1$s" 28 1.1 christos # Invalid: too few arguments 29 1.1 christos msgid "abc%2$xdef%1$s" 30 1.1 christos msgstr "xyz%1$s" 31 1.1 christos # Invalid: too few arguments 32 1.1 christos msgid "abc%sdef%x" 33 1.1 christos msgstr "xyz%s" 34 1.1 christos # Invalid: too many arguments 35 1.1 christos msgid "abc%xdef" 36 1.1 christos msgstr "xyz%xvw%c" 37 1.1 christos # Valid: same numbered arguments, with different widths 38 1.1 christos msgid "abc%2$5s%1$4s" 39 1.1 christos msgstr "xyz%2$4s%1$5s" 40 1.1 christos # Invalid: missing argument 41 1.1 christos msgid "abc%2$sdef%1$x" 42 1.1 christos msgstr "xyz%1$x" 43 1.1 christos # Invalid: missing argument 44 1.1 christos msgid "abc%1$sdef%2$x" 45 1.1 christos msgstr "xyz%2$x" 46 1.1 christos # Invalid: added argument 47 1.1 christos msgid "abc%1$xdef" 48 1.1 christos msgstr "xyz%1$xvw%2$c" 49 1.1 christos # Valid: type compatibility 50 1.1 christos msgid "abc%d" 51 1.1 christos msgstr "xyz%i" 52 1.1 christos # Valid: type compatibility 53 1.1 christos msgid "abc%d" 54 1.1 christos msgstr "xyz%x" 55 1.1 christos # Valid: type compatibility 56 1.1 christos msgid "abc%d" 57 1.1 christos msgstr "xyz%X" 58 1.1 christos # Valid: type compatibility 59 1.1 christos msgid "abc%d" 60 1.1 christos msgstr "xyz%o" 61 1.1 christos # Valid: type compatibility 62 1.1 christos msgid "abc%x" 63 1.1 christos msgstr "xyz%X" 64 1.1 christos # Valid: type compatibility 65 1.1 christos msgid "abc%x" 66 1.1 christos msgstr "xyz%o" 67 1.1 christos # Valid: type compatibility 68 1.1 christos msgid "abc%X" 69 1.1 christos msgstr "xyz%o" 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%d" 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%x" 91 1.1 christos # Invalid: type incompatibility 92 1.1 christos msgid "abc%c" 93 1.1 christos msgstr "xyz%X" 94 1.1 christos # Invalid: type incompatibility 95 1.1 christos msgid "abc%c" 96 1.1 christos msgstr "xyz%o" 97 1.1 christos # Invalid: type incompatibility 98 1.1 christos msgid "abc%c" 99 1.1 christos msgstr "xyz%e" 100 1.1 christos # Invalid: type incompatibility 101 1.1 christos msgid "abc%c" 102 1.1 christos msgstr "xyz%E" 103 1.1 christos # Invalid: type incompatibility 104 1.1 christos msgid "abc%c" 105 1.1 christos msgstr "xyz%f" 106 1.1 christos # Invalid: type incompatibility 107 1.1 christos msgid "abc%c" 108 1.1 christos msgstr "xyz%g" 109 1.1 christos # Invalid: type incompatibility 110 1.1 christos msgid "abc%c" 111 1.1 christos msgstr "xyz%G" 112 1.1 christos # Invalid: type incompatibility 113 1.1 christos msgid "abc%c" 114 1.1 christos msgstr "xyz%s" 115 1.1 christos # Invalid: type incompatibility 116 1.1 christos msgid "abc%c" 117 1.1 christos msgstr "xyz%S" 118 1.1 christos # Invalid: type incompatibility 119 1.1 christos msgid "abc%d" 120 1.1 christos msgstr "xyz%e" 121 1.1 christos # Invalid: type incompatibility 122 1.1 christos msgid "abc%d" 123 1.1 christos msgstr "xyz%E" 124 1.1 christos # Invalid: type incompatibility 125 1.1 christos msgid "abc%d" 126 1.1 christos msgstr "xyz%f" 127 1.1 christos # Invalid: type incompatibility 128 1.1 christos msgid "abc%d" 129 1.1 christos msgstr "xyz%g" 130 1.1 christos # Invalid: type incompatibility 131 1.1 christos msgid "abc%d" 132 1.1 christos msgstr "xyz%G" 133 1.1 christos # Invalid: type incompatibility 134 1.1 christos msgid "abc%d" 135 1.1 christos msgstr "xyz%s" 136 1.1 christos # Invalid: type incompatibility 137 1.1 christos msgid "abc%d" 138 1.1 christos msgstr "xyz%S" 139 1.1 christos # Invalid: type incompatibility 140 1.1 christos msgid "abc%i" 141 1.1 christos msgstr "xyz%e" 142 1.1 christos # Invalid: type incompatibility 143 1.1 christos msgid "abc%i" 144 1.1 christos msgstr "xyz%E" 145 1.1 christos # Invalid: type incompatibility 146 1.1 christos msgid "abc%i" 147 1.1 christos msgstr "xyz%f" 148 1.1 christos # Invalid: type incompatibility 149 1.1 christos msgid "abc%i" 150 1.1 christos msgstr "xyz%g" 151 1.1 christos # Invalid: type incompatibility 152 1.1 christos msgid "abc%i" 153 1.1 christos msgstr "xyz%G" 154 1.1 christos # Invalid: type incompatibility 155 1.1 christos msgid "abc%i" 156 1.1 christos msgstr "xyz%s" 157 1.1 christos # Invalid: type incompatibility 158 1.1 christos msgid "abc%i" 159 1.1 christos msgstr "xyz%S" 160 1.1 christos # Invalid: type incompatibility 161 1.1 christos msgid "abc%x" 162 1.1 christos msgstr "xyz%e" 163 1.1 christos # Invalid: type incompatibility 164 1.1 christos msgid "abc%x" 165 1.1 christos msgstr "xyz%E" 166 1.1 christos # Invalid: type incompatibility 167 1.1 christos msgid "abc%x" 168 1.1 christos msgstr "xyz%f" 169 1.1 christos # Invalid: type incompatibility 170 1.1 christos msgid "abc%x" 171 1.1 christos msgstr "xyz%g" 172 1.1 christos # Invalid: type incompatibility 173 1.1 christos msgid "abc%x" 174 1.1 christos msgstr "xyz%G" 175 1.1 christos # Invalid: type incompatibility 176 1.1 christos msgid "abc%x" 177 1.1 christos msgstr "xyz%s" 178 1.1 christos # Invalid: type incompatibility 179 1.1 christos msgid "abc%x" 180 1.1 christos msgstr "xyz%S" 181 1.1 christos # Invalid: type incompatibility 182 1.1 christos msgid "abc%X" 183 1.1 christos msgstr "xyz%e" 184 1.1 christos # Invalid: type incompatibility 185 1.1 christos msgid "abc%X" 186 1.1 christos msgstr "xyz%E" 187 1.1 christos # Invalid: type incompatibility 188 1.1 christos msgid "abc%X" 189 1.1 christos msgstr "xyz%f" 190 1.1 christos # Invalid: type incompatibility 191 1.1 christos msgid "abc%X" 192 1.1 christos msgstr "xyz%g" 193 1.1 christos # Invalid: type incompatibility 194 1.1 christos msgid "abc%X" 195 1.1 christos msgstr "xyz%G" 196 1.1 christos # Invalid: type incompatibility 197 1.1 christos msgid "abc%X" 198 1.1 christos msgstr "xyz%s" 199 1.1 christos # Invalid: type incompatibility 200 1.1 christos msgid "abc%X" 201 1.1 christos msgstr "xyz%S" 202 1.1 christos # Invalid: type incompatibility 203 1.1 christos msgid "abc%o" 204 1.1 christos msgstr "xyz%e" 205 1.1 christos # Invalid: type incompatibility 206 1.1 christos msgid "abc%o" 207 1.1 christos msgstr "xyz%E" 208 1.1 christos # Invalid: type incompatibility 209 1.1 christos msgid "abc%o" 210 1.1 christos msgstr "xyz%f" 211 1.1 christos # Invalid: type incompatibility 212 1.1 christos msgid "abc%o" 213 1.1 christos msgstr "xyz%g" 214 1.1 christos # Invalid: type incompatibility 215 1.1 christos msgid "abc%o" 216 1.1 christos msgstr "xyz%G" 217 1.1 christos # Invalid: type incompatibility 218 1.1 christos msgid "abc%o" 219 1.1 christos msgstr "xyz%s" 220 1.1 christos # Invalid: type incompatibility 221 1.1 christos msgid "abc%o" 222 1.1 christos msgstr "xyz%S" 223 1.1 christos # Invalid: type incompatibility 224 1.1 christos msgid "abc%e" 225 1.1 christos msgstr "xyz%s" 226 1.1 christos # Invalid: type incompatibility 227 1.1 christos msgid "abc%e" 228 1.1 christos msgstr "xyz%S" 229 1.1 christos # Invalid: type incompatibility 230 1.1 christos msgid "abc%E" 231 1.1 christos msgstr "xyz%s" 232 1.1 christos # Invalid: type incompatibility 233 1.1 christos msgid "abc%E" 234 1.1 christos msgstr "xyz%S" 235 1.1 christos # Invalid: type incompatibility 236 1.1 christos msgid "abc%f" 237 1.1 christos msgstr "xyz%s" 238 1.1 christos # Invalid: type incompatibility 239 1.1 christos msgid "abc%f" 240 1.1 christos msgstr "xyz%S" 241 1.1 christos # Invalid: type incompatibility 242 1.1 christos msgid "abc%g" 243 1.1 christos msgstr "xyz%s" 244 1.1 christos # Invalid: type incompatibility 245 1.1 christos msgid "abc%g" 246 1.1 christos msgstr "xyz%S" 247 1.1 christos # Invalid: type incompatibility 248 1.1 christos msgid "abc%G" 249 1.1 christos msgstr "xyz%s" 250 1.1 christos # Invalid: type incompatibility 251 1.1 christos msgid "abc%G" 252 1.1 christos msgstr "xyz%S" 253 1.1 christos # Invalid: type incompatibility 254 1.1 christos msgid "abc%s" 255 1.1 christos msgstr "xyz%S" 256 1.1 christos EOF 257 1.1 christos 258 1.1 christos : ${MSGFMT=msgfmt} 259 1.1 christos n=0 260 1.1 christos while read comment; do 261 1.1 christos read msgid_line 262 1.1 christos read msgstr_line 263 1.1 christos n=`expr $n + 1` 264 1.1 christos tmpfiles="$tmpfiles f-el-2-$n.po f-el-2-$n.mo" 265 1.1 christos cat <<EOF > f-el-2-$n.po 266 1.1 christos #, elisp-format 267 1.1 christos ${msgid_line} 268 1.1 christos ${msgstr_line} 269 1.1 christos EOF 270 1.1 christos fail= 271 1.1 christos if echo "$comment" | grep 'Valid:' > /dev/null; then 272 1.1 christos if ${MSGFMT} --check-format -o f-el-2-$n.mo f-el-2-$n.po; then 273 1.1 christos : 274 1.1 christos else 275 1.1 christos fail=yes 276 1.1 christos fi 277 1.1 christos else 278 1.1 christos ${MSGFMT} --check-format -o f-el-2-$n.mo f-el-2-$n.po 2> /dev/null 279 1.1 christos if test $? = 1; then 280 1.1 christos : 281 1.1 christos else 282 1.1 christos fail=yes 283 1.1 christos fi 284 1.1 christos fi 285 1.1 christos if test -n "$fail"; then 286 1.1 christos echo "Format string checking error:" 1>&2 287 1.1 christos cat f-el-2-$n.po 1>&2 288 1.1 christos exit 1 289 1.1 christos fi 290 1.1 christos rm -f f-el-2-$n.po f-el-2-$n.mo 291 1.1 christos done < f-el-2.data 292 1.1 christos 293 1.1 christos rm -fr $tmpfiles 294 1.1 christos 295 1.1 christos exit 0 296