1c1 < #!/usr/bin/perl --- > #!/usr/bin/perl 3c3 < # $Id: hdiff,v 1.7 2002/08/16 05:50:51 peters Exp $ --- > # $Id: hdiff,v 1.4 2002/06/09 02:18:18 peters Exp $ 7c7 < # PURPOSE: HTML diff. Produces a colourised HTML diff output which is --- > # PURPOSE: HTML diff. Produces a colourised HTML diff output which is 10,11c10,11 < # SOURCE: http://www.ginini.com/software/hdiff/ < # --- > # SOURCE: www.ginini.com/software/hdiff > # 13a14,17 > # MODS: Thanks to Gordon McKinney to support recursion (-r) and > # multiple file files per diff run. Also fixed blank context > # lines removing the background fill. > # 16d19 < require 5.000; 23c26 < # For most other Unix systems, grab a copy of GNU diff from --- > # For most other Unix systems, grab a copy of GNU diff from 26c29 < $diff = '/usr/bin/diff'; --- > $diff = 'diff'; 36d38 < $diffcolorLineNum = '#666666'; # Lines containing line numbers 42c44 < $Version = "2.1.0"; --- > $Version = "1.9.9"; 46a49 > use vars qw($opt_s $opt_r); 48,51c51 < # Keep warnings happy < use vars qw($opt_s $opt_r $opt_n $opt_N); < < getopts('h:f:t:rl:sL:c:C:e:nNo:') or Usage(); --- > getopts('h:f:t:rl:s') or Usage(); 58,64d57 < if ( defined $opt_o ) { < open STDOUT, ">$opt_o" < or die "Error creating file '$opt_o' ($!)"; < } < < $tabstop = ( $opt_e > 0 ? $opt_e : 8 ) if defined $opt_e; < 72,78d64 < $opt_L = 'legend,Lines Added,Lines changed,Lines Removed,- No viewable Change -,Line ##NUM#' unless $opt_L; < < ( $TextLegend, $TextAdded, $TextChanged, $TextRemoved, $TextNoChange, $TextLineNumber ) = map htmlify($_), split /,/, $opt_L . ", MISSING , MISSING , MISSING , MISSING , MISSING , MISSING "; < < $LeftCaptionText = ( $opt_c ? htmlify($opt_c) : '#NAME#' ); < $RightCaptionText = ( $opt_C ? htmlify($opt_C) : '#NAME#' ); < 87a74,75 > exit 0; > 120,122c108,109 < if ( defined $tabstop ) { < while ( $string =~ s/\t+/' ' x (length($&) * $tabstop - length($`) % $tabstop)/e ) { } < } --- > $string =~ s/\t+/' ' x (length($&) * $tabstop - length($`) % $tabstop)/e > if ( defined $tabstop ); 141,147d127 < sub LineNumText { < my ($LineNum) = @_; < return '' unless $opt_n; < return spacedHtmlText( sprintf( "%3d:", ($$LineNum)++ ) ); < } < < #------------------------------------------------------------------------------ 173d152 < my $header_content; 175,178c154,155 < $header_content = join ( "",
); < $header_content =~ s/#TITLE/$Title/g; < print $header_content; < close(HEADER); --- > print
; > close (HEADER); 184c161 < print qq(BODY { font-family: Versana,Arial,Helvetica }\n); --- > print qq(BODY { font-family: Versana,Arial,Helvetica }\n); 209,212c186,189 < $TextLegend < $TextAdded  < $TextChanged <  $TextRemoved --- > Legend > Lines Added  > Lines changed >  Lines Removed 221c198 < close(FOOTER); --- > close (FOOTER); 233c210 < my ( $file1, $file2 ) = @_; --- > my ($file1, $file2) = @_; 241c218 < if ( defined $opt_l ) { --- > if ($opt_l) { 284c261 < print "$TextNoChange"; --- > print "- No viewable Change -"; 323d299 < 328,330d303 < < $CaptionText = $LeftCaptionText; < $CaptionText =~ s/#NAME#/$leftfile/gi; 332c305 < print qq($CaptionText); --- > print qq($leftfile); 334,336d306 < < $CaptionText = $RightCaptionText; < $CaptionText =~ s/#NAME#/$rightfile/gi; 338c308 < print qq($CaptionText); --- > print qq($rightfile); 349c319 < print qq(\n); --- > print qq(\n); 352c322 < print qq(\n); --- > print qq(\n); 359,361d328 < # In case of a number of context lines of 0 < flush_diff_rows \@leftCol, \@rightCol, $leftRow, $rightRow; < 367,376d333 < ( $LeftLineNum, $RightLineNum ) = $difftxt =~ m/^@@ \-(\d+).*\+(\d+)/; < < if ($opt_N) { < my $LeftText = $TextLineNumber; < my $RightText = $TextLineNumber; < $LeftText =~ s/#NUM#/$LeftLineNum/gi; < $RightText =~ s/#NUM#/$RightLineNum/gi; < print "$LeftText", "$RightText\n"; < } < 395d351 < my $LineNumText = LineNumText($RightLineNum); 397c353 < print qq( $LineNumText$_\n); --- > print qq( $_\n); 401c357 < $rightCol[ $rightRow++ ] = $LineNumText . $_; --- > $rightCol[ $rightRow++ ] = $_; 406c362 < $leftCol[ $leftRow++ ] = LineNumText($LeftLineNum) . $_; --- > $leftCol[ $leftRow++ ] = $_; 410c366 < print "", LineNumText($LeftLineNum), "$_", LineNumText($RightLineNum), "$_\n"; --- > print "$_$_\n"; 423,424c379,380 < print qq(); < print qq($TextNoChange); --- > print qq(tr bgcolor="$diffcolorEmpty" >); > print qq(- No viewable Change -); 426d381 < 429,431d383 < # In case diff does not return 0 (no diff) nor 1 (diffs) < die "Error running $diff $diffopts $file1 $file2\n" if ( $? >> 8 ) > 1; < 437a390 > # Display script usage 440c393 < Usage: $0 [-rsn] [-e ][-f ] [-h ] [-l ] [-L ,,,,,] [-t ] [-c <Text>] [-C <Text>] <file1/dir1> <file2/dir2> --- > Usage: $0 [-rs] [-f <html footer>] [-h <html header>] [-l <lines>] [-t <title>] <file1/dir1> <file2/dir2> 442,444d394 < -c Caption for file 1 (#NAME# in caption is replaced by file name) < -C Caption for file 2 (#NAME# in caption is replaced by file name) < -e Expand tabs of 'size' characters (Defaults to 8 if <= 0) 447,456c397 < -l Number of context lines < -n Show line numbers in front of each line < -N Show line numbers at the beginning of each block (in a separator line), < Put a '#NUM#' where you want to see the line number (otherwise it would not appear) < -o File to create instead of stdout < -r Recursively diff directories < -s Small font for printing < -t Title heading < -L Legends/Text appearing in output, defaults to: < "legend,Lines Added,Lines changed,Lines Removed,- No viewable Change -,Line ##NUM#" --- > -l Num of context lines