1#! /bin/sh 2 3# Test whether the right number of arguments are extracted. 4 5tmpfiles="" 6trap 'rm -fr $tmpfiles' 1 2 3 15 7 8tmpfiles="$tmpfiles xg-pl-6.pl" 9cat <<\EOPERL > xg-pl-6.pl 10use strict; 11 12# For 'gettext', xgettext needs to extract the first argument. 13 14# Don't extract further strings (second argument to gettext or unrelated 15# expressions). 16print gettext "extracted1", "$shouldnotbeextracted"; 17print gettext ("extracted2"), "$shouldnotbeextracted"; 18print gettext ("extracted3")."$notextracted", "$shouldnotbeextracted"; 19print (gettext ("extracted4")), "$shouldnotbeextracted"; 20 21# Likewise, inside a call to an arbitrary 'foobar' function. 22print foobar gettext "extracted5", "$shouldnotbeextracted"; 23print foobar gettext ("extracted6"), "$shouldnotbeextracted"; 24print foobar gettext ("extracted7")."$notextracted", "$shouldnotbeextracted"; 25print foobar (gettext ("extracted8")), "$shouldnotbeextracted"; 26print foobar (gettext "extracted9", "$shouldnotbeextracted"); 27print foobar (gettext ("extracted10"), "$shouldnotbeextracted"); 28print foobar (gettext ("extracted11")."$notextracted", "$shouldnotbeextracted"); 29 30# Don't extract strings that are inside a function call to an arbitrary 31# 'foobar' function, and don't extract a second argument to gettext 32print gettext foobar "$notextracted", "$shouldnotbeextracted"; 33print gettext foobar ("$notextracted"), "$shouldnotbeextracted"; 34print gettext foobar ("$notextracted")."$notextracted", "$shouldnotbeextracted"; 35print (gettext foobar ("$notextracted")), "$shouldnotbeextracted"; 36print gettext (foobar "$notextracted"), "$shouldnotbeextracted"; 37print gettext (foobar ("$notextracted")), "$shouldnotbeextracted"; 38print gettext (foobar ("$notextracted"))."$notextracted", "$shouldnotbeextracted"; 39print gettext (foobar ("$notextracted")."$notextracted"), "$shouldnotbeextracted"; 40print (gettext (foobar ("$notextracted"))), "$shouldnotbeextracted"; 41 42# For 'dgettext', xgettext needs to extract the second argument. 43 44# The first argument should not be extracted. 45print dgettext "$shouldnotbeextracted", "extracted12"; 46 47# For a built-in unary function with parentheses, it's clear where dgettext's 48# first argument ends. 49print dgettext sin (17), "extracted13"; 50 51# For a built-in unary function, it's clear where dgettext's first argument 52# ends. 53print dgettext sin 17, "extracted14"; 54 55# For a function call with parentheses, it's clear where dgettext's first 56# argument ends. 57print dgettext foo (17), "extracted15"; 58 59# This one is hairy. If foo is a function with a prototype and one argument, 60# this parses like 61# print dgettext (foo (17), "extracted16"); 62# otherwise it parses like 63# print dgettext (foo (17, "extracted16")); 64# But in the latter case dgettext has no second argument at all; this is 65# therefore not the interpretation intended by the programmer. 66print dgettext foo 17, "extracted16"; 67EOPERL 68 69tmpfiles="$tmpfiles xg-pl-6.tmp xg-pl-6.pot" 70: ${XGETTEXT=xgettext} 71LC_MESSAGES=C LC_ALL= \ 72${XGETTEXT} --omit-header --no-location -o xg-pl-6.tmp xg-pl-6.pl 73test $? = 0 || { rm -fr $tmpfiles; exit 1; } 74tr -d '\r' < xg-pl-6.tmp > xg-pl-6.pot 75test $? = 0 || { rm -fr $tmpfiles; exit 1; } 76 77tmpfiles="$tmpfiles xg-pl-6.ok" 78cat <<\EOF > xg-pl-6.ok 79msgid "extracted1" 80msgstr "" 81 82msgid "extracted2" 83msgstr "" 84 85msgid "extracted3" 86msgstr "" 87 88msgid "extracted4" 89msgstr "" 90 91msgid "extracted5" 92msgstr "" 93 94msgid "extracted6" 95msgstr "" 96 97msgid "extracted7" 98msgstr "" 99 100msgid "extracted8" 101msgstr "" 102 103msgid "extracted9" 104msgstr "" 105 106msgid "extracted10" 107msgstr "" 108 109msgid "extracted11" 110msgstr "" 111 112msgid "extracted12" 113msgstr "" 114 115msgid "extracted13" 116msgstr "" 117 118msgid "extracted14" 119msgstr "" 120 121msgid "extracted15" 122msgstr "" 123 124msgid "extracted16" 125msgstr "" 126EOF 127 128: ${DIFF=diff} 129${DIFF} xg-pl-6.ok xg-pl-6.pot 130result=$? 131 132rm -fr $tmpfiles 133 134exit $result 135