[Po4a-commits] "po4a/lib/Locale/Po4a TeX.pm,1.71,1.72"

Nicolas FRANCOIS nekral-guest at alioth.debian.org
Wed Sep 21 19:48:04 UTC 2005


Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv14636/lib/Locale/Po4a

Modified Files:
	TeX.pm 
Log Message:
Implements the +command and -command syntaxes.


Index: TeX.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/TeX.pm,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- TeX.pm	21 Sep 2005 19:44:17 -0000	1.71
+++ TeX.pm	21 Sep 2005 19:48:01 -0000	1.72
@@ -703,8 +703,20 @@
 #            $buffer = $2; # FIXME: this also remove trailing spaces!!
             $buffer =~ s/^\s*//;
         }
+        my $buffer_save = $buffer;
         ($command, $variant, $args, $buffer) =
             get_leading_command($self,$buffer);
+        if (    (length $command)
+            and (defined $separated_command{$command})
+            and ($separated_command{$command} eq '-')
+            and (   (not (defined($buffer)))
+                 or ($buffer !~ m/^\s*$/s)  )) {
+            # This command can be separated only if alone on a buffer.
+            # We need to remove the trailing commands first, and see if it
+            # will be alone on this buffer.
+            $buffer = $buffer_save;
+            $command = "";
+        }
         if (length($command)) {
             # call the command subroutine.
             # These command subroutines will probably call translate_buffer
@@ -740,8 +752,18 @@
             $buffer = $1;
             $spaces = $2;
         }
+        my $buffer_save = $buffer;
         ($command, $variant, $args, $buffer) =
             get_trailing_command($self,$buffer);
+        if (    (length $command)
+            and (defined $separated_command{$command})
+            and ($separated_command{$command} eq '-')
+            and (   (not defined $buffer)
+                 or ($buffer !~ m/^\s*$/s))) {
+            # We can extract this command.
+            $command = "";
+            $buffer = $buffer_save;
+        }
         if (length($command)) {
             unshift @trailing_commands, ($command, $variant, $args, $spaces);
         } else {
@@ -985,7 +1007,7 @@
     my ($self,$line)=@_;
     $line =~ s/^\s*%\s*po4a\s*:\s*//;
 
-    if ($line =~ /^command\s+(\*?)(\w+)\s+(.*)$/) {
+    if ($line =~ /^command\s+([-*+]?)(\w+)\s+(.*)$/) {
         my $command = $2;
         $line = $3;
         if ($1) {
@@ -1229,11 +1251,16 @@
     print "generic_command($command,$variant,@$args,@$env)="
         if ($debug{'commands'} || $debug{'environments'});
     my ($t, at e)=("",());
+    my $translated = "";
 
     # the number of arguments is checked during the extraction of the
     # arguments
 
-    my $translated = "$ESCAPE$command$variant";
+    if (   (not (defined $separated_command{$command}))
+        or $separated_command{$command} ne '+') {
+        # Use the information from %command_parameters to only translate
+        # the needed parameters
+    $translated = "$ESCAPE$command$variant";
     # handle arguments
     my @arg_types = @{$command_parameters{$command}{'types'}};
     my @arg_translated = @{$command_parameters{$command}{'translated'}};
@@ -1269,6 +1296,20 @@
         }
         $translated .= $type.$t.$type_end{$type};
     }
+    } else {
+        # Translate the command with all its arguments joined
+        my $tmp = "$ESCAPE$command$variant";
+        my ($type, $opt);
+        while (@$args) {
+            $type = shift @$args;
+            $opt  = shift @$args;
+            $tmp .= $type.$opt.$type_end{$type};
+        }
+        @e = @$env;
+        $translated = $self->translate($tmp,$self->{ref},
+                                       @e?$e[-1]:"Plain text",
+                                       "wrap" => 1);
+    }
 
     print "($translated, @$env)\n"
         if ($debug{'commands'} || $debug{'environments'});
@@ -1279,9 +1320,9 @@
     if ($_[0] =~ m/^(.*),((\{_?\}|\[_?\])*)$/) {
         my $command = $1;
         my $arg_types = $2;
-        if ($command =~ /^\*(.*)$/) {
-            $command = $1;
-            $separated{$command}='*';
+        if ($command =~ /^([-*+])(.*)$/) {
+            $command = $2;
+            $separated_command{$command}=$1;
         }
         my @types = ();
         my @translated = ();




More information about the Po4a-commits mailing list