/[papo]/papo/tools/patchfilter/patchfilter
ViewVC logotype

Diff of /papo/tools/patchfilter/patchfilter

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by styxman, Mon Sep 16 14:55:08 2002 UTC revision 1.3 by styxman, Thu Sep 26 23:13:38 2002 UTC
# Line 3  Line 3 
3  use strict;  use strict;
4  use Data::Dumper;  use Data::Dumper;
5  $Data::Dumper::Indent= 1;  $Data::Dumper::Indent= 1;
6    use Getopt::Long;
7    
8  sub parseFilter {  sub parseFilter {
9    my @args= @_;    my @args= @_;
# Line 23  sub parseFilter { Line 24  sub parseFilter {
24  }  }
25    
26  sub loadDiff {  sub loadDiff {
27    my ($fileName)= @_;    my ($fileName, $verbose)= @_;
28        
29    open (DIFFIN, "<$fileName")    open (DIFFIN, "<$fileName")
30      or die ("miserably...");      or die ("miserably...");
# Line 32  sub loadDiff { Line 33  sub loadDiff {
33            
34    my $line= <DIFFIN>;    my $line= <DIFFIN>;
35    while ($line) {    while ($line) {
36      while ($line=~ /^Only/) {      # while ($line!~ /^diff/) {
37        while ($line!~ /^Only/) {
38        $line= <DIFFIN>;        $line= <DIFFIN>;
39      }      }
40        print STDERR $line
41          if $verbose;
42      chomp $line;      chomp $line;
43      my $patchedFile= $line;      my $patchedFile= $line;
44      $line= <DIFFIN>;      $line= <DIFFIN>;
# Line 53  sub loadDiff { Line 57  sub loadDiff {
57      my $chunkNo= 0;      my $chunkNo= 0;
58      $line= <DIFFIN>;      $line= <DIFFIN>;
59      while ($line and $line!~ /^diff / and $line!~ /^Only/) {      while ($line and $line!~ /^diff / and $line!~ /^Only/) {
60        # while ($line and $line!~ /^diff/) {
61          print STDERR $line
62            if $verbose;
63        chomp $line;        chomp $line;
64        my ($oStart, $oSize, $nStart, $nSize)= $line=~ /^\@\@ \-(\d+),(\d+) \+(\d+),(\d+) \@\@$/;        my ($oStart, $oSize, $nStart, $nSize)= $line=~ /^\@\@ \-(\d+),(\d+) \+(\d+),(\d+) \@\@/;
65          print STDERR "@@ -$oStart,$oSize +$nStart,$nSize @@\n\n"
66            if $verbose;
67        my $addedLines= $nSize-$oSize;        my $addedLines= $nSize-$oSize;
68        push @{$patch{$patchedFile}{'chunks'}}, ({        push @{$patch{$patchedFile}{'chunks'}}, ({
69          # 'header'=> $line,          # 'header'=> $line,
# Line 64  sub loadDiff { Line 73  sub loadDiff {
73                
74        $line= <DIFFIN>;        $line= <DIFFIN>;
75        while ($line and $line!~ /^\@\@.*\@\@$/ and $line!~ /^diff/ and $line!~ /^Only/) {        while ($line and $line!~ /^\@\@.*\@\@$/ and $line!~ /^diff/ and $line!~ /^Only/) {
76          # while ($line and $line=~ /^[ \+\-]/) {
77          chomp $line;          chomp $line;
78          push @{$patch{$patchedFile}{'chunks'}[$chunkNo]{'lines'}}, ($line);          push @{$patch{$patchedFile}{'chunks'}[$chunkNo]{'lines'}}, ($line);
79          $line= <DIFFIN>;          $line= <DIFFIN>;
80        }        }
81        $chunkNo++;        $chunkNo++;
82          # while ($line and $line=~ /^diff/) {
83            # $line= <DIFFIN>;
84          # }
85      }      }
86    }    }
87    return \%patch;    return \%patch;
# Line 118  sub printPatch { Line 131  sub printPatch {
131    }    }
132  }  }
133    
134    my $verbose;
135    my $options= GetOptions ('verbose'=> \$verbose);
136  my $fileName= shift @ARGV;  my $fileName= shift @ARGV;
137  my $patch= loadDiff ($fileName);  my $patch= loadDiff ($fileName, $verbose);
138  my $filter= parseFilter (@ARGV);  my $filter= parseFilter (@ARGV);
139  printPatch ($patch, $filter);  printPatch ($patch, $filter);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26