source: tags/svn.1.5.4/SOURCE_TOOLS/diff2grep.pl

Last change on this file was 7929, checked in by westram, 14 years ago

merge from dev [7844] [7855] [7865] [7869] [7910] [7911]

  • misc minor patches affecting:
    • diff2grep
    • remake_after_change
    • COMPILE_ASSERT
    • warning fixes
  • dont export error from move_group_info
  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6my $oldfile = undef;
7my $newfile = undef;
8
9my $newpad = '';
10my $oldpad = '';
11
12my $correct = 0; # perform correction?
13my $corr    = 0; # correct by number of lines
14
15sub set_padding_and_correction() {
16  $correct = 1;
17  $corr = 0;
18
19  if (defined $oldfile and defined $newfile) {
20    my $oldlen = length($oldfile);
21    my $newlen = length($newfile);
22
23    $newpad = '';
24    $oldpad = '';
25
26    while ($oldlen<$newlen) { $oldpad .= ' '; $oldlen++; }
27    while ($newlen<$oldlen) { $newpad .= ' '; $newlen++; }
28
29    if ($oldfile ne $newfile) { $correct = 0; }
30
31    print "diff2grep.pl: oldfile='$oldfile'\n";
32    print "diff2grep.pl: newfile='$newfile'\n";
33  }
34}
35
36my $pwd = `pwd`; chomp($pwd);
37
38print "diff2grep.pl: Entering directory `$pwd'\n";
39
40my ($o1,$o2,$n1,$n2);
41
42while (defined ($_ = <>)) {
43  chomp;
44  if (/^--- ([^\t]+)\t/) {
45    $oldfile = $1;
46    set_padding_and_correction();
47  }
48  elsif (/^\+\+\+ ([^\t]+)\t/) {
49    $newfile = $1;
50    set_padding_and_correction();
51  }
52  elsif (/^-/) {
53    print "$oldfile:".($o1+$corr*$correct).":$oldpad OLD: $'\n";
54    $o1++;
55    $corr--;
56  }
57  elsif (/^\+/) {
58    print "$newfile:".($n1).":$newpad NEW: $'\n";
59    $n1++;
60    $corr++;
61  }
62  elsif (/^\@\@ -(.*),(.*) \+(.*),(.*) \@\@$/) {
63    ($o1,$o2,$n1,$n2) = ($1,$2,$3,$4);
64    print $_."\n";
65  }
66  else {
67    print $_."\n";
68    $o1++;
69    $n1++;
70  }
71}
72
73print "diff2grep.pl: Leaving directory `$pwd'\n";
74
Note: See TracBrowser for help on using the repository browser.