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