Commit 83e7f160 authored by IKEDA Soji's avatar IKEDA Soji
Browse files

Fix injected bug that xgettext.pl couldn't work with Perl 5.26 or later.

parent 0906ef03
...@@ -247,7 +247,7 @@ sub add_expression { ...@@ -247,7 +247,7 @@ sub add_expression {
sub load_tt2 { sub load_tt2 {
my $filename = shift; my $filename = shift;
my $_ = shift; my $t = shift;
my $filters = shift; my $filters = shift;
# Initiliazing filter names with defaults if necessary. # Initiliazing filter names with defaults if necessary.
...@@ -275,9 +275,9 @@ sub load_tt2 { ...@@ -275,9 +275,9 @@ sub load_tt2 {
my $line; my $line;
$line = 1; $line = 1;
pos($_) = 0; pos($t) = 0;
while ( while (
m{ $t =~ m{
\G .*? \G .*?
(?: (?:
# Short style: [% "..." | loc(...) %] # Short style: [% "..." | loc(...) %]
...@@ -340,17 +340,17 @@ sub load_tt2 { ...@@ -340,17 +340,17 @@ sub load_tt2 {
sub load_perl { sub load_perl {
my $filename = shift; my $filename = shift;
my $_ = shift; my $t = shift;
my $line; my $line;
s{(?<=\n)__END__\n.*}{}s; # Omit postamble $t =~ s{(?<=\n)__END__\n.*}{}s; # Omit postamble
# Sympa variables (gettext_comment, gettext_id and gettext_unit) # Sympa variables (gettext_comment, gettext_id and gettext_unit)
$line = 1; $line = 1;
pos($_) = 0; pos($t) = 0;
while ( while (
m{ $t =~ m{
\G .*? \G .*?
([\"\']?) ([\"\']?)
(gettext_comment | gettext_id | gettext_unit) (gettext_comment | gettext_id | gettext_unit)
...@@ -380,14 +380,14 @@ sub load_perl { ...@@ -380,14 +380,14 @@ sub load_perl {
my $vars; my $vars;
my $type; my $type;
pos($_) = 0; pos($t) = 0;
my $orig = 1 + (() = ((my $__ = $_) =~ /\n/g)); my $orig = 1 + (() = ((my $tmp = $t) =~ /\n/g));
PARSER: { PARSER: {
$_ = substr $_, pos $_ if pos $_; $t = substr $t, pos $t if pos $t;
my $line = $orig - (() = ((my $__ = $_) =~ /\n/g)); my $line = $orig - (() = ((my $tmp = $t) =~ /\n/g));
# maketext or loc or _ # maketext or loc or _
if ($state == NUL if ( $state == NUL
and m/\b( and $t =~ m/\b(
translate translate
| gettext(?:_strftime|_sprintf)? | gettext(?:_strftime|_sprintf)?
| maketext | maketext
...@@ -408,89 +408,89 @@ PARSER: { ...@@ -408,89 +408,89 @@ PARSER: {
} }
redo; redo;
} }
if (($state == BEG or $state == BEGM) and m/^([\s\t\n]*)/cg) { if (($state == BEG or $state == BEGM) and $t =~ m/^([\s\t\n]*)/cg) {
redo; redo;
} }
# begin () # begin ()
if ($state == BEG and m/^([\S\(])/cg) { if ($state == BEG and $t =~ m/^([\S\(])/cg) {
$state = ($1 eq '(') ? PAR : NUL; $state = ($1 eq '(') ? PAR : NUL;
redo; redo;
} }
if ($state == BEGM and m/^([\(])/cg) { if ($state == BEGM and $t =~ m/^([\(])/cg) {
$state = PARM; $state = PARM;
redo; redo;
} }
# begin or end of string # begin or end of string
if ($state == PAR and m/^\s*(\')/cg) { if ($state == PAR and $t =~ m/^\s*(\')/cg) {
$state = QUO1; $state = QUO1;
redo; redo;
} }
if ($state == QUO1 and m/^([^\']+)/cg) { if ($state == QUO1 and $t =~ m/^([^\']+)/cg) {
$str .= $1; $str .= $1;
redo; redo;
} }
if ($state == QUO1 and m/^\'/cg) { if ($state == QUO1 and $t =~ m/^\'/cg) {
$state = PAR; $state = PAR;
redo; redo;
} }
if ($state == PAR and m/^\s*\"/cg) { if ($state == PAR and $t =~ m/^\s*\"/cg) {
$state = QUO2; $state = QUO2;
redo; redo;
} }
if ($state == QUO2 and m/^([^\"]+)/cg) { if ($state == QUO2 and $t =~ m/^([^\"]+)/cg) {
$str .= $1; $str .= $1;
redo; redo;
} }
if ($state == QUO2 and m/^\"/cg) { if ($state == QUO2 and $t =~ m/^\"/cg) {
$state = PAR; $state = PAR;
redo; redo;
} }
if ($state == PAR and m/^\s*\`/cg) { if ($state == PAR and $t =~ m/^\s*\`/cg) {
$state = QUO3; $state = QUO3;
redo; redo;
} }
if ($state == QUO3 and m/^([^\`]*)/cg) { if ($state == QUO3 and $t =~ m/^([^\`]*)/cg) {
$str .= $1; $str .= $1;
redo; redo;
} }
if ($state == QUO3 and m/^\`/cg) { if ($state == QUO3 and $t =~ m/^\`/cg) {
$state = PAR; $state = PAR;
redo; redo;
} }
if ($state == BEGM and m/^(\')/cg) { if ($state == BEGM and $t =~ m/^(\')/cg) {
$state = QUOM1; $state = QUOM1;
redo; redo;
} }
if ($state == PARM and m/^\s*(\')/cg) { if ($state == PARM and $t =~ m/^\s*(\')/cg) {
$state = QUOM1; $state = QUOM1;
redo; redo;
} }
if ($state == QUOM1 and m/^([^\']+)/cg) { if ($state == QUOM1 and $t =~ m/^([^\']+)/cg) {
$str .= $1; $str .= $1;
redo; redo;
} }
if ($state == QUOM1 and m/^\'/cg) { if ($state == QUOM1 and $t =~ m/^\'/cg) {
$state = COMM; $state = COMM;
redo; redo;
} }
if ($state == BEGM and m/^(\")/cg) { if ($state == BEGM and $t =~ m/^(\")/cg) {
$state = QUOM2; $state = QUOM2;
redo; redo;
} }
if ($state == PARM and m/^\s*(\")/cg) { if ($state == PARM and $t =~ m/^\s*(\")/cg) {
$state = QUOM2; $state = QUOM2;
redo; redo;
} }
if ($state == QUOM2 and m/^([^\"]+)/cg) { if ($state == QUOM2 and $t =~ m/^([^\"]+)/cg) {
$str .= $1; $str .= $1;
redo; redo;
} }
if ($state == QUOM2 and m/^\"/cg) { if ($state == QUOM2 and $t =~ m/^\"/cg) {
$state = COMM; $state = COMM;
redo; redo;
} }
...@@ -501,9 +501,9 @@ PARSER: { ...@@ -501,9 +501,9 @@ PARSER: {
} }
# end () # end ()
if ( ($state == PAR and m/^\s*[\)]/cg) if ( ($state == PAR and $t =~ m/^\s*[\)]/cg)
or ($state == PARM and m/^\s*[\)]/cg) or ($state == PARM and $t =~ m/^\s*[\)]/cg)
or ($state == COMM and m/^\s*,/cg)) { or ($state == COMM and $t =~ m/^\s*,/cg)) {
$state = NUL; $state = NUL;
$vars =~ s/[\n\r]//g if $vars; $vars =~ s/[\n\r]//g if $vars;
...@@ -521,18 +521,18 @@ PARSER: { ...@@ -521,18 +521,18 @@ PARSER: {
} }
# a line of vars # a line of vars
if ($state == PAR and m/^([^\)]*)/cg) { if ($state == PAR and $t =~ m/^([^\)]*)/cg) {
$vars .= $1 . "\n"; $vars .= $1 . "\n";
redo; redo;
} }
if ($state == PARM and m/^([^\)]*)/cg) { if ($state == PARM and $t =~ m/^([^\)]*)/cg) {
$vars .= $1 . "\n"; $vars .= $1 . "\n";
redo; redo;
} }
} }
unless ($state == NUL) { unless ($state == NUL) {
my $post = $_; my $post = $t;
$post =~ s/\A(\s*.*\n.*\n.*)\n(.|\n)+\z/$1\n.../; $post =~ s/\A(\s*.*\n.*\n.*)\n(.|\n)+\z/$1\n.../;
warn sprintf "Warning: incomplete state just before ---\n%s\n", $post; warn sprintf "Warning: incomplete state just before ---\n%s\n", $post;
} }
...@@ -540,15 +540,15 @@ PARSER: { ...@@ -540,15 +540,15 @@ PARSER: {
sub load_title { sub load_title {
my $filename = shift; my $filename = shift;
my $_ = shift; my $t = shift;
my $line; my $line;
# Titles in scenarios, tasks and comment.tt2 (title.gettext) # Titles in scenarios, tasks and comment.tt2 (title.gettext)
$line = 1; $line = 1;
pos($_) = 0; pos($t) = 0;
while ( while (
m{ $t =~ m{
\G .*? \G .*?
title [.] gettext \s* title [.] gettext \s*
([^\n]+) ([^\n]+)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment