1#! /bin/sh 2. "${srcdir=.}/init.sh"; path_prepend_ . ../src 3 4# Test checking of Lisp format strings. 5 6cat <<\EOF > f-sc-2.data 7# Valid: ~~ doesn't count 8msgid "abc~~def" 9msgstr "xyz" 10# Invalid: invalid msgstr 11msgid "abc~~def" 12msgstr "xyz~" 13# Valid: ~! doesn't count 14msgid "abc~!def" 15msgstr "xyz" 16# Valid: ~Q doesn't count 17msgid "abc~Qdef" 18msgstr "xyz" 19# Valid: same argument 20msgid "abc~Ddef" 21msgstr "xyz~D" 22# Valid: same arguments 23msgid "abc~1000000@*~Ddef" 24msgstr "~1000000@*xyz~D" 25# Valid: permutation 26msgid "abc~D~C~Fdef" 27msgstr "xyz~2@*~F~2:*~C~2:*~D" 28# Invalid: too few arguments 29msgid "abc~1@*~Sdef~0@*~S" 30msgstr "xyz~S" 31# Invalid: too many arguments 32msgid "abc~Ddef" 33msgstr "xyz~Duvw~C" 34# Invalid: missing non-final argument 35msgid "abc~1@*~Sdef~0@*~F" 36msgstr "xyz~1@*~S" 37# Invalid: added non-final argument 38msgid "abc~1@*~Ddef" 39msgstr "xyz~F~D" 40# Valid: formatting variations 41msgid "abc~Sdef" 42msgstr "xyz~:S" 43# Valid: formatting variations 44msgid "abc~4Sdef" 45msgstr "xyz~7S" 46# Valid: type compatibility 47msgid "abc~Sdef" 48msgstr "xyz~Y" 49# Valid: type compatibility 50msgid "abc~Ddef" 51msgstr "xyz~B" 52# Valid: type compatibility 53msgid "abc~Ddef" 54msgstr "xyz~O" 55# Valid: type compatibility 56msgid "abc~Ddef" 57msgstr "xyz~X" 58# Valid: type compatibility 59msgid "abc~Ddef" 60msgstr "xyz~R" 61# Valid: optional plural 62msgid "~D egg~:P" 63msgstr "~D Eier" 64# Valid: type compatibility 65msgid "abc~Fdef" 66msgstr "xyz~E" 67# Valid: type compatibility 68msgid "abc~Fdef" 69msgstr "xyz~G" 70# Valid: type compatibility 71msgid "abc~Fdef" 72msgstr "xyz~$" 73# Invalid: type incompatibility 74msgid "abc~Fdef" 75msgstr "xyz~D" 76# Invalid: type incompatibility 77msgid "abc~Ddef" 78msgstr "xyz~C" 79# Invalid: type incompatibility 80msgid "abc~Fdef" 81msgstr "xyz~C" 82# Invalid: type incompatibility 83msgid "abc~Sdef" 84msgstr "xyz~D" 85# Invalid: type incompatibility 86msgid "abc~Sdef" 87msgstr "xyz~F" 88# Invalid: type incompatibility 89msgid "abc~Sdef" 90msgstr "xyz~C" 91# Invalid: type incompatibility 92msgid "abc~Fdef" 93msgstr "xyz~I" 94# Invalid: type incompatibility 95msgid "abc~Ddef" 96msgstr "xyz~I" 97# Invalid: type incompatibility 98msgid "abc~Sdef" 99msgstr "xyz~I" 100# Invalid: type incompatibility 101msgid "abc~Cdef" 102msgstr "xyz~I" 103# Valid: extra formatting 104msgid "abc~Ddef~S" 105msgstr "xyz~D~_d~/ef~%~S" 106# Valid: extra force-output 107msgid "abc~Ddef~S" 108msgstr "xyz~Ddef~S~!" 109# Valid: FORMAT-GOTO doesn't consume an argument by itself 110msgid "abc~5@*~Ddef~C" 111msgstr "xyz~6@*~C~2@*uvw~5@*~R" 112# Valid: ~? and ~K are equivalent 113msgid "abc~?" 114msgstr "xyz~K" 115# Invalid: @ matters 116msgid "abc~?" 117msgstr "xyz~@?" 118# Valid: case conversion is optional 119msgid "abc~(~S~)" 120msgstr "xyz~S" 121# Valid: case conversion is optional 122msgid "abc~(~D~^ ~D~)" 123msgstr "xyz~D~^ ~D" 124# Invalid: ~^ matters 125msgid "abc~(~D~^ ~D~)" 126msgstr "xyz~(~D ~D~)" 127# Valid: case conversion is optional, and it doesn't catch ~^ 128msgid "abc~(~D~^ ~D~)def~C" 129msgstr "xyz~D~^ ~Duvw~C" 130# Valid: synonymous conditionals 131msgid "abc~@[~D~]def~C" 132msgstr "xyz~:[~;~:*~D~]~C" 133# Valid: synonymous conditionals 134msgid "abc~Ddef" 135msgstr "abc~[null~;eins~:;~:*~D~]def" 136# Valid: conditionals are optional and don't catch ~^ 137msgid "abc~:[~;~]~^~D~C" 138msgstr "xyz~:[uvw~^~R~;~:*~S~^~D~]~C" 139# Invalid: ~:[ requires an argument, ~1@* doesn't 140msgid "abc~1@*~^~D~C" 141msgstr "xyz~:[uvw~^~R~;~:*~S~^~D~]~C" 142# Invalid: ~{~} is special 143msgid "abc~{ ~}" 144msgstr "xyz~{~}" 145# Invalid: @ matters 146msgid "abc~{~S~}" 147msgstr "xyz~@{~S~}" 148# Invalid: @ matters 149msgid "abc~:{~S~}" 150msgstr "xyz~@:{~S~}" 151# Invalid: : matters 152msgid "abc~{~S~}" 153msgstr "xyz~:{~S~}" 154# Invalid: : matters 155msgid "abc~@{~S~}" 156msgstr "xyz~@:{~S~}" 157# Invalid: @: matters 158msgid "abc~{~S~}" 159msgstr "xyz~@:{~S~}" 160# Valid: permutation inside iteration 161msgid "abc~{~D ~C~}" 162msgstr "xyz~{~1@*~C~2:*~D~1*~}" 163# Invalid: permutation inside iteration, but wrong position at iteration end 164msgid "abc~{~D ~C~}" 165msgstr "xyz~{~1@*~C~2:*~D~}" 166# Invalid: ~^ inside iteration matters 167msgid "abc~{~D ~^~C~}" 168msgstr "xyz~{~D ~C~}" 169# Invalid: ~^ inside iteration depends on position 170msgid "abc~{~D ~^~C~}" 171msgstr "xyz~{~1@*~C~^~2:*~D~1*~}" 172# Invalid: ~^ inside iteration depends on position 173msgid "abc~{~D ~^~C~}" 174msgstr "xyz~{~1@*~C~2:*~^~D~1*~}" 175# Invalid: ~^ inside iteration depends on position 176msgid "abc~{~D ~^~C~}" 177msgstr "xyz~{~1@*~C~2:*~D~^~1*~}" 178# Invalid: ~^ inside iteration depends on position 179msgid "abc~{~D ~^~C~}" 180msgstr "xyz~{~1@*~C~2:*~D~1*~^~}" 181# Invalid: type compatibility with non-strict checking 182msgid "abc~{~c~c~}" 183msgid_plural "abc~{~c~c~}" 184msgstr[0] "xyz~{~c~d~}" 185msgstr[1] "xyz~{~c~d~}" 186EOF 187 188: ${MSGFMT=msgfmt} 189n=0 190while read comment; do 191 read msgid_line 192 read msgstr_line 193 msgid_plural_line="" 194 if echo "$msgstr_line" | grep '^msgid_plural' > /dev/null; then 195 msgid_plural_line="$msgstr_line" 196 read msgstr0_line 197 read msgstr1_line 198 fi 199 n=`expr $n + 1` 200 if test -z "$msgid_plural_line"; then 201 cat <<EOF > f-sc-2-$n.po 202#, scheme-format 203${msgid_line} 204${msgstr_line} 205EOF 206 else 207 cat <<EOF > f-l-2-$n.po 208#, lisp-format 209${msgid_line} 210${msgid_plural_line} 211${msgstr0_line} 212${msgstr1_line} 213EOF 214 fi 215 fail= 216 if echo "$comment" | grep 'Valid:' > /dev/null; then 217 if ${MSGFMT} --check-format -o f-sc-2-$n.mo f-sc-2-$n.po; then 218 : 219 else 220 fail=yes 221 fi 222 else 223 ${MSGFMT} --check-format -o f-sc-2-$n.mo f-sc-2-$n.po 2> /dev/null 224 if test $? = 1; then 225 : 226 else 227 fail=yes 228 fi 229 fi 230 if test -n "$fail"; then 231 echo "Format string checking error:" 1>&2 232 cat f-sc-2-$n.po 1>&2 233 Exit 1 234 fi 235 rm -f f-sc-2-$n.po f-sc-2-$n.mo 236done < f-sc-2.data 237 238Exit 0 239