"Fossies" - the Fresh Open Source Software Archive

Member "websec-1.9.0/htmldiff" (28 Jun 2003, 990 Bytes) of package /linux/www/old/websec-1.9.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl
    2 
    3 #
    4 # htmldiff uses HTML::Diff to create an HTML file that shows the difference
    5 # between two HTML files, given on the command line.
    6 #
    7 # Contributed by Maurice Aubrey <maurice@redweek.com>
    8 #
    9 
   10 use strict;
   11 use HTML::Diff;
   12 
   13 @ARGV == 2 or die "Usage: $0 <file1> <file2>\n";
   14 
   15 
   16 my @txt;
   17 foreach (@ARGV) {
   18   open my $fh, $_ or die "unable to read '$_': $!";
   19   local $/;
   20   push @txt, scalar <$fh>;
   21 }
   22 
   23 my $changeStatus = 0;
   24 
   25 print qq{<style type="text/css"><!-- ins{color: green} del{color:red}--></style>\n};
   26 foreach (@{ html_word_diff(@txt) }) {
   27   my($type, $left, $right) = @$_;
   28 
   29   # debug
   30   #$left =~ s/\n/ /g;
   31   #$right =~ s/\n/ /g;
   32   #print "TYPE:$type\nLEFT: $left\nRIGHT: $right\n\n";
   33   #next;
   34 
   35   if ($type eq 'u') {
   36     print $left;
   37   } else {
   38     print "<del>$left</del>" if length $left;
   39     print "<ins>$right</ins>" if length $right;
   40     $changeStatus = 1 if (length $left or length $right);
   41   }
   42 }
   43 
   44 # print "exiting with status: ".$changeStatus."\n";
   45 exit $changeStatus;