[Po4a-commits] po4a/lib/Locale/Po4a TeX.pm,1.4,1.5
Nicolas FRAN??OIS
po4a-devel@lists.alioth.debian.org
Sat, 08 Jan 2005 10:34:02 +0000
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv8437/lib/Locale/Po4a
Modified Files:
TeX.pm
Log Message:
Fix some issues:
* make sure commands extracted by get_(leading|trailing)_command are not null
* in get_trailing_command, make sure arguments (ending by a ']' or '}') have a matching '[' and '{'
* a % introduce a comment only if not preceded by a '\'
* don't test the last environment of @env if this array is empty
Index: TeX.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/TeX.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- TeX.pm 12 Dec 2004 19:54:25 -0000 1.4
+++ TeX.pm 8 Jan 2005 10:34:00 -0000 1.5
@@ -234,7 +234,7 @@
print STDERR "get_leading_command($buffer)="
if ($debug{'extract_commands'});
- if ($buffer =~ m/^\s*$RE_ESCAPE([[:alpha:]]*)(\*?)(.*)$/s) {
+ if ($buffer =~ m/^\s*$RE_ESCAPE([[:alpha:]]+)(\*?)(.*)$/s) {
# The buffer begin by a comand (possibly preceded by some
# whitespaces).
$command = $1;
@@ -320,7 +320,7 @@
# While the buffer ends by }, consider it is a mandatory argument
# and extract this argument.
- while ($buffer =~ m/^(.*)\}\s*$/s) {
+ while ($buffer =~ m/^(.*\{.*)\}\s*$/s) {
my $arg = "";
my $count = 1;
$buffer = $1;
@@ -351,7 +351,7 @@
# While the buffer ends by ], consider it is a mandatory argument
# and extract this argument.
- while ($buffer =~ m/^(.*)\]\s*$/s) {
+ while ($buffer =~ m/^(.*\[.*)\]\s*$/s) {
my $opt = "";
my $count = 1;
$buffer = $1;
@@ -381,7 +381,7 @@
}
# There should now be a command, maybe followed by an asterisk.
- if ($buffer =~ m/^(.*)$RE_ESCAPE([[:alpha:]]*)(\*?)\s*$/s) {
+ if ($buffer =~ m/^(.*)$RE_ESCAPE([[:alpha:]]+)(\*?)\s*$/s) {
$buffer = $1;
$command = $2;
$variant = $3;
@@ -501,7 +501,7 @@
$self->{ref}="$ref";
# remove comments, and store them in @comments
- if ($line =~ /^([^%]*)%(.*)$/) {
+ if ($line =~ /^([^%]*)(?<!\\)%(.*)$/) { # FIXME: even number of \ ...
push @comments, $2;
# Keep the % sign. It will be removed latter.
$line = "$1%";
@@ -510,7 +510,7 @@
if ($line =~ /^$/) {
# An empty line. This indicates the end of the current
# paragraph.
- $paragraph =~ s/%$//;
+ $paragraph =~ s/(?<!\\)%$//; # FIXME: even number of \ ...
if (length($paragraph)) {
($t, @env) = translate_buffer($self,$paragraph,@env);
$self->pushline($t."\n");
@@ -519,7 +519,7 @@
$self->pushline($line."\n");
} else {
# continue the same paragraph
- if ($paragraph =~ /%$/) {
+ if ($paragraph =~ /(?<!\\)%$/) { # FIXME: even number of \ ...
$paragraph =~ s/%$//s;
chomp $paragraph;
$line =~ s/^ *//;
@@ -623,7 +623,7 @@
if ($debug{'commands'} || $debug{'environments'});
# verify that this environment was the last pushed environment.
- if (@$env[-1] ne $args->[0]) {
+ if (!@$env || @$env[-1] ne $args->[0]) {
# a begin may have been hidden in the middle of a translated
# buffer. Just warn.
warn sprintf("po4a::TeX: unmatched end of environment '%s'",