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