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