[Po4a-commits] po4a/lib/Locale/Po4a Man.pm,1.35,1.36

Martin Quinson po4a-devel@lists.alioth.debian.org
Wed, 18 Aug 2004 00:11:24 +0000


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

Modified Files:
	Man.pm 
Log Message:
Deal properly with '\ ' in macro arguments. Ie, stop changing '.BI -a\  addresses' to '.BI "-a addresses"'

Index: Man.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Man.pm,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- Man.pm	17 Aug 2004 22:33:09 -0000	1.35
+++ Man.pm	18 Aug 2004 00:11:22 -0000	1.36
@@ -266,13 +266,12 @@
     my $self=shift;
     if (scalar @_) { 
 	$self->pushline(join(" ",map { defined $_ ? 
-					 (
-					   $_ eq '0' ? "0" 
-					             : ( length($_) && m/ / ? "\"$_\"" 
-							                    : "$_"||'""'
-						       )
+					 ($_ eq '0' ? "0" 
+					            : ( length($_) && m/ / ? "\"$_\"" 
+							                   : "$_"||'""'
+						      )
 				         ) : ''
-				     } @_)."\n");
+				      } @_)."\n");
     } else {
 	$self->pushline("\n");
     }
@@ -430,8 +429,7 @@
 
 # shortcut
 sub t { 
-    my ($self,$str)=(shift,shift);
-    return $self->translate($str);
+    return $_[0]->translate($_[1]);
 }
 
 
@@ -494,6 +492,12 @@
 	    my @args=();
 	    my $buffer="";
 	    my $escaped=0;
+	    # change non-breaking space before to ensure that split does what we want
+	    # We change them back before pushing into the arguments. The one which will be
+	    # translated will have the same change again (in pre_trans and post_trans), but
+	    # the ones which won't get translated are not changed anymore. Let's play safe.
+	    $line =~ s/\\ /\xA0/g; 
+	    
 	    foreach my $elem (split (/ +/,$line)) {
 		print STDERR ">>Seen $elem(buffer=$buffer;esc=$escaped)\n"
 		    if ($debug{'splitargs'});
@@ -506,13 +510,18 @@
 		    if ($buffer =~ m/^"(.*)"(.+)$/) {
 			print STDERR "End of quote, with stuff after it\n"
 			    if ($debug{'splitargs'});
-			push @args,$1;
-			push @args,$2;
+			my ($a,$b)=($1,$2);
+			$a =~ s/\xA0/\\ /g;
+			$b =~ s/\xA0/\\ /g;
+			push @args,$a;
+			push @args,$b;
 			$buffer = "";
 		    } elsif ($buffer =~ m/^"(.*)"$/) {
 			print STDERR "End of a quote\n"
 			    if ($debug{'splitargs'});
-			push @args,$1;
+			my $a = $1;
+			$a =~ s/\xA0/\\ /g;
+			push @args,$a;
 			$buffer = "";
 		    } elsif ($escaped) {
 			print STDERR "End of an escaped sequence\n"
@@ -525,6 +534,7 @@
 					"po4a::man: macro to control the wrapping."),
 					 $ref)."\n";
 			}
+			$buffer =~ s/\xA0/\\ /g;
 			push @args,$buffer;
 			$buffer = "";
 			$escaped = 0;
@@ -532,7 +542,9 @@
 		} elsif ($elem =~ m/^"(.*)"$/) {
 		    print STDERR "Quoted, no space\n"
 			if ($debug{'splitargs'});
-		    push @args,$1;
+		    my $a = $1;
+		    $a =~ s/\xA0/\\ /g;
+		    push @args,$a;
 		} elsif ($elem =~ m/^"/) { #") {
 		    print STDERR "Begin of a quoting arg\n"
 			if ($debug{'splitargs'});
@@ -552,6 +564,7 @@
 	    }
 	    if ($buffer) {
 		$buffer=~ s/"//g; #"
+		$buffer =~ s/\xA0/\\ /g;
 		push @args,$buffer;
 	    }
 	    if ($debug{'splitargs'}) {
@@ -559,13 +572,13 @@
 		map { print STDERR "$_^"} @args;
 		print STDERR "\n";
 	    }
-			  
+	    # Done with spliting the args. Do the job.
 
 	    if ($macro eq 'B' || $macro eq 'I') {
 		# pass macro name
 		shift @args;
 		my $arg=join(" ",@args);
-		$arg =~ s/^ //;
+		$arg =~ s/^ +//;
 		this_macro_needs_args($macro,$ref,$arg);
 		$paragraph .= "\\f$macro".$arg."\\fP\n";
 		goto LINE;