Software Freedom Law Center

Changeset 79

Show
Ignore:
Timestamp:
04/28/08 10:14:13 (3 months ago)
Author:
bkuhn
Message:

r102@hughes: bkuhn | 2008-04-28 10:14:06 -0400

  • Added code to pdiff.in that actually calls the diff commands
  • Added pdiff, diff, and meld commands to configure.in
    # Added dependency on File::Temp in Makefile.PL
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/apps/pdfdiff/ChangeLog

    r72 r79  
     12008-04-28  Bradley M. Kuhn  <bkuhn@ebb.org> 
     2 
     3        * configure.in: Added checks for pdiff, diff, and meld. 
     4 
     5        * pdfdiff.in: Added proper diff options. 
     6 
    172008-04-27  Bradley M. Kuhn  <bkuhn@ebb.org> 
    28 
  • trunk/apps/pdfdiff/configure.in

    r68 r79  
    2424AM_INIT_AUTOMAKE(pdfdiff, 0.1) 
    2525 
    26 # allow users to set a classpath, otherwise take it from the enivornment 
    27  
    28 AC_ARG_WITH(classpath,[  --with-classpath                Path to other Java classes], classpath=$withval, classpath=$CLASSPATH) 
    29  
    3026# make sure we have the right version of perl 
    3127 
     
    3531AC_SUBST(PERL_VERSION_NEEDED) 
    3632 
     33 
    3734PDFDIFF_AC_PROG_PERL($PERL_VERSION_NEEDED, AC_MSG_ERROR([*** Did you really expect to use perljvm without perl? ***]), ,AC_MSG_ERROR([*** perl >= $PERL_VERSION_NEEDED is not installed - perljvm will not function without it. ***])) 
     35 
     36AC_PATH_PROG(PDIFF,pdiff) 
     37AC_PATH_PROG(DIFF,diff) 
     38AC_PATH_PROG(MELD,meld) 
     39 
    3840 
    3941# Generate the Makefiles 
  • trunk/apps/pdfdiff/pdfdiff.in

    r70 r79  
    3131use Pod::Usage; 
    3232use PDF::Extract::Text; 
     33use File::Temp (); 
     34 
     35my $DIFF_CMD  = '@DIFF@'; 
     36my $PDIFF_CMD = '@PDIFF@'; 
     37my $MELD_CMD = '@MELD@'; 
    3338 
    3439=head1 SYNOPSIS 
     
    5661 
    5762     --pdiff=PSFILE_OUTPUT      Use "pdiff" to generate output to PSFILE_OUTPUT 
    58      --pdiff-options=OPTIONS    Add OPTIONS to the pdiff command 
    5963 
    6064 MELD 
     
    135139  $PDF::OCR::Thorough::DEBUG = 1; 
    136140} 
     141 
     142my($oldTextFile, $newTextFile, $oldFH, $newFH); 
     143 
    137144if ($saveTemplate) { 
    138   open(OLD_TEXT, ">${saveTemplate}-old.txt") or 
    139     pod2usage("$0: cannot open ${saveTemplate}-old.txt for writing: $!"); 
    140   open(NEW_TEXT, ">${saveTemplate}-new.txt") or 
    141     pod2usage("$0: cannot open ${saveTemplate}-new.txt for writing: $!"); 
    142 
     145  $oldTextFile = "${saveTemplate}-old.txt"; 
     146  $newTextFile =  "${saveTemplate}-new.txt"; 
     147  $oldFH = new IO::File ">$oldTextFile" or  
     148    pod2usage("$0: cannot open $oldTextFile for writing: $!"); 
     149  $newFH = new IO::File ">$newTextFile" or  
     150    pod2usage("$0: cannot open $newTextFile for writing: $!"); 
     151} else { 
     152  $oldFH = new File::Temp(TEMPLATE => 'oldXXXXXXXX', 
     153                          UNLINK => 1, SUFFIX => '.txt', DIR => File::Spec->tmpdir); 
     154  $oldTextFile = "$oldFH"; 
     155  $newFH = new File::Temp(TEMPLATE => 'newXXXXXXXXX', 
     156                          UNLINK => 1, SUFFIX => '.txt', DIR => File::Spec->tmpdir); 
     157  $newTextFile = "$newFH"; 
     158
     159 
    143160my $oldExtract = new PDF::Extract::Text(pdfFile => $oldFile) 
    144161  or die("cannot do PDF::OCR::Thorough on $oldFile"); 
     
    149166my $newText = $newExtract->getText(); 
    150167 
    151 print "OLD: $oldText\n"; 
    152 print "NEW: $newText\n"; 
     168print $oldFH $oldText; 
     169print $newFH $newText; 
     170 
     171$oldFH->close(); 
     172$newFH->close(); 
     173 
     174my(@commands); 
     175 
     176if ($pdiffOutputFile) { 
     177  my $list = [ $PDIFF_CMD, "-o", $pdiffOutputFile ]; 
     178  push(@{$list}, $extraDiffOptions) if $extraDiffOptions; 
     179  push(@{$list}, $oldTextFile, $newTextFile); 
     180  push(@commands, $list); 
     181
     182if ($useMeld) { 
     183  my $list = [ $MELD_CMD ]; 
     184  push(@{$list}, $extraDiffOptions) if $extraDiffOptions; 
     185  push(@{$list}, $oldTextFile, $newTextFile); 
     186  push(@commands, $list); 
     187
     188 
     189unless ($pdiffOutputFile or $useMeld) { 
     190  my $list = [ ($diffCmd ? $diffCmd : $DIFF_CMD) ]; 
     191  push(@{$list}, $extraDiffOptions) if $extraDiffOptions; 
     192  push(@{$list}, $oldTextFile, $newTextFile); 
     193  push(@commands, $list); 
     194
     195foreach my $cmd (@commands) { 
     196  system(@{$cmd}); 
     197
     198$oldFH = $newFH = undef; 
     199 
     200exit 0; 
  • trunk/apps/pdfdiff/Perl/Makefile.PL

    r72 r79  
    2929      'PDF::OCR'                                         => '1.07', 
    3030      'Text::Autoformat'                                 => '1.14', 
    31       'Text::Aspell'                                     => '0.04' 
     31      'Text::Aspell'                                     => '0.04', 
     32      'File::Temp'                                       => '0.00' 
    3233   }, 
    3334    MAKEFILE => "Makefile.perl-generated", 

SFLC Main Page

[frdm] Support SFLC