1#! /bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Tests for the general string extraction facilities of the Perl backend
5# (with option --extract-all).
6
7cat <<\EOPERL > xg-pl-4.pl
8use strict;
9
10# A double quoted string.
11print "'Your command, please?', asked the waiter.\n";
12# A double quoted string with interpolations.
13my $polite = 'please';
14print "'Your recommendation, $polite?', answered the guest.\n";
15# A reference.
16my $ref1 = \$polite;
17my $ref2 = \$ref1;
18my $ref3 = \$ref2;
19print "Yes, $$$$ref3!\n";
20# The qq operator and some of the more esoteric string interpolation
21# features of Perl.
22print (qq {\uU\lp \LaNd\E \ldo\lWn, \Uoh\E, yeah\Q!!!\E\\!\n});
23# The q operator.
24print q<E-Mail: <no@spam.org>.  >;
25# Should not be found.
26{ $polite =~ qr?le? }
27
28# List interpolation.
29print "Your Perl include path starts with '$INC[0]' and it " .
30      "ends with '$INC[-1]'.  $#INC directories are searched.\n";
31# Here documents.
32print <<EOF, <<'EOF';
33Line 1\nLine 2
34EOF
35Line 1\nStill line 1
36EOF
37# Perl code inside strings.
38sub hello_func { return 'Hello' };
39print "@{[hello_func]} world!\n";
40# Backticks.
41print `ls $0`;
42print qx;ls $0;;
43
44if (!defined($size = -s $filename)) {
45  # The above s is part of the function -s, not
46  # the substitution operator!
47}
48
49# The rest requires a Unicode aware Perl.
50require 5.006;
51print "\U\x70\LO\154\x{69}\x{004E}a \Q\lRu\LLeS\E\041\n";
52# FIXME: The following should actually produce 'Polina4ka' in cyrillic letters.
53#print "\u\x{43f}\L\x{41E}\x{43b}\x{418}\E\x{43d}" .
54#      "\x{430}\x{447}\x{43a}\x{430}\n";
55EOPERL
56
57: ${XGETTEXT=xgettext}
58LC_MESSAGES=C LC_ALL= \
59${XGETTEXT} -a --omit-header --no-location -o xg-pl-4.tmp.pot xg-pl-4.pl || Exit 1
60LC_ALL=C tr -d '\r' < xg-pl-4.tmp.pot > xg-pl-4.pot || Exit 1
61
62cat <<\EOF > xg-pl-4.ok
63msgid "'Your command, please?', asked the waiter.\n"
64msgstr ""
65
66msgid "please"
67msgstr ""
68
69msgid "'Your recommendation, $polite?', answered the guest.\n"
70msgstr ""
71
72msgid "Yes, $$$$ref3!\n"
73msgstr ""
74
75msgid "Up and down, OH, yeah\\!\\!\\!\\!\n"
76msgstr ""
77
78msgid "E-Mail: <no@spam.org>.  "
79msgstr ""
80
81msgid ""
82"Your Perl include path starts with '$INC[0]' and it ends with '$INC[-1]'.  "
83"$#INC directories are searched.\n"
84msgstr ""
85
86msgid ""
87"Line 1\n"
88"Line 2\n"
89msgstr ""
90
91msgid "Line 1\\nStill line 1\n"
92msgstr ""
93
94msgid "Hello"
95msgstr ""
96
97msgid "@{[hello_func]} world!\n"
98msgstr ""
99
100msgid "ls $0"
101msgstr ""
102
103msgid "Polina rules!\n"
104msgstr ""
105EOF
106
107: ${DIFF=diff}
108${DIFF} xg-pl-4.ok xg-pl-4.pot
109result=$?
110
111exit $result
112