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.pot" 70: ${XGETTEXT=xgettext} 71LC_MESSAGES=C LC_ALL= \ 72${XGETTEXT} --omit-header --no-location -o xg-pl-6.pot xg-pl-6.pl 73test $? = 0 || { rm -fr $tmpfiles; exit 1; } 74 75tmpfiles="$tmpfiles xg-pl-6.ok" 76cat <<\EOF > xg-pl-6.ok 77msgid "extracted1" 78msgstr "" 79 80msgid "extracted2" 81msgstr "" 82 83msgid "extracted3" 84msgstr "" 85 86msgid "extracted4" 87msgstr "" 88 89msgid "extracted5" 90msgstr "" 91 92msgid "extracted6" 93msgstr "" 94 95msgid "extracted7" 96msgstr "" 97 98msgid "extracted8" 99msgstr "" 100 101msgid "extracted9" 102msgstr "" 103 104msgid "extracted10" 105msgstr "" 106 107msgid "extracted11" 108msgstr "" 109 110msgid "extracted12" 111msgstr "" 112 113msgid "extracted13" 114msgstr "" 115 116msgid "extracted14" 117msgstr "" 118 119msgid "extracted15" 120msgstr "" 121 122msgid "extracted16" 123msgstr "" 124EOF 125 126: ${DIFF=diff} 127${DIFF} xg-pl-6.ok xg-pl-6.pot 128result=$? 129 130rm -fr $tmpfiles 131 132exit $result 133