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