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