1#! /bin/sh 2 3# Test recognition of Perl format strings of both kinds (printf and brace). 4# This test is for the combination of both kinds. 5 6tmpfiles="" 7trap 'rm -fr $tmpfiles' 1 2 3 15 8 9tmpfiles="$tmpfiles f-pm-1.data" 10 11cat <<\EOF > f-pm-1.data 12# Both formats. 13#, perl-format, perl-brace-format 14"{foo} %c {bar} %d {baz}" 15# printf format only. 16#, perl-format 17"%c %d" 18# printf format only, because '%' is not allowed in identifier. 19#, perl-format 20"{foo%cbar}" 21# Valid bracketed format because there is still one valid identifier. 22#, perl-format, perl-brace-format 23"{foo%cbar} {baz}" 24# Bracketed format only, because %l is not recognized in printf format. 25#, perl-brace-format 26"{foo} %l {bar}" 27# Neither format recognized here. 28 29"{foo bar %l" 30EOF 31 32: ${XGETTEXT=xgettext} 33n=0 34while read comment; do 35 read formats 36 read string 37 n=`expr $n + 1` 38 tmpfiles="$tmpfiles f-pm-1-$n.in f-pm-1-$n.po" 39 cat <<EOF > f-pm-1-$n.in 40gettext(${string}); 41EOF 42 ${XGETTEXT} -L perl --omit-header --no-location -o f-pm-1-$n.po f-pm-1-$n.in || exit 1 43 test -f f-pm-1-$n.po || exit 1 44 fail= 45 if test -n "${formats}"; then 46 # Verify that the first line contains the expected #, comment. 47 if sed 1q < f-pm-1-$n.po | tr -d '\r' | grep '^'"${formats}"'$' > /dev/null; then 48 : 49 else 50 fail=yes 51 fi 52 else 53 # Verify that there is no #, comment. 54 if sed 1q < f-pm-1-$n.po | grep '^msgid' > /dev/null; then 55 : 56 else 57 fail=yes 58 fi 59 fi 60 if test -n "$fail"; then 61 echo "Format string recognition error:" 1>&2 62 cat f-pm-1-$n.in 1>&2 63 echo "Got:" 1>&2 64 cat f-pm-1-$n.po 1>&2 65 exit 1 66 fi 67done < f-pm-1.data 68 69rm -fr $tmpfiles 70 71exit 0 72