On Wed, Feb 11, 2009 at 01:04:50AM +0900, Osamu Aoki wrote:
> I think this should be inclided as an example helper script or even integrated
> into additional --previous functionality.  wdiff makes good sense in many
> cases! 

(...)

Attached is an updated version of the script with minor enhancements in its
behaviour.

Regards

Javier
#!/usr/bin/perl -w
# Quick and dirty script to compare two msgids (when using po4a with
# --previous) with wdiff to find the differences between them

my $file1="diff1";
my $file2="diff2";

open (my $DIFF1, ">$file1") || die ("Cannot open $file1: $!");
open (my $DIFF2, ">$file2") || die ("Cannot open $file2: $!");

my $fileh="";
while ($line = <STDIN>) {
    $fileh="";
    chomp $line;
    $fileh = $DIFF1 if ( $line =~ /^\#\|/ ) ;
    $fileh = $DIFF2 if ( $line =~ /^"/ ) ;
    $line =~ s/^\#\| //;
    $line =~ s/^"//;
    $line =~ s/"$//;
    print $fileh $line if $fileh ne "" and $line ne 'msgid "';
}

close $DIFF1; close $DIFF2;

system ("wdiff -3 $file1 $file2 | less");

unlink $file1, $file2;


exit;

Reply via email to